Class: SolidAgents::Runtime::RubyLlmAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/solid_agents/runtime/ruby_llm_adapter.rb

Instance Method Summary collapse

Instance Method Details

#execute(run:, prompt:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/solid_agents/runtime/ruby_llm_adapter.rb', line 8

def execute(run:, prompt:)
  agent_class = SolidAgents::Agents.for_owner(run.stage_owner)
  agent = agent_class.new(run: run, context: run.prompt_payload || {})
  response = agent.call(prompt)
  output = response.respond_to?(:content) ? response.content.to_s : response.to_s

  Result.new(ok: true, output: output, error: nil, metadata: {agent_class: agent_class.name, stage: run.stage, owner: run.stage_owner})
rescue StandardError => e
  Result.new(ok: false, output: nil, error: e.message, metadata: {agent_class: agent_class&.name, stage: run.stage, owner: run.stage_owner, exception: e.class.name})
end