Class: DeepAgentsRb::SubAgent

Inherits:
Object
  • Object
show all
Defined in:
lib/deepagents/deepagentsrb/sub_agent.rb

Overview

SubAgent class to define sub-agents

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, description:, prompt:, tools: nil) ⇒ SubAgent

Returns a new instance of SubAgent.



6
7
8
9
10
11
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 6

def initialize(name:, description:, prompt:, tools: nil)
  @name = name
  @description = description
  @prompt = prompt
  @tools = tools
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 4

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 4

def name
  @name
end

#promptObject (readonly)

Returns the value of attribute prompt.



4
5
6
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 4

def prompt
  @prompt
end

#toolsObject (readonly)

Returns the value of attribute tools.



4
5
6
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 4

def tools
  @tools
end

Class Method Details

.from_h(hash) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 23

def self.from_h(hash)
  new(
    name: hash[:name],
    description: hash[:description],
    prompt: hash[:prompt],
    tools: hash[:tools]
  )
end

Instance Method Details

#to_hObject



13
14
15
16
17
18
19
20
21
# File 'lib/deepagents/deepagentsrb/sub_agent.rb', line 13

def to_h
  hash = {
    name: @name,
    description: @description,
    prompt: @prompt
  }
  hash[:tools] = @tools if @tools
  hash
end