Class: LLM::Clients::Anthropic
- Inherits:
-
Object
- Object
- LLM::Clients::Anthropic
- Includes:
- HTTParty
- Defined in:
- lib/llm/clients/anthropic.rb,
lib/llm/clients/anthropic/response.rb
Defined Under Namespace
Classes: Response
Instance Method Summary collapse
- #chat(messages, options = {}) ⇒ Object
-
#initialize(llm:) ⇒ Anthropic
constructor
A new instance of Anthropic.
Constructor Details
#initialize(llm:) ⇒ Anthropic
Returns a new instance of Anthropic.
11 12 13 |
# File 'lib/llm/clients/anthropic.rb', line 11 def initialize(llm:) @llm = llm end |
Instance Method Details
#chat(messages, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/llm/clients/anthropic.rb', line 15 def chat(, = {}) request = payload(, ) return chat_streaming(request, [:on_message], [:on_complete]) if [:stream] resp = post_url("/v1/messages", body: request.to_json) Response.new(resp).to_normalized_response end |