Skip to content

Commit c331aa2

Browse files
committed
feat: New features in VR4 and assistant2
feat: New features in VR4 and assistant2
1 parent c5d33e3 commit c331aa2

File tree

4 files changed

+124
-16
lines changed

4 files changed

+124
-16
lines changed

lib/ibm_watson/assistant_v2.rb

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
211268
end

lib/ibm_watson/discovery_v2.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,9 @@ def add_document(project_id:, collection_id:, file: nil, filename: nil, file_con
467467
# **Note:** This operation only works on collections created to accept direct file
468468
# uploads. It cannot be used to modify a collection that connects to an external
469469
# source such as Microsoft SharePoint.
470+
#
471+
# **Note:** If an uploaded document is segmented, all segments will be overwritten,
472+
# even if the updated version of the document has fewer segments.
470473
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
471474
# Discovery administrative tooling.
472475
# @param collection_id [String] The ID of the collection.
@@ -537,6 +540,9 @@ def update_document(project_id:, collection_id:, document_id:, file: nil, filena
537540
# **Note:** This operation only works on collections created to accept direct file
538541
# uploads. It cannot be used to modify a collection that connects to an external
539542
# source such as Microsoft SharePoint.
543+
#
544+
# **Note:** Segments of an uploaded document cannot be deleted individually. Delete
545+
# all segments by deleting using the `parent_document_id` of a segment result.
540546
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
541547
# Discovery administrative tooling.
542548
# @param collection_id [String] The ID of the collection.

lib/ibm_watson/text_to_speech_v1.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
# both, for each language. The audio is streamed back to the client with minimal delay.
2121
#
2222
# For speech synthesis, the service supports a synchronous HTTP Representational State
23-
# Transfer (REST) interface. It also supports a WebSocket interface that provides both
24-
# plain text and SSML input, including the SSML <mark> element and word timings.
25-
# SSML is an XML-based markup language that provides text annotation for speech-synthesis
26-
# applications.
23+
# Transfer (REST) interface and a WebSocket interface. Both interfaces support plain text
24+
# and SSML input. SSML is an XML-based markup language that provides text annotation for
25+
# speech-synthesis applications. The WebSocket interface also supports the SSML
26+
# <code>&lt;mark&gt;</code> element and word timings.
2727
#
28-
# The service also offers a customization interface. You can use the interface to define
29-
# sounds-like or phonetic translations for words. A sounds-like translation consists of
30-
# one or more words that, when combined, sound like the word. A phonetic translation is
31-
# based on the SSML phoneme format for representing a word. You can specify a phonetic
32-
# translation in standard International Phonetic Alphabet (IPA) representation or in the
33-
# proprietary IBM Symbolic Phonetic Representation (SPR). The Arabic, Chinese, Dutch, and
34-
# Korean languages support only IPA.
28+
# The service offers a customization interface that you can use to define sounds-like or
29+
# phonetic translations for words. A sounds-like translation consists of one or more words
30+
# that, when combined, sound like the word. A phonetic translation is based on the SSML
31+
# phoneme format for representing a word. You can specify a phonetic translation in
32+
# standard International Phonetic Alphabet (IPA) representation or in the proprietary IBM
33+
# Symbolic Phonetic Representation (SPR). The Arabic, Chinese, Dutch, and Korean languages
34+
# support only IPA.
3535

3636
require "concurrent"
3737
require "erb"

lib/ibm_watson/visual_recognition_v4.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,51 @@ def delete_collection(collection_id:)
325325
)
326326
nil
327327
end
328+
329+
##
330+
# @!method get_model_file(collection_id:, feature:, model_format:)
331+
# Get a model.
332+
# Download a model that you can deploy to detect objects in images. The collection
333+
# must include a generated model, which is indicated in the response for the
334+
# collection details as `"rscnn_ready": true`. If the value is `false`, train or
335+
# retrain the collection to generate the model.
336+
#
337+
# Currently, the model format is specific to Android apps. For more information
338+
# about how to deploy the model to your app, see the [Watson Visual Recognition on
339+
# Android](https://github.com/matt-ny/rscnn) project in GitHub.
340+
# @param collection_id [String] The identifier of the collection.
341+
# @param feature [String] The feature for the model.
342+
# @param model_format [String] The format of the returned model.
343+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
344+
def get_model_file(collection_id:, feature:, model_format:)
345+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
346+
347+
raise ArgumentError.new("feature must be provided") if feature.nil?
348+
349+
raise ArgumentError.new("model_format must be provided") if model_format.nil?
350+
351+
headers = {
352+
}
353+
sdk_headers = Common.new.get_sdk_headers("watson_vision_combined", "V4", "get_model_file")
354+
headers.merge!(sdk_headers)
355+
356+
params = {
357+
"version" => @version,
358+
"feature" => feature,
359+
"model_format" => model_format
360+
}
361+
362+
method_url = "/v4/collections/%s/model" % [ERB::Util.url_encode(collection_id)]
363+
364+
response = request(
365+
method: "GET",
366+
url: method_url,
367+
headers: headers,
368+
params: params,
369+
accept_json: false
370+
)
371+
response
372+
end
328373
#########################
329374
# Images
330375
#########################

0 commit comments

Comments
 (0)