Class: Legion::LLM::Types::ToolCall
- Inherits:
-
Data
- Object
- Data
- Legion::LLM::Types::ToolCall
- Defined in:
- lib/legion/llm/types/tool_call.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#duration_ms ⇒ Object
readonly
Returns the value of attribute duration_ms.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#exchange_id ⇒ Object
readonly
Returns the value of attribute exchange_id.
-
#finished_at ⇒ Object
readonly
Returns the value of attribute finished_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #error? ⇒ Boolean
- #success? ⇒ Boolean
- #to_audit_hash ⇒ Object
- #to_h ⇒ Object
- #with_result(result:, status:, duration_ms: nil, finished_at: nil) ⇒ Object
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def arguments @arguments end |
#duration_ms ⇒ Object (readonly)
Returns the value of attribute duration_ms
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def duration_ms @duration_ms end |
#error ⇒ Object (readonly)
Returns the value of attribute error
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def error @error end |
#exchange_id ⇒ Object (readonly)
Returns the value of attribute exchange_id
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def exchange_id @exchange_id end |
#finished_at ⇒ Object (readonly)
Returns the value of attribute finished_at
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def finished_at @finished_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def name @name end |
#result ⇒ Object (readonly)
Returns the value of attribute result
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def result @result end |
#source ⇒ Object (readonly)
Returns the value of attribute source
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def source @source end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def started_at @started_at end |
#status ⇒ Object (readonly)
Returns the value of attribute status
8 9 10 |
# File 'lib/legion/llm/types/tool_call.rb', line 8 def status @status end |
Class Method Details
.build(**kwargs) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/legion/llm/types/tool_call.rb', line 13 def self.build(**kwargs) new( id: kwargs[:id] || "call_#{SecureRandom.hex(12)}", exchange_id: kwargs[:exchange_id], name: kwargs[:name], arguments: kwargs[:arguments] || {}, source: kwargs[:source], status: kwargs[:status], duration_ms: kwargs[:duration_ms], result: kwargs[:result], error: kwargs[:error], started_at: kwargs[:started_at], finished_at: kwargs[:finished_at] ) end |
.from_hash(hash) ⇒ Object
29 30 31 32 |
# File 'lib/legion/llm/types/tool_call.rb', line 29 def self.from_hash(hash) hash = hash.transform_keys(&:to_sym) if hash.respond_to?(:transform_keys) build(**hash) end |
Instance Method Details
#error? ⇒ Boolean
38 39 40 |
# File 'lib/legion/llm/types/tool_call.rb', line 38 def error? status == :error end |
#success? ⇒ Boolean
34 35 36 |
# File 'lib/legion/llm/types/tool_call.rb', line 34 def success? status == :success end |
#to_audit_hash ⇒ Object
62 63 64 65 |
# File 'lib/legion/llm/types/tool_call.rb', line 62 def to_audit_hash { id: id, name: name, arguments: arguments, status: status, duration_ms: duration_ms, error: error, exchange_id: exchange_id }.compact end |
#to_h ⇒ Object
58 59 60 |
# File 'lib/legion/llm/types/tool_call.rb', line 58 def to_h super.compact end |
#with_result(result:, status:, duration_ms: nil, finished_at: nil) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/legion/llm/types/tool_call.rb', line 42 def with_result(result:, status:, duration_ms: nil, finished_at: nil) ToolCall.new( id: id, exchange_id: exchange_id, name: name, arguments: arguments, source: source, status: status, duration_ms: duration_ms, result: result, error: status == :error ? result : error, started_at: started_at, finished_at: finished_at || Time.now ) end |