Class: Envoy::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/envoy/runner.rb

Constant Summary collapse

ERROR_CONVENTION =
<<~TXT.freeze
  When a tool returns a JSON object with an "error" key, it failed. The
  "type" tells you why: "not_found" (no such record), "forbidden" (you may
  not do that), "invalid" (bad arguments). Explain the problem to the user
  instead of retrying blindly.
TXT

Instance Method Summary collapse

Constructor Details

#initialize(conversation:) ⇒ Runner

Returns a new instance of Runner.



10
11
12
# File 'lib/envoy/runner.rb', line 10

def initialize(conversation:)
  @conversation = conversation
end

Instance Method Details

#call(content:, &on_event) ⇒ Object



14
15
16
17
18
19
# File 'lib/envoy/runner.rb', line 14

def call(content:, &on_event)
  tools = compiled_tools
  Envoy.llm(conversation: @conversation)
       .run(content: content, tools: tools, instructions: instructions, &on_event)
  backfill_statuses!
end