Class: Phronomy::LLMAdapter::RubyLLM

Inherits:
Base
  • Object
show all
Defined in:
lib/phronomy/llm_adapter/ruby_llm.rb

Overview

LLM adapter that delegates to the RubyLLM blocking client.

This is the default adapter used by Phronomy agents. It wraps +chat.ask+ (and its streaming variant) so that the blocking HTTP call runs inside BlockingAdapterPool rather than on the EventLoop thread or the caller's thread directly.

Examples:

Explicitly configuring this adapter

Phronomy.configure do |c|
  c.llm_adapter = Phronomy::LLMAdapter::RubyLLM.new
end

Instance Method Summary collapse

Methods inherited from Base

#complete_async, #stream_async

Instance Method Details

#complete(chat, message, config: {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Delegates to +chat.ask(message)+.

Parameters:

  • chat (Object)

    RubyLLM chat session

  • message (String)

    user message

  • config (Hash) (defaults to: {})

    invocation config (not used directly by this impl)

Returns:

  • (Object)

    RubyLLM response



24
25
26
# File 'lib/phronomy/llm_adapter/ruby_llm.rb', line 24

def complete(chat, message, config: {})
  chat.ask(message)
end

#stream(chat, message, config: {}) {|chunk| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Delegates to +chat.ask(message) { |chunk| block.call(chunk) }+.

Parameters:

  • chat (Object)

    RubyLLM chat session

  • message (String)

    user message

  • config (Hash) (defaults to: {})

    invocation config

Yields:

  • (chunk)

    streaming chunk forwarded from +chat.ask+

Returns:

  • (Object)

    RubyLLM response



36
37
38
# File 'lib/phronomy/llm_adapter/ruby_llm.rb', line 36

def stream(chat, message, config: {}, &block)
  chat.ask(message, &block)
end