vania-janet/multiturn-rag-retrieval-data huggingface dataset:
}
},
{
"name": "Owen",
"age": 51,
"gender": "male",
"_id": "d1f61e66-7708-4da6-aa05-7cbc33b44b7e",
"_attachments": {

}
}
]
}
Show more

The return code from a successful bulk insertion is [201](https://cloud.ibm.com/apidocs/cloudantlist-of-http-codes). The content of the returned structure indicates success or other information messages on a per-document basis.

See an example response header after successful bulk insert of three documents:

201 Created
Cache-Control: must-revalidate
Content-Length: 269
Content-Type: application/json
Date: Mon, 04 Mar 2013 14:06:20 GMT
server: CouchDB/1.0.2 (Erlang OTP/R14B)
x-couch-request-id: e8ff64d5

The returned JSON contains a list of the documents that were created, including their revision and ID values.

The content and structure of the returned JSON depends on the transaction semantics that are used for the bulk update. For more information, see [Bulk documents transaction semantics](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-bulk-operationsbulk-documents-transaction-semantics).

Conflicts and validation errors that occur when you update documents in bulk must be handled separately. For more information, see [Bulk document validation and conflict errors](https://cloud.ibm.com/docs/Cloudant?topic=Cloudant-bulk-operationsbulk-document-validation-and-conflict-errors).

See an example response content after successful bulk insert of two documents:

[
{
"ok": true,
"id": "id1",
"rev": "2-402c81fee7ae6e723ff08bb166703a50"
},
{
// Example below (traversing the returned JSONObject)
if (property != null) {
JSONObject result = (JSONObject) property.getCurrentValue(entityId, entityAttributes);
result.get("key") // returns the value of the key
}

Property property = appConfiguration.getProperty("yaml-property");
property.getPropertyDataType(); // STRING
property.getPropertyDataFormat(); // YAML
property.getCurrentValue(entityId, entityAttributes); // returns the stringified yaml (check Table 1)



* Force fetch the configurations from server.

appConfiguration.fetchConfigurations()
...some synchronous code...
} catch(e) {
...log error...
reject(e); // <-- this also terminates the execution, but reports the failure back to the runtime
}
});
}

async function main() {
...some synchronous code...
await doGet(....) // <-- function continues synchronous execution, once this async call returned
...some synchronous code...
}
Show more

Note that a function declared as async automatically returns a promise, so you don't have to explicitly return one.

The following example does not necessarily work as expected, but might work intermittently, depending on the runtime of asynchronous code. Do not use this type of pattern.

function main() {
...some synchronous code...
doGet(callback => {
...log result... // <-- this line is never reached, if the doGet is not complete before the action container gets stopped
});
...some synchronous code... // <-- this code is usually executed BEFORE the doGet callback got processed. Make sure that this is what you expect to happen!
}

Instead, either use promises as part of the function or use async/await.

The following example performs the same type of function as in the previous example, but instead uses async/await. This type of function code runs reliably.

async function main() {
...some synchronous code...
await doGet(callback => {
...log result... // <-- this line gets now executed BEFORE the below synchronous code block is reached
});
...some synchronous code... // <-- the whole function now behaves as if it was only using synchronous code
}
If you use the recommended format for the response and the translation response shown earlier is returned, the assistant's response to the user would be: Your words in Spanish: ¿Cómo estás?
* If you want to provide a specific response if the callout returns an empty string, meaning the call is successful, but the value returned is an empty string, you can add a conditional response that has a condition with syntax like this:

$webhook_result_1.size() == 0



8. When you are done, click the X to close the node. Your changes are automatically saved.







 Testing webhooks 

When you first add a webhook callout, it can be useful to see exactly what is returned in the response from the external application, the data and its format. To do this, add this expression as the text response for the successful callout conditional response: $webhook_result_n where n is the appropriate number for the webhook you are testing.

