Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Tool Usage to Work w/ More LLMs #48

Merged
merged 1 commit into from
Aug 16, 2024

Conversation

ksylvest
Copy link
Owner

@ksylvest ksylvest commented Jul 18, 2024

Finalize tool call APIs to work as follows:

CLIENT = OmniAI::Client.find(provider: '...') # 'mistral' / 'google' / 'openai' / 'anthropic'

TOOL = OmniAI::Tool.new(
  proc { |location:, unit: 'celsius'| "#{rand(20..50)}° #{unit} in #{location}" },
  name: 'Weather',
  description: 'Lookup the weather in a location',
  parameters: OmniAI::Tool::Parameters.new(
    properties: {
      location: OmniAI::Tool::Property.string(description: 'e.g. Toronto'),
      unit: OmniAI::Tool::Property.string(enum: %w[celcius farenheit]),
    },
    required: %i[location]
  )
)

puts '> [SYSTEM] You are an expert in weather.'
puts '> [USER] What is the weather in "London" in celsius and "Madrid" in fahrenheit?'
response = CLIENT.chat(tools: [TOOL]) do |prompt|
  prompt.system 'You are an expert in weather.'
  prompt.user 'What is the weather in "London" in celsius and "Madrid" in fahrenheit?'
end
puts response.text

Dependencies:

@ksylvest ksylvest force-pushed the ksylvest/use-serializer-for-response branch from 846df67 to 15ff653 Compare July 19, 2024 04:04
@ksylvest ksylvest force-pushed the ksylvest/use-serializer-for-response branch 2 times, most recently from e1c7c2c to ce4e652 Compare August 5, 2024 16:56
@ksylvest ksylvest force-pushed the ksylvest/use-serializer-for-response branch 3 times, most recently from 0559fc9 to 964fcde Compare August 9, 2024 20:18
@ksylvest ksylvest force-pushed the ksylvest/use-serializer-for-response branch 7 times, most recently from fee0260 to 279c5d6 Compare August 15, 2024 17:05
@ksylvest ksylvest force-pushed the ksylvest/use-serializer-for-response branch 7 times, most recently from 068bb71 to a6333d9 Compare August 15, 2024 21:29
@ksylvest ksylvest force-pushed the ksylvest/use-serializer-for-response branch from a6333d9 to d860988 Compare August 16, 2024 17:20
@ksylvest ksylvest merged commit 6fa481d into main Aug 16, 2024
6 of 8 checks passed
@ksylvest ksylvest deleted the ksylvest/use-serializer-for-response branch August 20, 2024 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant