Class: ActiveGenie::Providers::AnthropicProvider
- Inherits:
-
BaseProvider
- Object
- BaseProvider
- ActiveGenie::Providers::AnthropicProvider
- Defined in:
- lib/active_genie/providers/anthropic_provider.rb
Overview
Provider for interacting with the Anthropic (Claude) API with json response
Constant Summary collapse
- ANTHROPIC_ENDPOINT =
'/v1/messages'
Constants inherited from BaseProvider
BaseProvider::DEFAULT_HEADERS, BaseProvider::DEFAULT_MAX_RETRIES, BaseProvider::DEFAULT_OPEN_TIMEOUT, BaseProvider::DEFAULT_RETRY_DELAY, BaseProvider::DEFAULT_TIMEOUT
Instance Method Summary collapse
-
#function_calling(messages, function) ⇒ Hash?
Requests structured JSON output from the Anthropic Claude model based on a schema.
Methods inherited from BaseProvider
#delete, #get, #initialize, #post, #put
Constructor Details
This class inherits a constructor from ActiveGenie::Providers::BaseProvider
Instance Method Details
#function_calling(messages, function) ⇒ Hash?
Requests structured JSON output from the Anthropic Claude model based on a schema.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_genie/providers/anthropic_provider.rb', line 19 def function_calling(, function) , = () tool = function_to_tool(function) payload = { model:, system: , messages: , tools: [tool], tool_choice: { name: tool[:name], type: 'tool' }, max_tokens: @config.llm.max_tokens, temperature: @config.llm.temperature || 0 } response = retry_with_backoff do request(payload) end response.dig('content', 0, 'input') end |