Class: Rubino::LLM::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/llm/request.rb

Overview

The single value object the conversation loop hands the LLM boundary on each model call. Pure data — it carries everything a provider needs to issue one request, so the loop never threads positional args through the adapter. Mirrors the reference per-call request shape feeding the normalize_response seam: build a request, call the boundary, read back a normalized response.

Fields:

messages    : [{role:, content:, tool_calls?, tool_call_id?}] — api copy
tools       : [tool schema] — may be [] (e.g. max-iter toolless summary)
temperature : Float | nil — nil ⇒ provider default; forced to 1 w/ thinking
max_tokens  : Integer | nil — bumped on thinking + truncation continuation
thinking    : {enabled:, effort:|budget:} | nil — rendered to wire later
prefill     : String | nil — assistant-turn seed for prefill-to-continue
image_paths : [path] — native attachments, first call of a turn only
stream      : Bool — loop decides (interactive turn ⇒ false)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(messages:, tools: nil, temperature: nil, max_tokens: nil, thinking: nil, prefill: nil, image_paths: nil, stream: false) ⇒ Request

Returns a new instance of Request.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rubino/llm/request.rb', line 25

def initialize(messages:, tools: nil, temperature: nil, max_tokens: nil,
               thinking: nil, prefill: nil, image_paths: nil, stream: false)
  @messages    = messages || []
  @tools       = tools || []
  @temperature = temperature
  @max_tokens  = max_tokens
  @thinking    = thinking
  @prefill     = prefill
  @image_paths = image_paths || []
  @stream      = stream ? true : false
end

Instance Attribute Details

#image_pathsObject (readonly)

Returns the value of attribute image_paths.



22
23
24
# File 'lib/rubino/llm/request.rb', line 22

def image_paths
  @image_paths
end

#max_tokensObject (readonly)

Returns the value of attribute max_tokens.



22
23
24
# File 'lib/rubino/llm/request.rb', line 22

def max_tokens
  @max_tokens
end

#messagesObject (readonly)

Returns the value of attribute messages.



22
23
24
# File 'lib/rubino/llm/request.rb', line 22

def messages
  @messages
end

#prefillObject (readonly)

Returns the value of attribute prefill.



22
23
24
# File 'lib/rubino/llm/request.rb', line 22

def prefill
  @prefill
end

#streamObject (readonly)

Returns the value of attribute stream.



22
23
24
# File 'lib/rubino/llm/request.rb', line 22

def stream
  @stream
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



22
23
24
# File 'lib/rubino/llm/request.rb', line 22

def temperature
  @temperature
end

#thinkingObject (readonly)

Returns the value of attribute thinking.



22
23
24
# File 'lib/rubino/llm/request.rb', line 22

def thinking
  @thinking
end

#toolsObject (readonly)

Returns the value of attribute tools.



22
23
24
# File 'lib/rubino/llm/request.rb', line 22

def tools
  @tools
end

Instance Method Details

#stream?Boolean

True when the loop asked the boundary to stream this call.

Returns:

  • (Boolean)


38
39
40
# File 'lib/rubino/llm/request.rb', line 38

def stream?
  @stream
end

#to_hObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rubino/llm/request.rb', line 42

def to_h
  {
    messages: @messages,
    tools: @tools,
    temperature: @temperature,
    max_tokens: @max_tokens,
    thinking: @thinking,
    prefill: @prefill,
    image_paths: @image_paths,
    stream: @stream
  }
end