Class: RubyLLM::Contract::Adapters::RubyLLM
- 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
Instance Method Details
#call(messages:, **options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_llm/contract/adapters/ruby_llm.rb', line 9 def call(messages:, **) system_contents, conversation = () conversation = fallback_conversation(system_contents, conversation) chat = build_chat(, system_contents) add_history(chat, conversation[0..-2]) # `with: nil` is a documented no-op in RubyLLM (verified against # 1.15.0: chat.rb:36-37 `build_content(message, nil)` -> content.rb:8-14 # `Content.new(text, nil)` keeps text-only path when attachments # are empty; raise only fires when BOTH text and attachments are nil, # and we always pass a non-nil string thanks to `&.fetch(:content, "")`). response = chat.ask( conversation.last&.fetch(:content, ""), with: [:attachment] ) build_response(response) end |