Class: Kward::SessionTabDriver
- Inherits:
-
Object
- Object
- Kward::SessionTabDriver
- Defined in:
- lib/kward/tab_driver.rb
Overview
Adapts a session-backed agent to the tab runtime interface. Plugin tab drivers implement the same small surface without becoming Kward sessions.
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #assistant_label ⇒ Object
- #conversation ⇒ Object
- #descriptor ⇒ Object
-
#initialize(session:, agent:) ⇒ SessionTabDriver
constructor
A new instance of SessionTabDriver.
- #messages ⇒ Object
- #session? ⇒ Boolean
- #submit(input, display_input:, cancellation:, steering: nil, &block) ⇒ Object
- #supports_steering? ⇒ Boolean
Constructor Details
#initialize(session:, agent:) ⇒ SessionTabDriver
Returns a new instance of SessionTabDriver.
8 9 10 11 |
# File 'lib/kward/tab_driver.rb', line 8 def initialize(session:, agent:) @session = session @agent = agent end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
6 7 8 |
# File 'lib/kward/tab_driver.rb', line 6 def agent @agent end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
6 7 8 |
# File 'lib/kward/tab_driver.rb', line 6 def session @session end |
Instance Method Details
#assistant_label ⇒ Object
40 41 42 |
# File 'lib/kward/tab_driver.rb', line 40 def assistant_label nil end |
#conversation ⇒ Object
17 18 19 |
# File 'lib/kward/tab_driver.rb', line 17 def conversation agent.conversation end |
#descriptor ⇒ Object
28 29 30 |
# File 'lib/kward/tab_driver.rb', line 28 def descriptor { "kind" => "session", "session_path" => session.path } end |
#messages ⇒ Object
13 14 15 |
# File 'lib/kward/tab_driver.rb', line 13 def agent.conversation. end |
#session? ⇒ Boolean
32 33 34 |
# File 'lib/kward/tab_driver.rb', line 32 def session? true end |
#submit(input, display_input:, cancellation:, steering: nil, &block) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/kward/tab_driver.rb', line 21 def submit(input, display_input:, cancellation:, steering: nil, &block) = { cancellation: cancellation } [:display_input] = display_input unless display_input.nil? [:steering] = steering if steering agent.ask(input, **, &block) end |
#supports_steering? ⇒ Boolean
36 37 38 |
# File 'lib/kward/tab_driver.rb', line 36 def supports_steering? true end |