Class: Kward::Transport::Host::PluginChat
- Inherits:
-
Object
- Object
- Kward::Transport::Host::PluginChat
- Defined in:
- lib/kward/transport/host.rb
Overview
Narrow plugin-chat operations exposed to a transport.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope_key ⇒ Object
readonly
Returns the value of attribute scope_key.
-
#type_id ⇒ Object
readonly
Returns the value of attribute type_id.
Instance Method Summary collapse
-
#initialize(host, handle, actor) ⇒ PluginChat
constructor
A new instance of PluginChat.
- #start_turn(input, attachments: [], options: {}, streaming_behavior: nil) ⇒ Object
- #transcript ⇒ Object
Constructor Details
#initialize(host, handle, actor) ⇒ PluginChat
Returns a new instance of PluginChat.
211 212 213 214 215 216 217 218 |
# File 'lib/kward/transport/host.rb', line 211 def initialize(host, handle, actor) @host = host @actor = actor @id = handle.id.to_s.freeze @type_id = handle.type_id.to_s.freeze @scope_key = handle.scope_key.to_s.freeze @name = handle.name&.to_s&.freeze end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
209 210 211 |
# File 'lib/kward/transport/host.rb', line 209 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
209 210 211 |
# File 'lib/kward/transport/host.rb', line 209 def name @name end |
#scope_key ⇒ Object (readonly)
Returns the value of attribute scope_key.
209 210 211 |
# File 'lib/kward/transport/host.rb', line 209 def scope_key @scope_key end |
#type_id ⇒ Object (readonly)
Returns the value of attribute type_id.
209 210 211 |
# File 'lib/kward/transport/host.rb', line 209 def type_id @type_id end |
Instance Method Details
#start_turn(input, attachments: [], options: {}, streaming_behavior: nil) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/kward/transport/host.rb', line 220 def start_turn(input, attachments: [], options: {}, streaming_behavior: nil) @host.(:start_plugin_chat_turn, actor: @actor, chat_id: @id, type_id: @type_id, input: input.to_s) if @host.execution_profile && !@host.execution_profile. && !Array().empty? raise PolicyDenied, "Transport execution profile does not allow attachments" end unless .nil? || .empty? raise ArgumentError, "plugin chat turns do not support options" end unless streaming_behavior.nil? || %i[aggregate none].include?(streaming_behavior.to_sym) raise ArgumentError, "plugin chat turns do not support #{streaming_behavior} streaming" end result = @host.plugin_chat_gateway.start_transport_plugin_chat_turn( chat_id: @id, actor: @actor, input: input, attachments: , streaming_behavior: streaming_behavior, execution_profile: @host.execution_profile ) handle = result.is_a?(PluginChatTurnHandle) ? result : PluginChatTurnHandle.new(**result.transform_keys(&:to_sym)) PluginChatTurn.new(@host, handle, @actor) end |
#transcript ⇒ Object
244 245 246 247 |
# File 'lib/kward/transport/host.rb', line 244 def transcript @host.(:read_plugin_chat_transcript, actor: @actor, chat_id: @id, type_id: @type_id) @host.plugin_chat_gateway.transport_plugin_chat_transcript(chat_id: @id) end |