Class: Crimson::Client::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/crimson/client/base.rb

Overview

This class is abstract.

Subclasses must implement #chat.

Abstract base class for LLM API client adapters.

Direct Known Subclasses

AnthropicAdapter, OpenAIAdapter

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.

Parameters:



9
10
11
# File 'lib/crimson/client/base.rb', line 9

def initialize(config)
  @config = config
end

Instance Method Details

#chat(messages:, tools: []) {|text_chunk, tool_event| ... } ⇒ Array(Message::Assistant, Hash, nil)

Send a chat request and return the assistant response.

Parameters:

  • messages (Array<Message::Base>)

    conversation messages

  • tools (Array<Hash>) (defaults to: [])

    tool definitions

Yields:

  • (text_chunk, tool_event)

    optional streaming callback

Yield Parameters:

  • text_chunk (String, nil)

    incremental text delta

  • tool_event (Hash, nil)

    partial tool call data

Returns:

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/crimson/client/base.rb', line 20

def chat(messages:, tools: [], &stream_callback)
  raise NotImplementedError, "#{self.class}#chat must be implemented"
end