This response returns the full body of the return variable, so you can see what the callout is sending back and decide what to share with the user. You can then use the methods documented in [Expression language methods](https://cloud.ibm.com/docs/assistant-data?topic=assistant-data-dialog-methods) to extract only the information you care about from the response.

Test whether certain user inputs can generate errors in the callout, and build in ways to handle those situations. Errors generated by the external application are stored in output.webhook_error.<result_variable>. You can use a conditional response like this while you are testing to capture such errors:



 Condition Response 

 output.webhook_error The callout generated this error: . 



For example, you might not be authenticating the request properly (401), or you might be trying to pass a parameter with a name that is already in use by the external application. Test the webhook to discover and fix these types of errors before you deploy the webhook.





 Removing a webhook 

If you decide you do not want to make a webhook call from a dialog node, open the node's Customize page, and then switch Webhooks Off.
if (result.output.generic.length > 0) {
result.output.generic.forEach( response => {
if (response.response_type === 'text') {
console.log(response.text);
}
});
}
}

// Prompt for the next round of input unless skip_user_input is true.
let newMessageFromUser = '';
if (result.context.global.system.skip_user_input !== true) {
newMessageFromUser = prompt('>> ');
}

if (newMessageFromUser !== 'quit') {
newMessageInput = {
messageType: 'text',
text: newMessageFromUser,
}
sendMessage(newMessageInput);
}
}

This version of the application begins the same way as before: sending an empty message to the assistant to start the conversation.

The processResult() function displays the text of any responses received from the assistant. It then prompts for the next round of user input.

It then displays the text of any responses received from the assistant, and it prompts for the next round of user input.

The example checks for the global context variable skip_user_input and prompts for user input only if this variable is not set to true True. The skip_user_input variable is set by the assistant in some situations where no user input is needed (for example, if the assistant has called an external service but is still waiting for the result). It's good practice always to make this check before prompting for user input.

Because we need a way to end the conversation, the client app is also watching for the literal command quit to indicate that the program should exit.

But something still isn't right:

Welcome to the Watson Assistant example. What's your name?
>> Robert
I'm afraid I don't understand. Please rephrase your question.
>> I want to make an appointment.
What day would you like to come in?
Response<Catalog> response = service.createCatalog(createOptions).execute();
System.out.println(response.getResult());

label = "{label}"
shortDesc = "{shortDesc}"
response = self.service.create_catalog(label=label, short_description=shortDesc)
print(response)

label := "{label}"
shortDesc := "{shortDesc}"
createOptions := service.NewCreateCatalogOptions()
createOptions.SetLabel(label)
createOptions.SetShortDescription(shortDesc)
_, response, _ := service.CreateCatalog(createOptions)
fmt.Println(response)

label = "{label}";
shortDesc = "{shortDesc}";
response = await service.createCatalog({ 'label': label, 'shortDescription': shortDesc });
console.log(response);





 Importing software to your private catalog by using the API 

