Class: RubyLLM::Contract::Adapters::RubyLLM

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_llm/contract/adapters/ruby_llm.rb

Constant Summary collapse

CHAT_OPTION_METHODS =

Maps option keys to the RubyLLM chat method and argument form.

{
  temperature: :with_temperature,
  schema: :with_schema
}.freeze

Instance Method Summary collapse

Methods inherited from Base

#clone_for_concurrency

Instance Method Details

#call(messages:, **options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/ruby_llm/contract/adapters/ruby_llm.rb', line 9

def call(messages:, **options)
  system_contents, conversation = partition_messages(messages)
  conversation = fallback_conversation(system_contents, conversation)

  chat = build_chat(options, system_contents)
  add_history(chat, conversation[0..-2])

  response = chat.ask(conversation.last&.fetch(:content, ""))
  build_response(response)
end