vania-janet/multiturn-rag-retrieval-data huggingface dataset:
!/usr/bin/env python3

import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
from sdcclient import IbmAuthHelper, SdMonitorClient

 Parse arguments.
def usage():
print('usage: %s <endpoint-url> <apikey> <instance-guid>' % sys.argv[0])
print('endpoint-url: The endpoint URL that should point to IBM Cloud')
print('apikey: IBM Cloud IAM apikey that will be used to retrieve an access token')
print('instance-guid: GUID of an IBM Cloud Monitoring with monitoring instance')
sys.exit(1)

if len(sys.argv) != 4:
usage()

URL = sys.argv[1]
APIKEY = sys.argv[2]
GUID = sys.argv[3]

 Name of the dashboard that you want to delete
DASHBOARD_NAME = "Nginx production"

 Instantiate the client
ibm_headers = IbmAuthHelper.get_headers(URL, APIKEY, GUID)
sdclient = SdMonitorClient(sdc_url=URL, custom_headers=ibm_headers)

 Show the list of dashboards
ok, res = sdclient.get_dashboards()

 Loop through all fetched dashboards
for dashboard in res[1]:
 Delete dashboard if it matches the pattern (one or many)
if DASHBOARD_NAME in dashboard['name']:
print("Deleting " + dashboard['name'])
res = sdclient.delete_dashboard(dashboard)
Show more





 Delete a dashboard from a team
* If you are using a private GitHub repository, provide your personal GitHub access token that you set up in [Setting up the IBM Cloud Schematics](https://cloud.ibm.com/docs/hpc-openshift?topic=hpc-openshift-setting-up-api) prerequisites in the x_github_token= "<github-api-token>" parameter. If you are using the public repository that is provided by IBM Cloud, you do not need to specify this parameter.
* Optional: Provide the tags if you want to filter resources by using the tag.



5. Run the Python script by using python3 <python-file-name> to create a Schematics workspace in the IBM Cloud.
6. You get a successful response if the parameters passed as part of the request are valid and you should be able to see the Schematics workspace that you created in the IBM Cloud console. If you don’t get a successful response, the error response contains the errors that you need to resolve. Resolve those errors and run the script until you are able to get a valid response and create a workspace.
7. Optional: If you want to add one of the variables such as base_name with the value oc-test when you create a workspace, provide the values in the following parameters:



* workspace_variable_request_model = {}
* workspace_variable_request_model['name'] = 'base_name'
* workspace_variable_request_model['value'] = 'oc-test'



8. If you want to update multiple values at the same time, follow the steps for [Updating variables with Schematics API](https://cloud.ibm.com/docs/hpc-openshift?topic=hpc-openshift-update-variables).





 Example Python request 

 Create a Schematics workspace using Python API

import json, logging

from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_schematics.schematics_v1 import SchematicsV1
Python script that uses IAM API key 

!/usr/bin/env python3

import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
from sdcclient import IbmAuthHelper, SdMonitorClient

 Parse arguments.
def usage():
print('usage: %s <ENDPOINT_URL> <API_KEY> <INSTANCE_GUID>' % sys.argv[0])
print('ENDPOINT_URL: IBM Cloud endpoint URL (e.g. https://us-south.monitoring.cloud.ibm.com')
print('API_KEY: IBM Cloud IAM API key. This key is used to retrieve an IAM access token.')
print('INSTANCE_GUID: GUID of an IBM Cloud Monitoring instance.')
sys.exit(1)

if len(sys.argv) != 4:
usage()

URL = sys.argv[1]
APIKEY = sys.argv[2]
GUID = sys.argv[3]

 Instantiate the client
ibm_headers = IbmAuthHelper.get_headers(URL, APIKEY, GUID)
sdclient = SdMonitorClient(sdc_url=URL, custom_headers=ibm_headers)
Show more





 Sample 2. Python script that uses a Monitoring API token 

!/usr/bin/env python3

import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))

from sdcclient import IbmAuthHelper, SdMonitorClient

 Parse arguments.
def usage():
API reference overview 

