Module: Legion::LLM::API::Translators::AnthropicRequest
- Extended by:
- Legion::Logging::Helper
- Defined in:
- lib/legion/llm/api/translators/anthropic_request.rb
Class Method Summary collapse
-
.normalize(body) ⇒ Object
Normalize Anthropic Messages API request into internal format.
Class Method Details
.normalize(body) ⇒ Object
Normalize Anthropic Messages API request into internal format.
Key differences from OpenAI:
- system is a top-level param, not a messages entry
- tools use input_schema not parameters
- max_tokens is required per Anthropic spec
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/legion/llm/api/translators/anthropic_request.rb', line 18 def self.normalize(body) log.debug('[llm][translator][anthropic_request] action=normalize') = (body) system = extract_system(body) tools = extract_tools(body) routing = extract_routing(body) result = { messages: , tools: tools, routing: routing, stream: body[:stream] == true, max_tokens: body[:max_tokens], metadata: { anthropic_version: body[:anthropic_version] } } result[:system] = system if system result.compact end |