Class: I18nAi::Clients::AnthropicClient
- Inherits:
-
BaseClient
- Object
- BaseClient
- I18nAi::Clients::AnthropicClient
- Defined in:
- lib/i18n_ai/clients/anthropic_client.rb
Overview
The AnthropicClient class is responsible for interacting with the Anthropic API
Instance Attribute Summary
Attributes inherited from BaseClient
Instance Method Summary collapse
- #chat(locale, text) ⇒ Object
-
#initialize ⇒ AnthropicClient
constructor
A new instance of AnthropicClient.
Methods inherited from BaseClient
Constructor Details
#initialize ⇒ AnthropicClient
Returns a new instance of AnthropicClient.
10 11 12 13 14 15 |
# File 'lib/i18n_ai/clients/anthropic_client.rb', line 10 def initialize super @client = Anthropic::Client.new( access_token: config[:access_token] ) end |
Instance Method Details
#chat(locale, text) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/i18n_ai/clients/anthropic_client.rb', line 17 def chat(locale, text) response = @client.( parameters: { model: config[:model], messages: [{ role: "user", content: chat_prompt(locale, text) }], max_tokens: 4096 } ) parse_response(response) end |