Class: LittleGhost::ModelRequest
- Inherits:
-
Data
- Object
- Data
- LittleGhost::ModelRequest
- Defined in:
- lib/little_ghost/model_request.rb,
lib/little_ghost/model_request.rb
Overview
Carries everything a provider needs for one model stream. Messages are normalized to Message objects, and required capabilities become unique symbols. The main request containers are frozen, but nested values are not defensively copied.
Treat settings, output schemas, and tool-choice values as immutable after construction. Create a separate copy before using mutable control data in another request or thread.
Instance Attribute Summary collapse
-
#cancellation_token ⇒ Object
readonly
Returns the value of attribute cancellation_token.
-
#deadline ⇒ Object
readonly
Returns the value of attribute deadline.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#output_schema ⇒ Object
readonly
Returns the value of attribute output_schema.
-
#required_capabilities ⇒ Object
readonly
Returns the value of attribute required_capabilities.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#tool_choice ⇒ Object
readonly
Returns the value of attribute tool_choice.
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Instance Method Summary collapse
-
#initialize(messages:, tools: [], settings: {}, output_schema: nil, tool_choice: nil, required_capabilities: [], cancellation_token: Support::CancellationToken.new, deadline: nil) ⇒ ModelRequest
constructor
Creates a model request with optional tools, structured output, tool choice, cancellation, and deadline controls.
Constructor Details
#initialize(messages:, tools: [], settings: {}, output_schema: nil, tool_choice: nil, required_capabilities: [], cancellation_token: Support::CancellationToken.new, deadline: nil) ⇒ ModelRequest
Creates a model request with optional tools, structured output, tool choice, cancellation, and deadline controls.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/little_ghost/model_request.rb', line 16 def initialize( messages:, tools: [], settings: {}, output_schema: nil, tool_choice: nil, required_capabilities: [], cancellation_token: Support::CancellationToken.new, deadline: nil ) super( messages: .map { || Message.coerce() }.freeze, tools: tools.freeze, settings: settings.freeze, output_schema:, tool_choice:, required_capabilities: required_capabilities.map(&:to_sym).uniq.freeze, cancellation_token: cancellation_token, deadline: ) end |
Instance Attribute Details
#cancellation_token ⇒ Object (readonly)
Returns the value of attribute cancellation_token
4 5 6 |
# File 'lib/little_ghost/model_request.rb', line 4 def cancellation_token @cancellation_token end |
#deadline ⇒ Object (readonly)
Returns the value of attribute deadline
4 5 6 |
# File 'lib/little_ghost/model_request.rb', line 4 def deadline @deadline end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages
4 5 6 |
# File 'lib/little_ghost/model_request.rb', line 4 def @messages end |
#output_schema ⇒ Object (readonly)
Returns the value of attribute output_schema
4 5 6 |
# File 'lib/little_ghost/model_request.rb', line 4 def output_schema @output_schema end |
#required_capabilities ⇒ Object (readonly)
Returns the value of attribute required_capabilities
4 5 6 |
# File 'lib/little_ghost/model_request.rb', line 4 def required_capabilities @required_capabilities end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings
4 5 6 |
# File 'lib/little_ghost/model_request.rb', line 4 def settings @settings end |
#tool_choice ⇒ Object (readonly)
Returns the value of attribute tool_choice
4 5 6 |
# File 'lib/little_ghost/model_request.rb', line 4 def tool_choice @tool_choice end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools
4 5 6 |
# File 'lib/little_ghost/model_request.rb', line 4 def tools @tools end |