You can export models that you have already trained to back them up. You can use these backups to roll back an existing model or to transfer a model to a new project.
Export a model
Permissions required for this task
To perform this task, you must have the following permissions:
contactcenterinsights.issueModels.export
Exporting a topic model to Cloud Storage lets you save a backup copy of the model so that you can restore it later if needed.
To export a topic model, call the export
method on the
issueModel
resource.
Before using any of the request data, make the following replacements:
- PROJECT_ID: Your project ID.
- ISSUE_MODEL_ID: The ID of the topic model to export.
- GCS_DESTINATION: A Cloud Storage URI where the topic model is exported to.
HTTP method and URL:
POST https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID /locations/us-central1/issueModels/ISSUE_MODEL_ID :export
Request JSON body:
{ gcs_destination: { object_uri: 'GCS_DESTINATION ' } }
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID /locations/us-central1/issueModels/ISSUE_MODEL_ID :export"
PowerShell (Windows)
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID /locations/us-central1/issueModels/ISSUE_MODEL_ID :export" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID /locations/us-central1/operations/OPERATION_ID " }
Import a model
Permissions required for this task
To perform this task, you must have the following permissions:
contactcenterinsights.issueModels.create
contactcenterinsights.issueModels.import
Importing a topic model from Cloud Storage lets you replace an existing topic model or create a new topic model based on an existing model. Starting from an existing model can be useful when you want to make tweaks without changing the original model.
- To replace an existing topic model, call the import method with a Cloud Storage object URI, pointing to a previously exported topic model from the same project. Conversational Insights pulls the replacement model ID from the exported file.
- If the topic model does not exist in the project or is being imported into a new project, Conversational Insights automatically creates a new topic model.
- Optionally, you can set the
create_new_model
flag if you don't want to replace the existing model.
Before using any of the request data, make the following replacements:
- PROJECT_ID: Your project ID.
- GCS_SOURCE: The Cloud Storage URI where the topic model is saved.
- CREATE_NEW_MODEL: Boolean flag to create a new model, rather than replacing an existing model.
HTTP method and URL:
POST https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID /locations/us-central1/issueModels:import
Request JSON body:
{ gcs_source: { object_uri: 'GCS_SOURCE ' } create_new_model:CREATE_NEW_MODEL }
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID /locations/us-central1/issueModels:import"
PowerShell (Windows)
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://contactcenterinsights.googleapis.com/v1/projects/PROJECT_ID /locations/us-central1/issueModels:import" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_ID /locations/us-central1/operations/OPERATION_ID " }