You can programmatically import software to your catalog by calling the Catalog Management API as shown in the following sample request. This API creates the software and imports it as well. For detailed information about the API, see [Catalog Management API](https://cloud.ibm.com/apidocs/resource-catalog/private-catalog?code=goimport-offering).



* Java
* Python
* Go
* Node



id = "{id}";
offeringURL = "{offeringURL}";
ImportOfferingOptions offeringOptions = new ImportOfferingOptions.Builder().catalogIdentifier(id).zipurl(offeringURL).build();
Response<Offering> response = service.importOffering(offeringOptions).execute();
System.out.println(response.getResult());

id = "{id}"
offeringURL = "{offeringURL}"
The SDK uses the attribute values to determine whether the specified entity satisfies the targeting rules, and returns the appropriate feature flag value.







 Get single property 

const property = appConfigClient.getProperty('property_id'); // property can be null incase of an invalid property id

if (property != null) {
console.log(Property Name ${property.getPropertyName()} );
console.log(Property Id ${property.getPropertyId()} );
console.log(Property Type ${property.getPropertyDataType()} );
}





 Get all properties 

const properties = appConfigClient.getProperties();
const property = properties['property_id'];

if (property != null) {
console.log(Property Name ${property.getPropertyName()} );
console.log(Property Id ${property.getPropertyId()} );
console.log(Property Type ${property.getPropertyDataType()} );
}





 Evaluate a property 

You can use the property.getCurrentValue(entityId, entityAttributes) method to evaluate the value of the property. This method returns a JSON object containing evaluated value and evaluation details.

const entityId = '<entityId>';
const entityAttributes = {
city: 'Bangalore',
country: 'India',
};

const result = property.getCurrentValue(entityId, entityAttributes);
console.log(result.value); // Evaluated value of the property. The type of evaluated value will match the type of property (Boolean, String, Numeric).
console.log(result.details); // a JSON object containing detailed information of the evaluation. See below

// the result.details will have the following
console.log(result.details.valueType); // a string value. Example: DEFAULT_VALUE
service = CloudantV1.new_instance()

response = service.post_find(
db='my-movies',
selector={'Person_name': 'Zoe Saldana'}
).get_result()

print(response)

postFindOptions := service.NewPostFindOptions(
"my-movies",
map[string]interface{}{
"Person_name": "Zoe Saldana",
},
)

findResult, _, err := service.PostFind(postFindOptions)
if err != nil {
panic(err)
}

b, _ := json.MarshalIndent(findResult, "", " ")
fmt.Println(string(b))

The previous Go example requires the following import block:

import (
"encoding/json"
"fmt"
"github.com/IBM/cloudant-go-sdk/cloudantv1"
)

See the following example result from the search:

{
"docs": [
{
"_id": "d9e6a7ae2363d6cfe81af75a3941110b",
"_rev": "1-556aec0e89fa13769fbf59d651411528",
"Movie_runtime": 162,
"Movie_rating": "PG-13",
"Person_name": "Zoe Saldana",
"Movie_genre": "AVYS",
"Movie_name": "Avatar",
"Movie_earnings_rank": "1",
"Person_pob": "New Jersey, USA",
"Movie_year": 2009,
"Person_dob": "1978-06-19"
}
],
"bookmark": "g2wA ... Omo"
}
Show more
val result = feature.getCurrentValue(entityId, entityAttributes) as JSONObject
result.get("key") // returns the value of the key
}

val feature: Feature? = appConfiguration.getFeature("yaml-feature")
feature.getFeatureDataType(); // STRING
feature.getFeatureDataFormat(); // YAML
feature.getCurrentValue(entityId, entityAttributes); // returns the stringified yaml (check Table 1)





 Property 

val property: Property? = appConfiguration.getProperty("json-property")
property.getPropertyDataType(); // STRING
property.getPropertyDataFormat(); // JSON

// Example below (traversing the returned JSONObject)
if (property != null) {
val result = property.getCurrentValue(entityId, entityAttributes) as JSONObject
result.get("key") // returns the value of the key
}

val property: Property? = appConfiguration.getProperty("yaml-property")
property.getPropertyDataType(); // STRING
property.getPropertyDataFormat(); // YAML
property.getCurrentValue(entityId, entityAttributes); // returns the stringified yaml (check above Table 1)



* Force fetch the configurations from server.

appConfiguration.fetchConfigurations()











 Integrating client SDK for Android app written in Java 

App Configuration service provides Android client SDK to integrate with your Android application. You can evaluate the values of your property and feature flag by integrating the SDK.



