Module: LLM::Anthropic::ResponseParser
- Defined in:
- lib/llm/providers/anthropic/response_parser.rb
Instance Method Summary collapse
Instance Method Details
#parse_completion(body) ⇒ Hash
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/llm/providers/anthropic/response_parser.rb', line 19 def parse_completion(body) { model: body["model"], choices: body["content"].map do # TODO: don't hardcode role LLM::Message.new("assistant", _1["text"], {response: self}) end, prompt_tokens: body.dig("usage", "input_tokens"), completion_tokens: body.dig("usage", "output_tokens") } end |
#parse_embedding(body) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/llm/providers/anthropic/response_parser.rb', line 7 def (body) { model: body["model"], embeddings: body["data"].map { _1["embedding"] }, total_tokens: body.dig("usage", "total_tokens") } end |