Class: Bristow::Agencies::Supervisor

Inherits:
Bristow::Agency show all
Defined in:
lib/bristow/agencies/supervisor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Bristow::Agency

chat, #find_agent

Methods included from Sgetter

included

Constructor Details

#initialize(agents: self.class.agents.dup, custom_instructions: self.class.custom_instructions, termination: Bristow::Terminations::MaxMessages.new(100)) ⇒ Supervisor

Returns a new instance of Supervisor.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bristow/agencies/supervisor.rb', line 8

def initialize(agents: self.class.agents.dup, custom_instructions: self.class.custom_instructions, termination: Bristow::Terminations::MaxMessages.new(100))
  @custom_instructions = custom_instructions
  @agents = agents
  @termination = termination
  @supervisor = Agents::Supervisor.new(
    child_agents: agents,
    agency: self,
    custom_instructions: custom_instructions,
    termination: termination
  )
end

Instance Attribute Details

#supervisorObject (readonly)

Returns the value of attribute supervisor.



4
5
6
# File 'lib/bristow/agencies/supervisor.rb', line 4

def supervisor
  @supervisor
end

Instance Method Details

#chat(messages, &block) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/bristow/agencies/supervisor.rb', line 20

def chat(messages, &block)
  raise "Supervisor not set" unless supervisor

  # Convert string message to proper format
  messages = [{ role: "user", content: messages }] if messages.is_a?(String)

  supervisor.chat(messages, &block)
end