From ca089c3231ceb6b095a51448e4a4af96d98e764e Mon Sep 17 00:00:00 2001 From: Obie Fernandez Date: Sun, 10 Nov 2024 22:04:54 -0500 Subject: [PATCH] support for multiple tool calls --- CHANGELOG.md | 3 +++ Gemfile.lock | 2 +- README.md | 24 ++++++++++++++++++++++++ lib/raix/version.rb | 2 +- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e4ea64..c1d7680 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 489d86f..dedcfc7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/README.md b/README.md index 7b522cc..ebe06a5 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/lib/raix/version.rb b/lib/raix/version.rb index 8f8e608..1b89b15 100644 --- a/lib/raix/version.rb +++ b/lib/raix/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Raix - VERSION = "0.4.3" + VERSION = "0.4.4" end