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.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/little_ghost/model_request.rb', line 28 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
16 17 18 |
# File 'lib/little_ghost/model_request.rb', line 16 def cancellation_token @cancellation_token end |
#deadline ⇒ Object (readonly)
Returns the value of attribute deadline
16 17 18 |
# File 'lib/little_ghost/model_request.rb', line 16 def deadline @deadline end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages
16 17 18 |
# File 'lib/little_ghost/model_request.rb', line 16 def @messages end |
#output_schema ⇒ Object (readonly)
Returns the value of attribute output_schema
16 17 18 |
# File 'lib/little_ghost/model_request.rb', line 16 def output_schema @output_schema end |
#required_capabilities ⇒ Object (readonly)
Returns the value of attribute required_capabilities
16 17 18 |
# File 'lib/little_ghost/model_request.rb', line 16 def required_capabilities @required_capabilities end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings
16 17 18 |
# File 'lib/little_ghost/model_request.rb', line 16 def settings @settings end |
#tool_choice ⇒ Object (readonly)
Returns the value of attribute tool_choice
16 17 18 |
# File 'lib/little_ghost/model_request.rb', line 16 def tool_choice @tool_choice end |
#tools ⇒ Object (readonly)
Returns the value of attribute tools
16 17 18 |
# File 'lib/little_ghost/model_request.rb', line 16 def tools @tools end |