Class: Arcp::Job::EventBody::ToolResult

Inherits:
Data
  • Object
show all
Defined in:
lib/arcp/job/event_body/tool_result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#call_idObject (readonly)

Returns the value of attribute call_id

Returns:

  • (Object)

    the current value of call_id



6
7
8
# File 'lib/arcp/job/event_body/tool_result.rb', line 6

def call_id
  @call_id
end

#errorObject (readonly)

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



6
7
8
# File 'lib/arcp/job/event_body/tool_result.rb', line 6

def error
  @error
end

#resultObject (readonly)

Returns the value of attribute result

Returns:

  • (Object)

    the current value of result



6
7
8
# File 'lib/arcp/job/event_body/tool_result.rb', line 6

def result
  @result
end

Class Method Details

.from_h(h) ⇒ Object



7
8
9
10
# File 'lib/arcp/job/event_body/tool_result.rb', line 7

def self.from_h(h)
  h = h.transform_keys(&:to_s)
  new(call_id: h.fetch('call_id'), result: h['result'], error: h['error'])
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


19
# File 'lib/arcp/job/event_body/tool_result.rb', line 19

def ok? = error.nil?

#to_hObject



12
13
14
15
16
17
# File 'lib/arcp/job/event_body/tool_result.rb', line 12

def to_h
  out = { 'call_id' => call_id }
  out['result'] = result if result
  out['error']  = error if error
  out
end