Sha256: c7a1bd66fc8f6af9a62deffffdd31ef2d6f6f854d5fc11d56d32b3610bc85d38
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
require_relative "../bootstrap" client = OpenAISwarm.new def get_weather(location:) "{'temp':67, 'unit':'F'}" end function_instance = OpenAISwarm::FunctionDescriptor.new( target_method: :get_weather, description: 'Simulate fetching weather data' ) agent = OpenAISwarm::Agent.new( name: "Agent", instructions: "You are a helpful agent.", model: "gpt-4o-mini", functions: [function_instance] ) # debugger logger: {:model=>"gpt-4o-mini", :messages=>[{:role=>"system", :content=>"You are a helpful agent."}, {"role"=>"user", "content"=>"What's the weather in NYC?"}], :tools=>[{:type=>"function", :function=>{:name=>"get_weather", :description=>"", :parameters=>{:type=>"object", :properties=>{:location=>{:type=>"string"}}, :required=>["location"]}}}], :stream=>false, :parallel_tool_calls=>true} response = client.run( messages: [{"role" => "user", "content" => "What's the weather in NYC?"}], agent: agent, debug: true, ) pp response.messages.last # print(response.messages[-1]["content"]) # The current temperature in New York City is 67°F. => nil
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby-openai-swarm-0.2.2 | examples/basic/function_calling.rb |
ruby-openai-swarm-0.2.1 | examples/basic/function_calling.rb |
ruby-openai-swarm-0.2.0 | examples/basic/function_calling.rb |