Skip to content

watson-developer-cloud/Watson-Assistant-Workspace-Retrain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retrain Workspace Script

Purpose

This script is used to automate the process of retraining workspaces in your Watson Assistant instance.

This script utilizes the Watson Python SDK to communicate with the Watson Assistant service. The endpoints that are utilized are:

  1. list_workspaces()
  2. list_intents()
  3. update_intent()

Note that for instances for that have more than 30 workspaces, updating all the workspaces will take time because of the 30 requests / 30 minutes rate limit. Therefore after every 30 workspaces are updated, the script sleeps for 30 minutes to reset the rate limit window.

Things To Know

How It Works

The script uses the endpoints listed above to get the workspaces and intents. Next, the script appends "RETRAINED" to the description of the first intent returned. This causes a retraining event to occur, and the workspace is retrained. If the workspace does not contain intents, then the entities are retrieved, and the first entity's description is updated to "RETRAINED".

Requirements and Running the Script

Requirements:

  • python 3.9
  • pip
  • conda (or another virtual environment. The steps shown below are for conda.)
  1. conda create -n update-workspace python=3.9 -y
  2. conda activate update-workspace
  3. pip install -r requirements.txt

Next, go to this link: https://cloud.ibm.com/apidocs/assistant/assistant-v1?code=python#endpoint-cloud. Copy the URL where your Watson Assistant instance is located and paste it next to URL in the config.ini file. Second, grab the API key for your instance and paste it to the API_KEY field in config.ini. You don't need to worry about the AUTH_URL

See the example_config.ini for reference.

Running the Script

  1. cd retrain
  2. python retrain_wksp.py

Errors

During the update process, if an error is encountered, the workspace_id is saved to "retrain_manually.txt" These workspaces will require you to retrain the workspace manually.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages