Class: OpenAISwarm::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-openai-swarm/agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: "Agent", model: "gpt-4", instructions: "You are a helpful agent.", functions: [], tool_choice: nil, temperature: nil, parallel_tool_calls: true, resource: nil, noisy_tool_calls: [], strategy: {}, current_tool_name: nil, memory: nil) ⇒ Agent

These attributes can be read and written externally. They include:

  • name: The name of the agent.

  • model: The model used, e.g., “gpt-4”.

  • resource: Additional custom parameters or data that the agent might need.

  • noisy_tool_calls: is an array that contains the names of tool calls that should be excluded because they are considered “noise”.

These tool calls generate irrelevant or unnecessary messages that the agent should not send to OpenAI. When filtering messages, any message that includes these tool calls will be removed from the list, preventing them from being sent to OpenAI.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ruby-openai-swarm/agent.rb', line 20

def initialize(
  name: "Agent",
  model: "gpt-4",
  instructions: "You are a helpful agent.",
  functions: [],
  tool_choice: nil,
  temperature: nil,
  parallel_tool_calls: true,
  resource: nil,
  noisy_tool_calls: [],
  strategy: {},
  current_tool_name: nil,
  memory: nil
)
  @name = name
  @model = model
  @instructions = instructions
  @functions = functions
  @tool_choice = tool_choice
  @temperature = temperature
  @parallel_tool_calls = parallel_tool_calls
  @resource = resource
  @noisy_tool_calls = noisy_tool_calls
  @strategy = Agents::StrategyOptions.new(strategy)
  @current_tool_name = current_tool_name.nil? ? nil : current_tool_name.to_s
  @memory = memory
end

Instance Attribute Details

#current_tool_nameObject

Returns the value of attribute current_tool_name.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def current_tool_name
  @current_tool_name
end

#functionsObject

Returns the value of attribute functions.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def functions
  @functions
end

#instructionsObject

Returns the value of attribute instructions.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def instructions
  @instructions
end

#memoryObject

Returns the value of attribute memory.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def memory
  @memory
end

#modelObject

Returns the value of attribute model.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def model
  @model
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def name
  @name
end

#noisy_tool_callsObject

Returns the value of attribute noisy_tool_calls.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def noisy_tool_calls
  @noisy_tool_calls
end

#parallel_tool_callsObject

Returns the value of attribute parallel_tool_calls.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def parallel_tool_calls
  @parallel_tool_calls
end

#resourceObject

Returns the value of attribute resource.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def resource
  @resource
end

#strategyObject

Returns the value of attribute strategy.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def strategy
  @strategy
end

#temperatureObject

Returns the value of attribute temperature.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def temperature
  @temperature
end

#tool_choiceObject

Returns the value of attribute tool_choice.



3
4
5
# File 'lib/ruby-openai-swarm/agent.rb', line 3

def tool_choice
  @tool_choice
end