Class: LlmProviders::Providers::Anthropic

Inherits:
Base
  • Object
show all
Defined in:
lib/llm_providers/providers/anthropic.rb

Constant Summary collapse

API_URL =
"https://api.anthropic.com/v1/messages"
API_VERSION =
"2023-06-01"

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LlmProviders::Providers::Base

Instance Method Details

#chat(messages:, system: nil, tools: nil, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/llm_providers/providers/anthropic.rb', line 9

def chat(messages:, system: nil, tools: nil, &block)
  Time.now

  payload = build_payload(messages, system, tools)

  if block_given?
    stream_response(payload, &block)
  else
    sync_response(payload)
  end
end