Class: LLM::Anthropic::ResponseParser::CompletionParser

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/providers/anthropic/response_parser/completion_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ CompletionParser

Returns a new instance of CompletionParser.



7
8
9
# File 'lib/llm/providers/anthropic/response_parser/completion_parser.rb', line 7

def initialize(body)
  @body = OpenStruct.from_hash(body)
end

Instance Method Details

#format(response) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/llm/providers/anthropic/response_parser/completion_parser.rb', line 11

def format(response)
  {
    model:,
    prompt_tokens:,
    completion_tokens:,
    total_tokens:,
    choices: format_choices(response)
  }
end