1. Install the SDK by using either one of the options:
(https://cloud.ibm.com/docs-content/v1/content/f16b1f78a92498247223b337bd9303c2758b9ba8/discovery-data/images/tut-sdu-activity.png)

Figure 6. Activity page that shows the data upload is finished





 Step 4: Test your project 



1. After the crawl is completed, go to the Improve and customize page. From the navigation panel, click Improve and customize.
2. In the Search field, enter When did the Flash Crash occur and why?

The following passage is returned as the response:

These could in turn generate systemic destabilizing market events, such as the May 2010 “Flash Crash.” The “Flash Crash” occurred on May 6, 2010, when an algorithm rapidly sold 75,000 S&P500 e-mini futures contracts.

The returned passage contains an accurate answer to the question.

Zoom

![Shows the passages that are returned by search.](https://cloud.ibm.com/docs-content/v1/content/f16b1f78a92498247223b337bd9303c2758b9ba8/discovery-data/images/tut-sdu-search-fast-crash.png)

Figure 7. Search results
3. Ask another question, What is the purpose of Rule 15c3-5?

The following passage is returned as the response:

mechanism.306 b. 15c3-5 In November 2011, the SEC implemented the final provision of Rule 15c3-5 curbing unfiltered market access. The provision mandated that brokers verify their clients’ order flow for compliance with credit and capital thresholds before routing to market centers

Again, the answer is accurate (despite there being some extraneous text at the beginning of the passage).

In both examples, a somewhat complex question is asked and the passage that is returned provides a valid answer.

However, not every question returns as clear an answer.
// Send message to assistant.
function sendMessage(messageInput) {
assistant
.messageStateless({
assistantId,
input: messageInput,
})
.then(res => {
processResult(res.result);
})
.catch(err => {
console.log(err); // something went wrong
});
}

// Process the result.
function processResult(result) {
// Print responses from actions, if any. Supports only text responses.
if (result.output.generic) {
if (result.output.generic.length > 0) {
result.output.generic.forEach( response => {
if (response.response_type == 'text') {
console.log(response.text);
}
});
}
}
}

The first step is to create a the service object, a sort of wrapper for the Watson Assistant service.

You use the service object for sending input to, and receiving output from, the service. When you create the service object, you specify the API key for authentication, as well as the version of the Watson Assistant API you are using.

In this Node.js example, the service object is an instance of AssistantV2, stored in the variable assistant. The Watson SDKs for other languages provide equivalent mechanisms for instantiating a service object.

In this Python example, the service object is an instance of watson_developer_cloud.AssistantV2, stored in the variable assistant. The Watson SDKs for other languages provide equivalent mechanisms for instantiating a service object.

After creating the service object, we use it to send a message to the assistant, using the stateless message method. In this example, the message is empty; we just want to trigger the Greet customer action to start the conversation, so we don't need any input text. We then print any text responses returned in the generic array in the returned output.

Use the node <filename.js> command to run the example application.
console.log(result.value); // Evaluated value of the property. The type of evaluated value will match the type of property (Boolean, String, Numeric).
console.log(result.details); // a JSON object containing detailed information of the evaluation. See below

// the result.details will have the following
console.log(result.details.valueType); // a string value. Example: DEFAULT_VALUE
console.log(result.details.reason); // a string value. Example: Default value of the property.
console.log(result.details.segmentName); // (only if applicable, else it is undefined) a string value containing the segment name for which the property was evaluated.
console.log(result.details.errorType); // (only if applicable, else it is undefined) contains the error.message if any error was occured during the evaluation.
Show more



* entityId: Id of the entity. This is a string identifier related to the entity against which the property is evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App Configuration, it must provide a unique entity ID.
* entityAttributes: A JSON object consisting of the attribute name and their values that define the specified entity. This is an optional parameter if the property is not configured with any targeting definition. If the targeting is configured, then entityAttributes should be provided for the rule evaluation. An attribute is a parameter that is used to define a segment. The SDK uses the attribute values to determine whether the specified entity satisfies the targeting rules, and returns the appropriate property value.







 Get secret property 

Explicit method for getting the secret references stored in App Configuration.

const secretPropertyObject = appConfigClient.getSecret(propertyId, secretsManagerObject);

Where,
feature.getCurrentValue(entityId, entityAttributes); // JSONObject or JSONArray is returned
}

// Example Below
// input json :- [{"role": "developer", "description": "do coding"},{"role": "tester", "description": "do testing"}]
// expected output :- "do coding"

JSONArray tar_val = (JSONArray) feature.get_current_value(entityId, entityAttributes);
String expected_output = (String) ((JSONObject) tar_val.get(0)).get('description');

// input json :- {"role": "tester", "description": "do testing"}
// expected output :- "tester"

JSONObject tar_val = (JSONObject) feature.get_current_value(entityId, entityAttributes);
String expected_output = (String) tar_val.get('role');

Feature feature = appConfigClient.getFeature("yaml-feature");
if (feature != null) {
feature.getFeatureDataType(); // STRING
feature.getFeatureDataFormat(); // YAML
feature.getCurrentValue(entityId, entityAttributes); // Yaml String is returned
}
Show more



 Property 

Property property = appConfigClient.getProperty("json-property");
if (property != null) {
property.getPropertyDataType(); // STRING
property.getPropertyDataFormat(); // JSON
property.getCurrentValue(entityId, entityAttributes); // JSONObject or JSONArray is returned
}

// Example Below
result := feature.GetCurrentValue(entityID, entityAttributes) // YAML value is returned as a Map
result.(map[string]interface{})["key"] // returns the value of the key
}
Show more



 Property 

