Module: LLM::Gemini::ResponseParser
- Defined in:
- lib/llm/providers/gemini/response_parser.rb
Instance Method Summary collapse
Instance Method Details
#parse_completion(body) ⇒ Hash
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/llm/providers/gemini/response_parser.rb', line 16 def parse_completion(body) { model: body["modelVersion"], choices: body["candidates"].map do LLM::Message.new( _1.dig("content", "role"), _1.dig("content", "parts", 0, "text"), {completion: self} ) end, prompt_tokens: body.dig("usageMetadata", "promptTokenCount"), completion_tokens: body.dig("usageMetadata", "candidatesTokenCount") } end |
#parse_embedding(body) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/llm/providers/gemini/response_parser.rb', line 5 def (body) { model: "text-embedding-004", embeddings: body.dig("embedding", "values") } end |