Class: Girb::Providers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/girb/providers/base.rb

Overview

Base class for LLM providers Implement this class to add support for new LLM providers

Example:

class MyProvider < Girb::Providers::Base
  def chat(messages:, system_prompt:, tools:)
    # Call your LLM API
    # Return Response object
  end
end

Girb.configure do |c|
  c.provider = MyProvider.new(api_key: "...")
end

Defined Under Namespace

Classes: Response

Instance Method Summary collapse

Instance Method Details

#chat(messages:, system_prompt:, tools:, binding: nil) ⇒ Response

Send a chat request to the LLM

Parameters:

  • messages (Array<Hash>)

    Conversation history in normalized format Each message has :role (:user, :assistant, :tool_call, :tool_result) and :content

  • system_prompt (String)

    System prompt

  • tools (Array<Hash>)

    Tool definitions in normalized format

  • binding (Binding) (defaults to: nil)

    Optional binding for tool execution (used by some providers)

Returns:

  • (Response)

    Response object with text and/or function_calls

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/girb/providers/base.rb', line 29

def chat(messages:, system_prompt:, tools:, binding: nil)
  raise NotImplementedError, "#{self.class}#chat must be implemented"
end