Class: Silas::Agent
- Inherits:
-
Object
- Object
- Silas::Agent
- Defined in:
- lib/silas/agent.rb
Overview
The parsed agent definition: app/agent/agent.yml (data-only config, eve's keys) over Silas.config defaults.
Class Method Summary collapse
Instance Method Summary collapse
- #description ⇒ Object
-
#final_answer ⇒ Object
Optional JSON schema for the turn's final answer (raw Hash, passed to RubyLLM's with_schema).
-
#initialize(attrs = {}) ⇒ Agent
constructor
A new instance of Agent.
- #limits ⇒ Object
-
#max_cost ⇒ Object
dollars per turn.
-
#max_input_tokens ⇒ Object
cumulative input tokens per turn.
- #max_steps ⇒ Object
- #model ⇒ Object
-
#start(input:, metadata: {}, channel: nil, continuation_token: nil) ⇒ Object
Start a session with its first turn.
-
#timeout ⇒ Object
wall-clock seconds per turn.
Constructor Details
#initialize(attrs = {}) ⇒ Agent
Returns a new instance of Agent.
13 14 15 |
# File 'lib/silas/agent.rb', line 13 def initialize(attrs = {}) @attrs = attrs end |
Class Method Details
.load(root: Rails.root, dir: nil) ⇒ Object
7 8 9 10 11 |
# File 'lib/silas/agent.rb', line 7 def self.load(root: Rails.root, dir: nil) dir ||= root.join("app/agent") path = Pathname(dir).join("agent.yml") new(path.exist? ? YAML.safe_load(path.read) || {} : {}) end |
Instance Method Details
#description ⇒ Object
18 19 20 21 |
# File 'lib/silas/agent.rb', line 18 def description = @attrs["description"].to_s # Optional JSON schema for the turn's final answer (raw Hash, passed to # RubyLLM's with_schema). Model-visible state: folded into the definitions # digest when present, so a mid-turn change fails loudly. |
#final_answer ⇒ Object
Optional JSON schema for the turn's final answer (raw Hash, passed to RubyLLM's with_schema). Model-visible state: folded into the definitions digest when present, so a mid-turn change fails loudly.
22 |
# File 'lib/silas/agent.rb', line 22 def final_answer = @attrs["final_answer"] |
#limits ⇒ Object
23 |
# File 'lib/silas/agent.rb', line 23 def limits = @attrs["limits"] || {} |
#max_cost ⇒ Object
dollars per turn
26 |
# File 'lib/silas/agent.rb', line 26 def max_cost = limits["max_cost"] # dollars per turn |
#max_input_tokens ⇒ Object
cumulative input tokens per turn
25 |
# File 'lib/silas/agent.rb', line 25 def max_input_tokens = limits["max_input_tokens"] # cumulative input tokens per turn |
#max_steps ⇒ Object
24 |
# File 'lib/silas/agent.rb', line 24 def max_steps = limits["max_steps"] || Silas.config.max_steps |
#model ⇒ Object
17 |
# File 'lib/silas/agent.rb', line 17 def model = @attrs["model"] || Silas.config.default_model |
#start(input:, metadata: {}, channel: nil, continuation_token: nil) ⇒ Object
Start a session with its first turn. channel/continuation_token let a channel bind the session to an external thread (backward-compatible).
31 32 33 34 35 |
# File 'lib/silas/agent.rb', line 31 def start(input:, metadata: {}, channel: nil, continuation_token: nil) session = Session.create!(metadata: , channel: channel, continuation_token: continuation_token) session.continue(input: input) session end |
#timeout ⇒ Object
wall-clock seconds per turn
27 |
# File 'lib/silas/agent.rb', line 27 def timeout = limits["timeout"] # wall-clock seconds per turn |