The SoftLayer® Application Programming Interface is the development interface that gives developers and system administrators direct interaction with IBM Cloud backend system. The SoftLayer API powers many of the features in the IBM Cloud console, which typically means if an interaction is possible in the IBM Cloud console, it can also be run in the API. Because you can programmatically interact with all portions of the IBM Cloud environment within the API, SoftLayer API can automate tasks. For example, you can use the SoftLayer_Virtual_Guest/createObject API to deploy a virtual server instance.

The SoftLayer API is a Remote Procedure Call system. Each call involves sending data to an API endpoint and receiving structured data in return. The format that is used to send and receive data with the SoftLayer API depends on which implementation of the API you choose. The SoftLayer API currently uses SOAP, XML-RPC, or REST for data transmission.

For more information about the SoftLayer API and virtual server APIs, see the following resources in the SoftLayer® Development Network:



* [SoftLayer API Overview](https://softlayer.github.io/reference/softlayerapi/)
* [Getting Started with the SoftLayer API](https://softlayer.github.io/article/getting-started/)
* [API Reference: Virtual_Guest::createObject](https://softlayer.github.io/reference/services/SoftLayer_Virtual_Guest/createObject/)
* [API Reference: Product_Order::placeOrder](https://softlayer.github.io/reference/services/SoftLayer_Product_Order/placeOrder/)



For API usage examples, see the following resources:



* [Understanding and building an order using the SoftLayer API order CLI](https://softlayer.github.io/article/understanding-ordering/)
* [SoftLayer API Examples - Release Notes](https://softlayer.github.io/)
* [Python examples](https://softlayer.github.io/python/)





 Dedicated virtual servers usage examples
You also want to keep an eye out for any informational messages that are generated by the ingestion process. It is easier to troubleshoot an ingestion issue, for example, when you ingest one collection at a time.



 Uploaded data 

If you used the API to upload documents into Discovery v1, a similar API is available in v2 to upload documents into collections. You must update any workflows that you use to automate the process to account for the new arrangement of projects and collections.

If the original documents that you ingested into Discovery v1 are no longer available, you can use the query API to extract the document text from Discovery v1. You can then add the text to a collection in Discovery v2. For more information, see [Recovering documents](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-migrate-to-v2migrate-to-v2-advanced-transfer).





 Crawled data 

If you crawled data from an external data source in v1, you can continue to crawl data from the same external data source in v2. All of the same data sources are supported.

To use data from an external data source, you must re-create the collections within a v2 project, and configure how the data source is crawled. For more information, see [Overview of data sources](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-sources).

The service needs time and resources to crawl and ingest documents from external data sources. Re-create the connectors one at a time. Factor the time it takes to recrawl the data into your migration plan schedule.





 Prebuilt data collections 

The following built-in data source collections are not available in v2:

Watson Discovery News
: This pre-enriched data source is not offered in v2. For more information about an alternative way to get news data, see [Using a news service with v2](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-migrate-to-v2migrate-to-v2-news).

COVID-19 kit
Pagination 



  Support for pagination features in the API 

The SDK MUST support pagination for any methods whose underlying API implements pagination.





  Pagination helpers 

The SDK MAY offer pagination "helper" methods that ease the burden of retrieving paginated lists of resources. The network-call complexity of these methods MUST be clear and under the control of the user.
From the drop-down menu, click Import API from a file or URL. ![toolkit-import-1.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/toolkit-import-1.png)
8. There is an OpenAPI 2.0 definition of the weather API that you will use for this tutorial. In the "Import OpenAPI (Swagger)" dialog box, enter this URL: https://raw.githubusercontent.com/IBM-Bluemix-Docs/apiconnect/master/tutorials/weather-provider-api_1.yaml.
9. Leave the Add a product option unchecked and click Import.
![screenshot_import-url.png](https://cloud.ibm.com/docs-content/v1/content/78bb71851d95d7580503eb9ba10cf3ae31490ade/apiconnect/tutorials/images/screenshot_import-url.png)



After you import the OpenAPI spec, you are taken to the Design view of the API. Here you can view various sections of the OpenAPI definition. Scroll to explore, and especially note the Host value. Also you can view the OpenAPI under the Source tab. _You'll see that the Host value is set to _ $(catalog.host). This is the base URL for your API proxy.





 Conclusion 

In this tutorial, you saw how an existing REST service can be invoked through an API passthrough proxy. You started by checking the availability of the sample service through the web browser. Then you created an API proxy in API Connect, and linked the proxy to the sample service to be invoked. Finally, you tested this service with the API Connect internal testing tools.

--------------------





 Next step
* For python:3.6, use the Docker image ibmfunctions/action-python-v3.6.



Example

docker pull ibmfunctions/action-python-v3.9:1.0.0

Example output

Using default tag: latest
latest: Pulling from ibmfunctions/action-python-v3.9:1.0.0
5. Create a virtual environment and install the additional Python packages.

The virtual environment directory must be named virtualenv to create a virtualenv folder in the test directory.

docker run --rm -v "$PWD:/tmp" --entrypoint "/bin/bash" ibmfunctions/action-python-v3.9:1.0.0 -c "cd /tmp && virtualenv virtualenv && source virtualenv/bin/activate && pip install -r requirements.txt"

This command instantiates a container (docker run) based on the runtime image selected and mounts the current working directory ($PWD) as /tmp into the container (-v "$PWD:/tmp"). Inside the container, it then changes to the /tmp directory cd /tmp, creates and activates the virtualenv (virtualenv virtualenv && source virtualenv/bin/activate), and runs the pip install to add the selected packages. The container is deleted when the command completes (--rm). The directory structure of the created virtualenv and finally, the installed packages can be found in the folder virtualenv in your current directory.

Example output

created virtual environment CPython3.9.10.final.0-64 in 3291ms
creator CPython3Posix(dest=/tmp/virtualenv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
Future<AsperaTransaction> asperaTransactionFuture = asperaTransferMgr.uploadDirectory(bucketName, directoryPrefix, inputDirectory, includeSubDirectories);
AsperaTransaction asperaTransaction = asperaTransactionFuture.get();
Show more

Key Values



* <bucket-name> - name of the bucket in your Object Storage service instance that has Aspera enabled.
* <absolute-path-to-directory> - directory of the files to be uploaded to Object Storage.
* <virtual-directory-prefix> - name of the directory prefix to be added to each file upon upload. Use null or empty string to upload the files to the bucket root.







 Directory Download 

String bucketName = "<bucket-name>";
String directoryPath = "<absolute-path-to-directory>";
String directoryPrefix = "<virtual-directory-prefix>";
boolean includeSubDirectories = true;

// Load Directory
File outputDirectory = new File(directoryPath);

// Create AsperaTransferManager for FASP download
AsperaTransferManager asperaTransferMgr = new AsperaTransferManagerBuilder(COS_API_KEY_ID, s3Client)
.withTokenManager(tokenManager)
.withAsperaConfig(asperaConfig)
.build();

// Download test directory
Future<AsperaTransaction> asperaTransactionFuture = asperaTransferMgr.downloadDirectory(bucketName, directoryPrefix, outputDirectory, includeSubDirectories);
AsperaTransaction asperaTransaction = asperaTransactionFuture.get();

Show more

Key Values



* <bucket-name> - name of the bucket in your Object Storage service instance that has Aspera enabled.
For more information about Python 3.9 packages, see [(Details on GitHub)](https://github.com/ibm-functions/runtime-python/blob/master/python3.9/requirements.txt).

For more information about Python 3.7 packages, see [(Details on GitHub)](https://github.com/ibm-functions/runtime-python/blob/master/python3.7/requirements.txt).

For more information about Python 3.6 packages, see [(Details on GitHub)](https://github.com/ibm-functions/runtime-python/blob/master/python3.6/requirements.txt).







 PHP runtime 

By default, all PHP actions are executed in a version 8.1 environment.

For more information about the php:8.1 runtime, see [(Details on GitHub)](https://github.com/apache/openwhisk-runtime-php/blob/master/core/php8.1Action/CHANGELOG.md).

The following PHP extensions are available in addition to the standard ones.



* bcmath
* curl
* gd
* intl
* mbstring
* mongodb
* mysqli
* pdo_mysql
* pdo_pgsql
* pdo_sqlite
* soap
* zip



Ensure that your action uses only the modules that are mentioned in the following table. \n While other PHP modules might be part of the runtime, they are included only as indirect dependencies of the other listed modules. These unlisted modules are candidates to be removed as soon as they are not required by the referring modules.





 Ruby runtime (deprecated) 

The Ruby runtime is deprecated. There is no relacement. Instead, you must migrate to a different runtime.

By default, all Ruby actions are executed in a version 2.6 environment.
Watson SDK support change
: Support for the following SDKs is provided by the Watson community of developers instead of IBM:



* Go
* Ruby
* Swift
* Unity



For more information, see [Watson SDKs](https://cloud.ibm.com/docs/discovery-data?topic=watson-using-sdks).





 1 June 2022 

The entity extractor tool is now easier to use
: The user interface was redesigned to better support the workflow of adding entity types and labeling examples of them. As part of the new design, the bulk labeling feature now is enabled by default, the documents view is easier to find and use, the suggestions pane is more responsive, and you can track metrics scores across multiple training runs. For more information about the entity extractor, see [Customizing the terms that Discovery can recognize](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-entity-extractor).

The entity extractor is now available in more plans and languages
: The entity extractor beta feature is now available to users of Plus and Enterprise plans in addition to Premium plans. The extractor enrichment is supported for collections in languages other than English.

When you remove a starting URL from a Web crawl connector its associated documents are deleted
: The Web crawl connector was updated. Starting with collections that you create after April 2022, if you remove a starting URL from the Web crawl configuration, any indexed documents that were derived from the content of the web page at that URL are deleted with the next crawl. For more information, see [Web crawl](https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-connector-web-cloud).





 16 May 2022 

Added API methods for working with stop words and expansion lists
: You can now get, add, and remove a stop words or expansion list for a collection programmatically. For more information, see the [Query modifications](https://cloud.ibm.com/apidocs/discovery-datagetstopwordlist) methods.





 13 May 2022 

An improved JSON view is available
The app manages the metadata for GitHub repositories and provides access to the statistics for data analytics. The traffic data is collected from GitHub either on-demand in the app or when triggered by Code Engine events, e.g., daily. The app discussed in this tutorial implements a multi-tenant-ready solution with the initial set of features supporting a single-tenant mode.

Code Engine Db2 on Cloud

+1

App ID



* 1 hour
* 2023-06-16



[Build a database-driven Slackbot](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-slack-chatbot-database-watson)Build a database-driven Slackbot

In this tutorial, you are going to build a Slackbot which allows to search and create entries in a backend Db2 on Cloud database. The Slackbot is backed by the IBM Watson® Assistant service. You will integrate Slack and IBM Watson® Assistant using an Assistant integration. Db2 on Cloud is made available to Watson Assistant as custom extension.

Code Engine Watson Assistant

+1

Db2 on Cloud



* 2 hours
* 2023-05-05



[SQL Database for Cloud data](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-sql-database)SQL Database for Cloud data

This tutorial shows how to provision a SQL (relational) database service. As administrator, you create a table and load a large data set (city information) into the database. Then, you deploy a web app "worldcities" to Code Engine. The app allows regular users to look up records from the cloud database. The app is written in Python using the Flask framework.

Code Engine Db2 Warehouse on Cloud



* 2 hours
* 2023-05-05
All IBM-developed coding examples and sample applications for the service SHOULD use the SDK.





 Contributor documentation 

The SDK MUST include documentation for developers that would like to contribute to the SDK either by opening issues or submitting pull requests.

In particular:



 Issue template and pull request template 

Provide issue and pull request templates to guide contributors on what information should be provided and what processes to follow when making contributions to the SDK.





 CONTRIBUTING.md 

Provide a CONTRIBUTING.md file in the root of the SDK repo containing the following information:



* The coding style established for the SDK. This is typically a reference to an externally documented coding style for the language, with perhaps some exceptions specific to the SDK.
* How to build the SDK
* How to run the code style checker and use the autofix feature if available
* How to run the unit tests and integration tests
* How to run a single test (for debugging)
* How to run the code coverage tooling
Before you begin, [review the packages that are included with the Python runtime](https://cloud.ibm.com/docs/openwhisk?topic=openwhisk-runtimesopenwhisk_ref_python_environments) to see whether a dependency of your app is already included with the runtime. If your dependency is not included, you must package it with your app.



1. Create a test directory on your desktop.
2. Save the following code as a file called __main__.py in your test directory.

from helper import helper
def main(args):
return helper(args)
3. Save the following code as a file called helper.py in your test directory. This code accepts a name parameter and returns a greeting. If no name is specified, the name that is returned is stranger.

def helper(dict):
if 'name' in dict:
name = dict['name']
else:
name = "stranger"
greeting = "Hello from helper.py, " + name + "!"
return {"greeting": greeting}
4. To package your app as a compressed file, cd to your test directory and run the following command. In this example, the archive is called stranger.zip.

zip -r stranger.zip __main__.py helper.py
5. You can use then use the compressed file to create an action called hello. Replace <file_path> with the file path to your compressed file.

ibmcloud fn action create hello <file_path>/test/stranger.zip --kind python:3.11
6. Test the action.

ibmcloud fn action invoke hello --result

Example output

{
"greeting": "Hello from helper.py, stranger!"
}
7. Test the action again and specify the name parameter. Replace the <your_name> parameter with your name.
[Architecture](https://cloud.ibm.com/docs-content/v1/content/f84e2238288b7f0355715a4c355609ce7ac48fb0/solution-tutorials/images/solution19/SlackbotArchitecture.svg)

Figure 1. Architecture diagram of the tutorial



1. The user interacts with [IBM Watson® Assistant](https://cloud.ibm.com/docs/watson-assistant), either through Slack or using a web chat client
2. The chatbot utilizes a custom extension with REST API deployed as Python app on [Code Engine](https://cloud.ibm.com/docs/codeengine?topic=codeengine-getting-started)
3. The custom extension app retrieves data from and inserts data into a [Db2 on Cloud](https://cloud.ibm.com/docs/Db2onCloud) database







 Before you begin 

This tutorial requires:



* IBM Cloud CLI,



* Code Engine plugin,



* git to clone source code repository,
* jq to query JSON data.



To avoid the installation of these tools you can use the [Cloud Shell](https://cloud.ibm.com/shell) from the IBM Cloud console.

You will find instructions to download and install these tools for your operating environment in the [Getting started with tutorials](https://cloud.ibm.com/docs/solution-tutorials?topic=solution-tutorials-tutorials) guide.





 Step 1: Set up services and deploy backend 

In this section, you are going to set up the needed services and deploy the backend app. All of this can be accomplished from the command line interface (CLI) in a terminal.



1. Clone the [GitHub repository](https://github.com/IBM-Cloud/slack-chatbot-database-watson) and navigate into the cloned directory:

git clone https://github.com/IBM-Cloud/slack-chatbot-database-watson
https://api.<region>.devops.cloud.ibm.com/v1/tekton-pipelines Gets the pipeline run data. 







 Promotion pipelines 

The following table lists and describes each of the hosts that are accessed from promotion pipelines.



Table 3. Promotion pipeline hosts

 Host Description 

 https://hooks.slack.com/services When the Slack integration is configured, notifications are sent when pipelines start and finish. 
 https://otc-github-consolidated-broker.<region>.devops.cloud.ibm.com/github/token?git_id=integrated The OTC broker URL to fetch a Git token if one was not provided. 
 https://<region>.git.cloud.ibm.com The open promotion pull request. 







 Continuous deployment pipelines 

The following table lists and describes each of the hosts that are accessed from continuous deployment pipelines.



Table 4. Continuous deployment pipeline hosts

 Host Description 

 https://hooks.slack.com/services When the Slack integration is configured, notifications are sent when pipelines start and finish. 
 https://otc-github-consolidated-broker.region.devops.cloud.ibm.com/github/token?git_id=integrated The OTC broker URL to fetch a Git token if one was not provided. 
 https://<region>.git.cloud.ibm.com Clones repos, and stores evidence, change requests, and inventory. 
 https://detect-secrets-client-version.s3.us-south Detects secrets checks for newer versions. 
 https://otcbroker.devopsinsights.cloud.ibm.com Checks the toolchain for Code Risk Analyzer support. 
 https://gitsecure.us-south.devopsinsights.cloud.ibm.com The Code Risk Analyzer API. 
 https://vcurator.us-south.devopsinsights.cloud.ibm.com Code Risk Analyzer. 
 Cloud Object Storage endpoint in cos-endpoint The endpoint that stores the evidence in Cloud Object Storage.