Class: OmniAI::Chat::Response
- Inherits:
-
Object
- Object
- OmniAI::Chat::Response
- Defined in:
- lib/omniai/chat/response.rb
Overview
Used when processing everything at once.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #choice(index: 0) ⇒ Choice
- #choices ⇒ Array<Choice>
- #completion ⇒ Payload
-
#initialize(data:, context: nil) ⇒ Response
constructor
A new instance of Response.
- #message(index: 0) ⇒ Message
- #messages ⇒ Array<Message>
- #text ⇒ String
- #text? ⇒ Boolean
- #tool_call_list ⇒ Array<ToolCall>
- #tool_call_list? ⇒ Boolean
- #usage ⇒ Usage?
Constructor Details
#initialize(data:, context: nil) ⇒ Response
Returns a new instance of Response.
12 13 14 15 |
# File 'lib/omniai/chat/response.rb', line 12 def initialize(data:, context: nil) @data = data @context = context end |
Instance Attribute Details
#data ⇒ Hash
8 9 10 |
# File 'lib/omniai/chat/response.rb', line 8 def data @data end |
Instance Method Details
#choice(index: 0) ⇒ Choice
39 40 41 |
# File 'lib/omniai/chat/response.rb', line 39 def choice(index: 0) completion.choice(index:) end |
#choices ⇒ Array<Choice>
28 29 30 |
# File 'lib/omniai/chat/response.rb', line 28 def choices completion.choices end |
#completion ⇒ Payload
18 19 20 |
# File 'lib/omniai/chat/response.rb', line 18 def completion @completion ||= Payload.deserialize(@data, context: @context) end |
#message(index: 0) ⇒ Message
45 46 47 |
# File 'lib/omniai/chat/response.rb', line 45 def (index: 0) completion.(index:) end |
#messages ⇒ Array<Message>
33 34 35 |
# File 'lib/omniai/chat/response.rb', line 33 def completion. end |
#text ⇒ String
50 51 52 |
# File 'lib/omniai/chat/response.rb', line 50 def text .text end |
#text? ⇒ Boolean
55 56 57 |
# File 'lib/omniai/chat/response.rb', line 55 def text? .text? end |
#tool_call_list ⇒ Array<ToolCall>
60 61 62 |
# File 'lib/omniai/chat/response.rb', line 60 def tool_call_list choice.tool_call_list end |
#tool_call_list? ⇒ Boolean
65 66 67 |
# File 'lib/omniai/chat/response.rb', line 65 def tool_call_list? tool_call_list&.any? end |
#usage ⇒ Usage?
23 24 25 |
# File 'lib/omniai/chat/response.rb', line 23 def usage completion.usage end |