Sha256: 49ecb4c0ac2e6c8ee156e3af2158550eeb79a2a65ce9c1a82200ae3f83326138

Contents?: true

Size: 905 Bytes

Versions: 15

Compression:

Stored size: 905 Bytes

Contents

require_relative "../bootstrap"

def client
  OpenAISwarm.new
end

def get_weather(location, time= Time.now)
  { location: location, temperature: "65", time: time }.to_json
end

def send_email(recipient, subject, body)
  puts "Sending email..."
  puts "To: #{recipient}"
  puts "Subject: #{subject}"
  puts "Body: #{body}"
  puts "Sent!"
end

def function_instance_send_email
  OpenAISwarm::FunctionDescriptor.new(
    target_method: :send_email
  )
end

def function_instance_get_weather
  OpenAISwarm::FunctionDescriptor.new(
    target_method: :get_weather,
    description: 'Get the current weather in a given location. Location MUST be a city.'
  )
end

def weather_agent
  OpenAISwarm::Agent.new(
    name: "Weather Agent",
    instructions: "You are a helpful agent.",
    model: "gpt-4o-mini",
    functions: [
      function_instance_send_email,
      function_instance_get_weather
    ]
  )
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ruby-openai-swarm-0.4.0.1 examples/weather_agent/agents.rb
ruby-openai-swarm-0.4.0 examples/weather_agent/agents.rb
ruby-openai-swarm-0.3.1 examples/weather_agent/agents.rb
ruby-openai-swarm-0.3.0.1 examples/weather_agent/agents.rb
ruby-openai-swarm-0.3.0 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.9 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.8 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.7 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.6 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.5 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.4 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.3 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.2 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.1 examples/weather_agent/agents.rb
ruby-openai-swarm-0.2.0 examples/weather_agent/agents.rb