Module: RubyLLM::Providers::OpenAIResponses::State
- Defined in:
- lib/ruby_llm/providers/openai_responses/state.rb
Overview
Statefulness support for the OpenAI Responses API. Handles conversation state via previous_response_id and store options.
Class Method Summary collapse
-
.apply_state_params(payload, params) ⇒ Hash
Add state parameters to payload.
-
.continuation_params(previous_response_id, store: true) ⇒ Hash
Build parameters for continuing a conversation.
-
.extract_response_id(response) ⇒ String?
Extract response ID from a completed response for chaining.
-
.response_stored?(response) ⇒ Boolean
Check if a response was stored.
Class Method Details
.apply_state_params(payload, params) ⇒ Hash
Add state parameters to payload
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_llm/providers/openai_responses/state.rb', line 15 def apply_state_params(payload, params) # Handle previous_response_id for conversation chaining payload[:previous_response_id] = params[:previous_response_id] if params[:previous_response_id] # Handle store option (defaults to true in Responses API) payload[:store] = params[:store] if params.key?(:store) # Handle metadata payload[:metadata] = params[:metadata] if params[:metadata] payload end |
.continuation_params(previous_response_id, store: true) ⇒ Hash
Build parameters for continuing a conversation
47 48 49 50 51 52 |
# File 'lib/ruby_llm/providers/openai_responses/state.rb', line 47 def continuation_params(previous_response_id, store: true) { previous_response_id: previous_response_id, store: store } end |
.extract_response_id(response) ⇒ String?
Extract response ID from a completed response for chaining
31 32 33 |
# File 'lib/ruby_llm/providers/openai_responses/state.rb', line 31 def extract_response_id(response) response['id'] end |
.response_stored?(response) ⇒ Boolean
Check if a response was stored
38 39 40 41 |
# File 'lib/ruby_llm/providers/openai_responses/state.rb', line 38 def response_stored?(response) # Responses are stored by default unless store: false was set response['store'] != false end |