Class: RubyLLM::Chat
- Inherits:
-
Object
- Object
- RubyLLM::Chat
- Includes:
- ConcurrentToolExecution, MultiSubscriberCallbacks
- Defined in:
- lib/swarm_sdk/ruby_llm_patches/responses_api_patch.rb,
lib/swarm_sdk/ruby_llm_patches/chat_callbacks_patch.rb,
lib/swarm_sdk/ruby_llm_patches/tool_concurrency_patch.rb,
lib/swarm_sdk/ruby_llm_patches/message_management_patch.rb
Defined Under Namespace
Modules: ConcurrentToolExecution, MultiSubscriberCallbacks Classes: Subscription
Instance Attribute Summary collapse
-
#max_concurrency ⇒ Object
readonly
Returns the value of attribute max_concurrency.
-
#responses_session ⇒ ResponsesSession?
readonly
Get the current Responses API session.
-
#tool_concurrency ⇒ Object
readonly
Returns the value of attribute tool_concurrency.
Instance Method Summary collapse
-
#reset_messages!(preserve_system_prompt: true) ⇒ self
Override reset_messages! to support preserve_system_prompt option.
-
#responses_api_enabled? ⇒ Boolean
Check if Responses API is enabled.
-
#restore_responses_session(session_hash) ⇒ self
Restore a Responses API session from saved state.
-
#with_responses_api(stateful: false, store: true, truncation: :disabled, include: []) ⇒ self
Enable OpenAI Responses API for this chat.
Methods included from MultiSubscriberCallbacks
#after_tool_calls, #around_llm_request, #around_tool_execution, #callback_count, #clear_callbacks, #complete, #initialize, #on_end_message, #on_new_message, #on_tool_call, #on_tool_result, #once, #subscribe
Methods included from ConcurrentToolExecution
#initialize, #with_tool_concurrency
Instance Attribute Details
#max_concurrency ⇒ Object (readonly)
Returns the value of attribute max_concurrency.
133 134 135 |
# File 'lib/swarm_sdk/ruby_llm_patches/tool_concurrency_patch.rb', line 133 def max_concurrency @max_concurrency end |
#responses_session ⇒ ResponsesSession? (readonly)
Get the current Responses API session
597 598 599 |
# File 'lib/swarm_sdk/ruby_llm_patches/responses_api_patch.rb', line 597 def responses_session @responses_session end |
#tool_concurrency ⇒ Object (readonly)
Returns the value of attribute tool_concurrency.
133 134 135 |
# File 'lib/swarm_sdk/ruby_llm_patches/tool_concurrency_patch.rb', line 133 def tool_concurrency @tool_concurrency end |
Instance Method Details
#reset_messages!(preserve_system_prompt: true) ⇒ self
Override reset_messages! to support preserve_system_prompt option
14 15 16 17 18 19 20 21 |
# File 'lib/swarm_sdk/ruby_llm_patches/message_management_patch.rb', line 14 def (preserve_system_prompt: true) if preserve_system_prompt @messages.select! { |m| m.role == :system } else @messages.clear end self end |
#responses_api_enabled? ⇒ Boolean
Check if Responses API is enabled
590 591 592 |
# File 'lib/swarm_sdk/ruby_llm_patches/responses_api_patch.rb', line 590 def responses_api_enabled? @responses_api_enabled == true end |
#restore_responses_session(session_hash) ⇒ self
Restore a Responses API session from saved state
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/swarm_sdk/ruby_llm_patches/responses_api_patch.rb', line 571 def restore_responses_session(session_hash) @responses_session = ResponsesSession.from_h(session_hash) if @provider.is_a?(Providers::OpenAIResponses) # Re-create provider with restored session @provider = Providers::OpenAIResponses.new( @config, @responses_session, @provider.responses_config, ) @connection = @provider.connection end self end |
#with_responses_api(stateful: false, store: true, truncation: :disabled, include: []) ⇒ self
Enable OpenAI Responses API for this chat
552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/swarm_sdk/ruby_llm_patches/responses_api_patch.rb', line 552 def with_responses_api(stateful: false, store: true, truncation: :disabled, include: []) responses_config = { stateful: stateful, store: store, truncation: truncation, include: include, } @responses_session ||= ResponsesSession.new @provider = Providers::OpenAIResponses.new(@config, @responses_session, responses_config) @connection = @provider.connection @responses_api_enabled = true self end |