Class: SkillBench::Clients::Providers::Anthropic
- Inherits:
-
BaseClient
- Object
- BaseClient
- SkillBench::Clients::Providers::Anthropic
- Defined in:
- lib/skill_bench/clients/providers/anthropic.rb
Overview
Anthropic Claude-specific LLM client. Uses the Messages API endpoint with Claude models.
Constant Summary collapse
- VERSION =
'2023-06-01'
Instance Attribute Summary
Attributes inherited from BaseClient
#api_key, #messages, #model, #options, #system_prompt, #tools
Class Method Summary collapse
-
.translate_assistant_message(msg) ⇒ Hash
Translates assistant message with tool calls to Anthropic format.
-
.translate_tool_message(msg) ⇒ Hash
Translates tool result message to Anthropic format.
-
.translate_tools(tools) ⇒ Array<Hash>
Translates standard tool definitions to Anthropic tool format.
Instance Method Summary collapse
-
#provider_name ⇒ Symbol
Returns the provider identifier.
Methods inherited from BaseClient
Constructor Details
This class inherits a constructor from SkillBench::Clients::BaseClient
Class Method Details
.translate_assistant_message(msg) ⇒ Hash
Translates assistant message with tool calls to Anthropic format.
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/skill_bench/clients/providers/anthropic.rb', line 166 def (msg) content = [] text = msg[:content] || msg['content'] content << { type: 'text', text: text } if text && !text.empty? (msg[:tool_calls] || msg['tool_calls'])&.each do |tool_call| content << build_tool_use_block(tool_call) end { role: 'assistant', content: content } end |
.translate_tool_message(msg) ⇒ Hash
Translates tool result message to Anthropic format.
182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/skill_bench/clients/providers/anthropic.rb', line 182 def (msg) { role: 'user', content: [ { type: 'tool_result', tool_use_id: msg[:tool_call_id] || msg['tool_call_id'], content: msg[:content] || msg['content'] } ] } end |
.translate_tools(tools) ⇒ Array<Hash>
Translates standard tool definitions to Anthropic tool format.
152 153 154 155 156 157 158 159 160 |
# File 'lib/skill_bench/clients/providers/anthropic.rb', line 152 def translate_tools(tools) tools.map do |tool| { name: tool.dig(:function, :name) || tool.dig('function', 'name'), description: tool.dig(:function, :description) || tool.dig('function', 'description'), input_schema: tool.dig(:function, :parameters) || tool.dig('function', 'parameters') } end end |
Instance Method Details
#provider_name ⇒ Symbol
Returns the provider identifier.
19 20 21 |
# File 'lib/skill_bench/clients/providers/anthropic.rb', line 19 def provider_name :anthropic end |