Class: Regent::LLM::Anthropic
Constant Summary collapse
- MAX_TOKENS =
1000- ENV_KEY =
"ANTHROPIC_API_KEY"
Instance Method Summary collapse
Methods inherited from Base
Methods included from Concerns::Dependable
included, #initialize, #require_dynamic
Constructor Details
This class inherits a constructor from Regent::LLM::Base
Instance Method Details
#invoke(messages, **args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/regent/llm/anthropic.rb', line 11 def invoke(, **args) parameters = { messages: (), model: model, temperature: args[:temperature] || 0.0, stop_sequences: args[:stop] || [], max_tokens: MAX_TOKENS } if system_instruction = system_instruction() parameters[:system] = system_instruction end response = client.(parameters:) result( model: model, content: response.dig("content", 0, "text"), input_tokens: response.dig("usage", "input_tokens"), output_tokens: response.dig("usage", "output_tokens") ) end |