CLI workspaces

Workspaces#

All workspace commands are available via the workspace sub-commands of hf. Execute hf workspace --help to see the list of available sub-commands.

Listing#

To list workspaces, execute hf workspace list. The --sets option can be used to display the datasets used by each workspace.

Execute hf workspace list --help to see the list of available options.

$ hf workspace list --sets
id name disabled datasets intents phrases utters convs labelled
playbook-4WIKDZXCXFGMPBD7X5HRKKSA workspace1 false convset-YTB7YBPUUBDKJPQZPWUKHLJU 48 1513 3000 0 0.488667%
playbook-4ZDMYR4M3RAP5DXCQEGQ23JD workspace2 false convset-BT7QT6YCRFHLNDINXQP2KWG7 11 227 3001 0 0.000000%

Creation#

To create a new workspace, execute hf workspace create <name of the workspace>. The --sets [dataset id[,id]] can be used to link datasets to the new workspace.

$ hf workspace create workspace-name
Created: playbook-W3WG4KTBIJFNZA357GTKJTD4

Deletion#

To delete a workspace, execute hf workspace --id <id of the workspace> delete.

$ hf workspace --id playbook-Z6T2R76YXJB65LA62CHOTTPT delete
Deleted: playbook-W3WG4KTBIJFNZA357GTKJTD4

Import and export#

A workspace can be exported and imported using any format supported by Studio as documented in the intents section.

For third-party integrations, refer to their respective documentation: DialogFlow CX, DialogFlow ES, Rasa.

Workspace formats#

Shorthand nameDescription
jsonHumanFirst JSON format
cognigy_jsonCognigy intent JSON format
csvSimple intent CSV format
Import#

In order to import a workspace file, the workspace needs to exist first. You can create a workspace using the create (ex: hf workspace create my-workspace-name) command.

To import a workspace, execute hf workspace --id <id of the workspace> import [--format format] <filename>.

You can use the --clear option to clear the objects in the workspace before importing.

The --hierarchical-delimiter option can be used to specify the delimiter used to separate the intent name from the intent parent name for formats that don't support a hierarchy (ex: csv).

$ hf workspace --id playbook-Z6T2R76YXJB65LA62CHOTTPT import --format json my_workspace.json
The workspace 'playbook-4ZDMYR4M3RAP5DXCQEGQ23JD' has been imported
Export#

To export a workspace, execute hf workspace --id <id of the workspace> export [--format format] <filename>.

The --hierarchical-delimiter option can be used to specify the delimiter used to separate the intent name from the intent parent name for formats that don't support a hierarchy (ex: csv).

$ hf workspace --id playbook-Z6T2R76YXJB65LA62CHOTTPT export --format json my_workspace.json
The workspace 'playbook-Z6T2R76YXJB65LA62CHOTTPT' has been exported to 'my_workspace.json'

Data#

The data sub-command is used to manage the datasets linked to a workspace. Refer to the data management section for more information on datasets.

Linking & unlinking datasets#

To link a dataset to a workspace, execute hf workspace --workspace <id of the workspace> data link <id of the dataset>

and hf workspace --workspace <id of the workspace> data unlink <id of the dataset> to unlink it.

$ hf workspace --id playbook-4ZDMYR4M3RAP5DXCQEGQ23JD data link convset-BT7QT6YCRFHLNDINXQP2KWG7
Dataset 'convset-BT7QT6YCRFHLNDINXQP2KWG7' linked to workspace 'playbook-4ZDMYR4M3RAP5DXCQEGQ23JD'
$ hf workspace --id playbook-4ZDMYR4M3RAP5DXCQEGQ23JD data unlink convset-BT7QT6YCRFHLNDINXQP2KWG7
Dataset 'convset-BT7QT6YCRFHLNDINXQP2KWG7' unlinked from workspace 'playbook-4ZDMYR4M3RAP5DXCQEGQ23JD'

List linked datasets#

To list the datasets linked to a workspace, execute hf --workspace <id of the workspace> data list.

$ hf workspace --workspace playbook-Z6T2R76YXJB65LA62CHOTTPT data list
id name utterances
convset-BT7QT6YCRFHLNDINXQP2KWG7 bleh 3001

Managing files#

Files can be managed using the data management sub-command, but it is also possible to list and import files of a workspace from the workspace sub-command.

To list files available from a workspace, execute hf workspace --id <id of the workspace> data list-files.

$ hf workspace --workspace playbook-4ZDMYR4M3RAP5DXCQEGQ23JD data list-files
Files in dataset 'my-dataset' (id: convset-BT7QT6YCRFHLNDINXQP2KWG7)
file format time
file1.txt txt 2022-07-15T18:15:34Z
file2.txt txt 2022-07-15T21:11:07Z

To import a file into a workspace, execute hf workspace --workspace <id of the workspace> data import [--format format] <filename>. Refer to the file formats documentation for available formats.

The file content needs to be encoded in UTF-8 and can be passed via filename or stdin.

hf workspace --workspace playbook-4ZDMYR4M3RAP5DXCQEGQ23JD data import my-file.txt
No format specified, using 'txt'.
my-file.txt: File uploaded successfully