Class: Rixie::LLM::Response

Inherits:
Data
  • Object
show all
Defined in:
lib/rixie/llm/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



5
6
7
# File 'lib/rixie/llm/response.rb', line 5

def content
  @content
end

#finish_reasonObject (readonly)

Returns the value of attribute finish_reason

Returns:

  • (Object)

    the current value of finish_reason



5
6
7
# File 'lib/rixie/llm/response.rb', line 5

def finish_reason
  @finish_reason
end

#tool_callsObject (readonly)

Returns the value of attribute tool_calls

Returns:

  • (Object)

    the current value of tool_calls



5
6
7
# File 'lib/rixie/llm/response.rb', line 5

def tool_calls
  @tool_calls
end

Class Method Details

.from_openai_wire(raw) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/rixie/llm/response.rb', line 6

def self.from_openai_wire(raw)
  choices = raw["choices"] || []
  choice = choices.first || {}
  message = choice["message"] || {}
  tool_calls = (message["tool_calls"] || []).map { |tc| LLM::ToolCall.from_openai_wire(tc) }
  new(content: message["content"], tool_calls: tool_calls, finish_reason: choice["finish_reason"])
end

Instance Method Details

#has_tool_calls?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rixie/llm/response.rb', line 14

def has_tool_calls?
  tool_calls.any?
end