Class: Assistant::ChatService::Result

Inherits:
Data
  • Object
show all
Defined in:
app/services/assistant/chat_service.rb

Overview

Result object containing response and usage stats (immutable)
Includes model_reason for auto-selection and thinking_text for extended reasoning traces

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content: nil, model: nil, input_tokens: nil, output_tokens: nil, cached_tokens: nil, cache_creation_tokens: nil, response_time: nil, model_reason: nil, thinking_text: nil, tool_limit_reached: false, tool_stats: {}) ⇒ void

Builds a Result with optional defaults.

Parameters:

  • content (String, nil) (defaults to: nil)

    assembled response text

  • model (String, nil) (defaults to: nil)

    model key that produced the response

  • input_tokens (Integer, nil) (defaults to: nil)

    number of input tokens consumed

  • output_tokens (Integer, nil) (defaults to: nil)

    number of output tokens generated

  • cached_tokens (Integer, nil) (defaults to: nil)

    tokens read from cache

  • cache_creation_tokens (Integer, nil) (defaults to: nil)

    tokens written to cache

  • response_time (Float, nil) (defaults to: nil)

    wall-clock time for the turn in seconds

  • model_reason (String, nil) (defaults to: nil)

    explanation of why this model was chosen

  • thinking_text (String, nil) (defaults to: nil)

    extended-reasoning trace text, if any

  • tool_limit_reached (Boolean) (defaults to: false)

    true when the tool-loop guard hit a limit

  • tool_stats (Hash) (defaults to: {})

    per-tool call statistics



653
# File 'app/services/assistant/chat_service.rb', line 653

def initialize(content: nil, model: nil, input_tokens: nil, output_tokens: nil, cached_tokens: nil, cache_creation_tokens: nil, response_time: nil, model_reason: nil, thinking_text: nil, tool_limit_reached: false, tool_stats: {}) = super

Instance Attribute Details

#cache_creation_tokensObject (readonly)

Returns the value of attribute cache_creation_tokens

Returns:

  • (Object)

    the current value of cache_creation_tokens



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def cache_creation_tokens
  @cache_creation_tokens
end

#cached_tokensObject (readonly)

Returns the value of attribute cached_tokens

Returns:

  • (Object)

    the current value of cached_tokens



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def cached_tokens
  @cached_tokens
end

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def content
  @content
end

#input_tokensObject (readonly)

Returns the value of attribute input_tokens

Returns:

  • (Object)

    the current value of input_tokens



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def input_tokens
  @input_tokens
end

#modelObject (readonly)

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def model
  @model
end

#model_reasonObject (readonly)

Returns the value of attribute model_reason

Returns:

  • (Object)

    the current value of model_reason



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def model_reason
  @model_reason
end

#output_tokensObject (readonly)

Returns the value of attribute output_tokens

Returns:

  • (Object)

    the current value of output_tokens



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def output_tokens
  @output_tokens
end

#response_timeObject (readonly)

Returns the value of attribute response_time

Returns:

  • (Object)

    the current value of response_time



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def response_time
  @response_time
end

#thinking_textObject (readonly)

Returns the value of attribute thinking_text

Returns:

  • (Object)

    the current value of thinking_text



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def thinking_text
  @thinking_text
end

#tool_limit_reachedObject (readonly)

Returns the value of attribute tool_limit_reached

Returns:

  • (Object)

    the current value of tool_limit_reached



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def tool_limit_reached
  @tool_limit_reached
end

#tool_statsObject (readonly)

Returns the value of attribute tool_stats

Returns:

  • (Object)

    the current value of tool_stats



626
627
628
# File 'app/services/assistant/chat_service.rb', line 626

def tool_stats
  @tool_stats
end