@@ -160,8 +160,10 @@ def delete_session(assistant_id:, session_id:)
160160
161161 ##
162162 # @!method message(assistant_id:, session_id:, input: nil, context: nil)
163- # Send user input to assistant.
164- # Send user input to an assistant and receive a response.
163+ # Send user input to assistant (stateful).
164+ # Send user input to an assistant and receive a response, with conversation state
165+ # (including context data) stored by Watson Assistant for the duration of the
166+ # session.
165167 #
166168 # There is no rate limit for this operation.
167169 # @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
@@ -172,9 +174,12 @@ def delete_session(assistant_id:, session_id:)
172174 # **Note:** Currently, the v2 API does not support creating assistants.
173175 # @param session_id [String] Unique identifier of the session.
174176 # @param input [MessageInput] An input object that includes the input text.
175- # @param context [MessageContext] State information for the conversation. The context is stored by the assistant on
176- # a per-session basis. You can use this property to set or modify context variables,
177- # which can also be accessed by dialog nodes.
177+ # @param context [MessageContext] Context data for the conversation. You can use this property to set or modify
178+ # context variables, which can also be accessed by dialog nodes. The context is
179+ # stored by the assistant on a per-session basis.
180+ #
181+ # **Note:** The total size of the context data stored for a stateful session cannot
182+ # exceed 100KB.
178183 # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
179184 def message ( assistant_id :, session_id :, input : nil , context : nil )
180185 raise ArgumentError . new ( "assistant_id must be provided" ) if assistant_id . nil?
@@ -207,5 +212,57 @@ def message(assistant_id:, session_id:, input: nil, context: nil)
207212 )
208213 response
209214 end
215+
216+ ##
217+ # @!method message_stateless(assistant_id:, input: nil, context: nil)
218+ # Send user input to assistant (stateless).
219+ # Send user input to an assistant and receive a response, with conversation state
220+ # (including context data) managed by your application.
221+ #
222+ # There is no rate limit for this operation.
223+ # @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
224+ # Assistant user interface, open the assistant settings and click **API Details**.
225+ # For information about creating assistants, see the
226+ # [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
227+ #
228+ # **Note:** Currently, the v2 API does not support creating assistants.
229+ # @param input [MessageInputStateless] An input object that includes the input text.
230+ # @param context [MessageContextStateless] Context data for the conversation. You can use this property to set or modify
231+ # context variables, which can also be accessed by dialog nodes. The context is not
232+ # stored by the assistant. To maintain session state, include the context from the
233+ # previous response.
234+ #
235+ # **Note:** The total size of the context data for a stateless session cannot exceed
236+ # 250KB.
237+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
238+ def message_stateless ( assistant_id :, input : nil , context : nil )
239+ raise ArgumentError . new ( "assistant_id must be provided" ) if assistant_id . nil?
240+
241+ headers = {
242+ }
243+ sdk_headers = Common . new . get_sdk_headers ( "conversation" , "V2" , "message_stateless" )
244+ headers . merge! ( sdk_headers )
245+
246+ params = {
247+ "version" => @version
248+ }
249+
250+ data = {
251+ "input" => input ,
252+ "context" => context
253+ }
254+
255+ method_url = "/v2/assistants/%s/message" % [ ERB ::Util . url_encode ( assistant_id ) ]
256+
257+ response = request (
258+ method : "POST" ,
259+ url : method_url ,
260+ headers : headers ,
261+ params : params ,
262+ json : data ,
263+ accept_json : true
264+ )
265+ response
266+ end
210267 end
211268end
0 commit comments