Class: Google::ADK::Event
- Inherits:
-
Object
- Object
- Google::ADK::Event
- Defined in:
- lib/google/adk/events.rb
Overview
Represents an event in agent-user conversation
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#function_calls ⇒ Object
readonly
Returns the value of attribute function_calls.
-
#function_responses ⇒ Object
readonly
Returns the value of attribute function_responses.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#invocation_id ⇒ Object
readonly
Returns the value of attribute invocation_id.
-
#long_running_tool_ids ⇒ Object
readonly
Returns the value of attribute long_running_tool_ids.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
-
.new_id ⇒ String
Generate a new event ID.
Instance Method Summary collapse
-
#initialize(invocation_id:, author:, id: nil, timestamp: nil, content: nil, function_calls: [], function_responses: [], long_running_tool_ids: nil, branch: nil, actions: nil) ⇒ Event
constructor
Initialize an event.
-
#is_final_response? ⇒ Boolean
Check if this is a final response.
-
#to_h ⇒ Hash
Convert to hash representation.
Constructor Details
#initialize(invocation_id:, author:, id: nil, timestamp: nil, content: nil, function_calls: [], function_responses: [], long_running_tool_ids: nil, branch: nil, actions: nil) ⇒ Event
Initialize an event
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/google/adk/events.rb', line 139 def initialize(invocation_id:, author:, id: nil, timestamp: nil, content: nil, function_calls: [], function_responses: [], long_running_tool_ids: nil, branch: nil, actions: nil) @id = id || self.class.new_id @invocation_id = invocation_id = = || Time.now @content = content @function_calls = function_calls @function_responses = function_responses @long_running_tool_ids = long_running_tool_ids || Set.new @branch = branch @actions = actions end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def actions @actions end |
#author ⇒ Object (readonly)
Returns the value of attribute author.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def end |
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def branch @branch end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def content @content end |
#function_calls ⇒ Object (readonly)
Returns the value of attribute function_calls.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def function_calls @function_calls end |
#function_responses ⇒ Object (readonly)
Returns the value of attribute function_responses.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def function_responses @function_responses end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def id @id end |
#invocation_id ⇒ Object (readonly)
Returns the value of attribute invocation_id.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def invocation_id @invocation_id end |
#long_running_tool_ids ⇒ Object (readonly)
Returns the value of attribute long_running_tool_ids.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def long_running_tool_ids @long_running_tool_ids end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
123 124 125 |
# File 'lib/google/adk/events.rb', line 123 def end |
Class Method Details
.new_id ⇒ String
Generate a new event ID
167 168 169 |
# File 'lib/google/adk/events.rb', line 167 def self.new_id SecureRandom.uuid end |
Instance Method Details
#is_final_response? ⇒ Boolean
Check if this is a final response
157 158 159 160 161 162 |
# File 'lib/google/adk/events.rb', line 157 def is_final_response? return true if == "user" return true if @actions.nil? @actions.transfer_to_agent.nil? end |
#to_h ⇒ Hash
Convert to hash representation
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/google/adk/events.rb', line 174 def to_h result = { id: @id, invocation_id: @invocation_id, author: , timestamp: .iso8601, content: @content, function_calls: @function_calls.map(&:to_h), function_responses: @function_responses.map(&:to_h), long_running_tool_ids: @long_running_tool_ids.to_a } result[:branch] = @branch unless @branch.nil? result[:actions] = @actions.to_h if @actions result end |