Module: LLM::OpenAI::Response::Completion
- Defined in:
- lib/llm/providers/openai/response/completion.rb
Instance Method Summary collapse
-
#choices ⇒ Object
(also: #messages)
-
#model ⇒ Object
-
#prompt_tokens ⇒ Object
-
#completion_tokens ⇒ Object
-
#total_tokens ⇒ Object
Instance Method Details
#choices ⇒ Object Also known as: messages
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/llm/providers/openai/response/completion.rb', line 5 def choices body.choices.map.with_index do |choice, index| choice = LLM::Object.from_hash(choice) = choice. extra = { index:, response: self, logprobs: choice.logprobs, tool_calls: format_tool_calls(.tool_calls), original_tool_calls: .tool_calls } LLM::Message.new(.role, .content, extra) end end |
#model ⇒ Object
20 |
# File 'lib/llm/providers/openai/response/completion.rb', line 20 def model = body.model |
#prompt_tokens ⇒ Object
21 |
# File 'lib/llm/providers/openai/response/completion.rb', line 21 def prompt_tokens = body.usage&.prompt_tokens |
#completion_tokens ⇒ Object
22 |
# File 'lib/llm/providers/openai/response/completion.rb', line 22 def completion_tokens = body.usage&.completion_tokens |
#total_tokens ⇒ Object
23 |
# File 'lib/llm/providers/openai/response/completion.rb', line 23 def total_tokens = body.usage&.total_tokens |