Class: OmniAgent::Streaming::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/omni_agent/streaming/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/omni_agent/streaming/event.rb', line 4

def content
  @content
end

#errorObject (readonly)

Returns the value of attribute error.



4
5
6
# File 'lib/omni_agent/streaming/event.rb', line 4

def error
  @error
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/omni_agent/streaming/event.rb', line 4

def response
  @response
end

#textObject (readonly)

Returns the value of attribute text.



4
5
6
# File 'lib/omni_agent/streaming/event.rb', line 4

def text
  @text
end

#tool_argumentsObject (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_idObject (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_nameObject (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

#typeObject (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

Returns:

  • (Boolean)


45
46
47
# File 'lib/omni_agent/streaming/event.rb', line 45

def done?
  type == :done
end

#error?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/omni_agent/streaming/event.rb', line 49

def error?
  @error == true
end

#text?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/omni_agent/streaming/event.rb', line 33

def text?
  type == :text
end

#tool_call?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/omni_agent/streaming/event.rb', line 37

def tool_call?
  type == :tool_call
end

#tool_result?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/omni_agent/streaming/event.rb', line 41

def tool_result?
  type == :tool_result
end