Class: Rasti::AI::Anthropic::Client

Inherits:
Client
  • Object
show all
Defined in:
lib/rasti/ai/anthropic/client.rb

Constant Summary collapse

ANTHROPIC_VERSION =
'2023-06-01'.freeze
DEFAULT_MAX_TOKENS =
4096

Constants inherited from Client

Client::RETRYABLE_STATUS_CODES

Instance Method Summary collapse

Methods inherited from Client

#initialize

Constructor Details

This class inherits a constructor from Rasti::AI::Client

Instance Method Details

#messages(messages:, model: nil, system: nil, tools: [], tool_choice: nil, max_tokens: nil, thinking: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rasti/ai/anthropic/client.rb', line 9

def messages(messages:, model:nil, system:nil, tools:[], tool_choice:nil, max_tokens:nil, thinking:nil)
  body = {
    model:      model || Rasti::AI.anthropic_default_model,
    max_tokens: max_tokens || DEFAULT_MAX_TOKENS,
    messages:   messages
  }

  body[:thinking]    = thinking    if thinking
  body[:system]      = system      if system
  body[:tools]       = tools       unless tools.empty?
  body[:tool_choice] = tool_choice if tool_choice

  post '/messages', body
end