Class: Copilot::ToolResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/copilot/types.rb

Overview

The result of a tool invocation. Can be constructed directly or returned as a plain Hash / String from a handler.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#binary_results_for_llmObject

Returns the value of attribute binary_results_for_llm

Returns:

  • (Object)

    the current value of binary_results_for_llm



39
40
41
# File 'lib/copilot/types.rb', line 39

def binary_results_for_llm
  @binary_results_for_llm
end

#errorObject

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



39
40
41
# File 'lib/copilot/types.rb', line 39

def error
  @error
end

#result_typeObject

Returns the value of attribute result_type

Returns:

  • (Object)

    the current value of result_type



39
40
41
# File 'lib/copilot/types.rb', line 39

def result_type
  @result_type
end

#session_logObject

Returns the value of attribute session_log

Returns:

  • (Object)

    the current value of session_log



39
40
41
# File 'lib/copilot/types.rb', line 39

def session_log
  @session_log
end

#text_result_for_llmObject

Returns the value of attribute text_result_for_llm

Returns:

  • (Object)

    the current value of text_result_for_llm



39
40
41
# File 'lib/copilot/types.rb', line 39

def text_result_for_llm
  @text_result_for_llm
end

#tool_telemetryObject

Returns the value of attribute tool_telemetry

Returns:

  • (Object)

    the current value of tool_telemetry



39
40
41
# File 'lib/copilot/types.rb', line 39

def tool_telemetry
  @tool_telemetry
end

Instance Method Details

#to_hObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/copilot/types.rb', line 44

def to_h
  h = {
    textResultForLlm: text_result_for_llm,
    resultType: result_type || ToolResultType::SUCCESS,
  }
  h[:binaryResultsForLlm] = binary_results_for_llm.map(&:to_h) if binary_results_for_llm
  h[:error] = error if error
  h[:sessionLog] = session_log if session_log
  h[:toolTelemetry] = tool_telemetry || {}
  h
end