Class: OmniAgent::Streaming::Event
- Inherits:
-
Object
- Object
- OmniAgent::Streaming::Event
- Defined in:
- lib/omni_agent/streaming/event.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#tool_arguments ⇒ Object
readonly
Returns the value of attribute tool_arguments.
-
#tool_id ⇒ Object
readonly
Returns the value of attribute tool_id.
-
#tool_name ⇒ Object
readonly
Returns the value of attribute tool_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .done(response) ⇒ Object
- .text(delta) ⇒ Object
- .tool_call(name:, arguments:, id:) ⇒ Object
- .tool_result(name:, id:, content:, error: false) ⇒ Object
Instance Method Summary collapse
- #done? ⇒ Boolean
- #error? ⇒ Boolean
-
#initialize(type:, text: nil, tool_name: nil, tool_arguments: nil, tool_id: nil, content: nil, error: false, response: nil) ⇒ Event
constructor
A new instance of Event.
- #text? ⇒ Boolean
- #tool_call? ⇒ Boolean
- #tool_result? ⇒ Boolean
Constructor Details
#initialize(type:, text: nil, tool_name: nil, tool_arguments: nil, tool_id: nil, content: nil, error: false, response: nil) ⇒ Event
Returns a new instance of Event.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/omni_agent/streaming/event.rb', line 22 def initialize(type:, text: nil, tool_name: nil, tool_arguments: nil, tool_id: nil, content: nil, error: false, response: nil) @type = type @text = text @tool_name = tool_name @tool_arguments = tool_arguments @tool_id = tool_id @content = content @error = error @response = response end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/omni_agent/streaming/event.rb', line 4 def content @content end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'lib/omni_agent/streaming/event.rb', line 4 def error @error end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/omni_agent/streaming/event.rb', line 4 def response @response end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
4 5 6 |
# File 'lib/omni_agent/streaming/event.rb', line 4 def text @text end |
#tool_arguments ⇒ Object (readonly)
Returns the value of attribute tool_arguments.
4 5 6 |
# File 'lib/omni_agent/streaming/event.rb', line 4 def tool_arguments @tool_arguments end |
#tool_id ⇒ Object (readonly)
Returns the value of attribute tool_id.
4 5 6 |
# File 'lib/omni_agent/streaming/event.rb', line 4 def tool_id @tool_id end |
#tool_name ⇒ Object (readonly)
Returns the value of attribute tool_name.
4 5 6 |
# File 'lib/omni_agent/streaming/event.rb', line 4 def tool_name @tool_name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/omni_agent/streaming/event.rb', line 4 def type @type end |
Class Method Details
.done(response) ⇒ Object
18 19 20 |
# File 'lib/omni_agent/streaming/event.rb', line 18 def self.done(response) new(type: :done, response: response) end |
.text(delta) ⇒ Object
6 7 8 |
# File 'lib/omni_agent/streaming/event.rb', line 6 def self.text(delta) new(type: :text, text: delta) end |
.tool_call(name:, arguments:, id:) ⇒ Object
10 11 12 |
# File 'lib/omni_agent/streaming/event.rb', line 10 def self.tool_call(name:, arguments:, id:) new(type: :tool_call, tool_name: name, tool_arguments: arguments, tool_id: id) end |
.tool_result(name:, id:, content:, error: false) ⇒ Object
14 15 16 |
# File 'lib/omni_agent/streaming/event.rb', line 14 def self.tool_result(name:, id:, content:, error: false) new(type: :tool_result, tool_name: name, tool_id: id, content: content, error: error) end |
Instance Method Details
#done? ⇒ Boolean
45 46 47 |
# File 'lib/omni_agent/streaming/event.rb', line 45 def done? type == :done end |
#error? ⇒ Boolean
49 50 51 |
# File 'lib/omni_agent/streaming/event.rb', line 49 def error? @error == true end |
#text? ⇒ Boolean
33 34 35 |
# File 'lib/omni_agent/streaming/event.rb', line 33 def text? type == :text end |
#tool_call? ⇒ Boolean
37 38 39 |
# File 'lib/omni_agent/streaming/event.rb', line 37 def tool_call? type == :tool_call end |
#tool_result? ⇒ Boolean
41 42 43 |
# File 'lib/omni_agent/streaming/event.rb', line 41 def tool_result? type == :tool_result end |