Class: Girb::Providers::RubyLlm
- Inherits:
-
Base
- Object
- Base
- Girb::Providers::RubyLlm
- Defined in:
- lib/girb/providers/ruby_llm.rb
Instance Method Summary collapse
- #chat(messages:, system_prompt:, tools:, binding: nil) ⇒ Object
-
#initialize(model: nil) ⇒ RubyLlm
constructor
A new instance of RubyLlm.
Constructor Details
#initialize(model: nil) ⇒ RubyLlm
Returns a new instance of RubyLlm.
9 10 11 |
# File 'lib/girb/providers/ruby_llm.rb', line 9 def initialize(model: nil) @model = model end |
Instance Method Details
#chat(messages:, system_prompt:, tools:, binding: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/girb/providers/ruby_llm.rb', line 13 def chat(messages:, system_prompt:, tools:, binding: nil) # Use specified model or RubyLLM's default = @model ? { model: @model } : {} ruby_llm_chat = ::RubyLLM.chat(**) # Set system prompt ruby_llm_chat.with_instructions(system_prompt) if system_prompt && !system_prompt.empty? # Add tool schemas (for API payload generation only, not auto-executed) tool_instances = build_tools(tools) tool_instances.each { |tool| ruby_llm_chat.with_tool(tool) } # Add all messages to the chat (ruby_llm_chat, ) # Get raw response without auto-executing tools response = raw_complete(ruby_llm_chat) parse_response(response) rescue Faraday::BadRequestError => e Response.new(error: "API Error: #{e.}") rescue StandardError => e Response.new(error: "Error: #{e.}") end |