Skip to content

Commit

Permalink
support for multiple tool calls
Browse files Browse the repository at this point in the history
  • Loading branch information
obie committed Nov 11, 2024
1 parent f401db0 commit ca089c3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@

## [0.4.3] - 2024-11-11
- adds support for `Predicate` module

## [0.4.4] - 2024-11-11
- adds support for multiple tool calls in a single response
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
raix (0.4.3)
raix (0.4.4)
activesupport (>= 6.0)
open_router (~> 0.2)
ruby-openai (~> 7.0)
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,30 @@ RSpec.describe WhatIsTheWeather do
end
```

#### Multiple Tool Calls

Some AI models (like GPT-4) can make multiple tool calls in a single response. When this happens, Raix will automatically handle all the function calls sequentially and return an array of their results. Here's an example:

```ruby
class MultipleToolExample
include Raix::ChatCompletion
include Raix::FunctionDispatch

function :first_tool do |arguments|
"Result from first tool"
end

function :second_tool do |arguments|
"Result from second tool"
end
end

example = MultipleToolExample.new
example.transcript << { user: "Please use both tools" }
results = example.chat_completion(openai: "gpt-4o")
# => ["Result from first tool", "Result from second tool"]
```

#### Manually Stopping a Loop

To loop AI components that don't interact with end users, at least one function block should invoke `stop_looping!` whenever you're ready to stop processing.
Expand Down
2 changes: 1 addition & 1 deletion lib/raix/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Raix
VERSION = "0.4.3"
VERSION = "0.4.4"
end

0 comments on commit ca089c3

Please sign in to comment.