property, err := appConfigClient.GetProperty("json-property")
if err == nil {
property.GetPropertyDataType() // STRING
property.GetPropertyDataFormat() // JSON

// Example (traversing the returned map)
result := property.GetCurrentValue(entityID, entityAttributes) // JSON value is returned as a Map
result.(map[string]interface{})["key"] // returns the value of the key
}

property, err := appConfigClient.GetProperty("yaml-property")
if err == nil {
property.GetPropertyDataType() // STRING
property.GetPropertyDataFormat() // YAML

// Example (traversing the returned map)
result := property.GetCurrentValue(entityID, entityAttributes) // YAML value is returned as a Map
result.(map[string]interface{})["key"] // returns the value of the key
}
Show more





 Listen to the property and feature changes 

To listen to the data changes, add the following code in your application:

appConfigClient.RegisterConfigurationUpdateListener(func () {
// add your code
// To find the effect of any configuration changes, you can call the feature or property related methods

// feature, err := appConfigClient.GetFeature("json-feature")
// newValue := feature.GetCurrentValue(entityID, entityAttributes)
})
You can use the feature.get_current_value(entity_id, entity_attributes) method to evaluate the value of the feature flag. This method returns one of the Enabled or Disabled or Overridden value based on the evaluation. The data type of returned value matches that of feature flag.

entity_id = "john_doe"
entity_attributes = {
'city': 'Bangalore',
'country': 'India'
}
feature_value = feature.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)



* entity_id: Id of the entity. This is a string identifier related to the entity against which the feature is evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App Configuration, it must provide a unique entity ID.
* entity_attributes: A JSON object consisting of the attribute name and their values that define the specified entity. This is an optional parameter if the feature flag is not configured with any targeting definition. If the targeting is configured, then entity_attributes should be provided for the rule evaluation. An attribute is a parameter that is used to define a segment. The SDK uses the attribute values to determine whether the specified entity satisfies the targeting rules, and returns the appropriate feature flag value.







 Get single Property 

property = appconfig_client.get_property('check-in-charges') property can be None incase of an invalid property id
if property is not None:
print(f'Property Name : {0}'.format(property.get_property_name()))
print(f'Property Id : {0}'.format(property.get_property_id()))
print(f'Property Data Type : {0}'.format(property.get_property_data_type()))





 Get all Properties 

properties_dictionary = appconfig_client.get_properties()





 Property evaluation
Return values Wraps EP11 error into message Grep11Error. 



Code snippets



* Golang code snippet

// Use DigestUpdate if you would like to breakup
// the digest operation into multiple suboperations
DigestUpdateRequest1 := &pb.DigestUpdateRequest {
State: DigestInitResponse.State,
Data: digestData[:16],
}

DigestUpdateResponse, err := cryptoClient.DigestUpdate(context.Background(), DigestUpdateRequest1)

DigestUpdateRequest2 := &pb.DigestUpdateRequest {
State: DigestUpdateResponse.State,
Data: digestData[16:],
}

DigestUpdateResponse, err := cryptoClient.DigestUpdate(context.Background(), DigestUpdateRequest2)
* JavaScript code snippet

client.DigestUpdate({
State: state,
Data: Buffer.from(digestData.substr(0, 64))
}, (err, data={}) => {
cb(err, data.State);
});







 DigestFinal 

The DigestFinal function finishes a multiple-part digesting operation.

Enterprise PKCS #11 over gRPC

Enterprise PKCS #11

PKCS #11





 Description Binds to EP11 m_DigestFinal, which is an implementation of PKCS #11 C_DigestFinal. 
 Parameters message DigestFinalRequest { bytes State = 1; } message DigestFinalResponse { bytes Digest = 2; } 
 Return values Wraps EP11 error into message Grep11Error. 



Code snippets



* Golang code snippet

DigestFinalRequest := &pb.DigestFinalRequest {
State: DigestUpdateResponse.State,
}

DigestFinalResponse, err := cryptoClient.DigestFinal(context.Background(), DigestFinalRequest)