Class: Silas::Engines::RubyLLM

Inherits:
Base
  • Object
show all
Defined in:
lib/silas/engines/ruby_llm.rb

Overview

The :ruby_llm adapter: ONE model call per step, streamed, with tool interception. Silas's Ledger owns tool execution, so tools are registered as halt-proxies — RubyLLM sees the schemas, but the moment the model requests a tool the proxy halts the chat loop and the calls are handed back to the framework untouched.

Defined Under Namespace

Classes: HaltProxy

Constant Summary collapse

INTERCEPTED =
"__silas_intercepted__".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.loop_ownershipObject



11
# File 'lib/silas/engines/ruby_llm.rb', line 11

def self.loop_ownership = :framework

Instance Method Details

#execute_step(context, &on_event) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/silas/engines/ruby_llm.rb', line 13

def execute_step(context, &on_event)
  chat = build_chat(context, &on_event)

  response = ActiveSupport::Notifications.instrument("silas.step",
                                                     turn_id: context[:turn]&.id,
                                                     index: context[:index],
                                                     model: context[:model]) do
    chat.complete
  end

  to_result(chat, response)
end