|
19 | 19 | # workspaces |
20 | 20 | ######################### |
21 | 21 |
|
22 | | -response = conversation.create_workspace(name='test_workspace', |
23 | | - description='Test workspace.', |
24 | | - language='en', |
25 | | - metadata={}) |
| 22 | +create_workspace_data = { |
| 23 | + "name": "test_workspace", |
| 24 | + "description": "integration tests", |
| 25 | + "language": "en", |
| 26 | + "intents": [ |
| 27 | + { |
| 28 | + "intent": "hello", |
| 29 | + "description": "string", |
| 30 | + "examples": [ |
| 31 | + { |
| 32 | + "text": "good morning" |
| 33 | + } |
| 34 | + ] |
| 35 | + } |
| 36 | + ], |
| 37 | + "entities": [ |
| 38 | + { |
| 39 | + "entity": "pizza_toppings", |
| 40 | + "description": "Tasty pizza toppings", |
| 41 | + "metadata": { |
| 42 | + "property": "value" |
| 43 | + } |
| 44 | + } |
| 45 | + ], |
| 46 | + "counterexamples": [ |
| 47 | + { |
| 48 | + "text": "string" |
| 49 | + } |
| 50 | + ], |
| 51 | + "metadata": {}, |
| 52 | +} |
| 53 | + |
| 54 | + |
| 55 | +response = conversation.create_workspace(name=create_workspace_data['name'], |
| 56 | + description=create_workspace_data['description'], |
| 57 | + language='en', |
| 58 | + intents=create_workspace_data['intents'], |
| 59 | + entities=create_workspace_data['entities'], |
| 60 | + counterexamples=create_workspace_data['counterexamples'], |
| 61 | + metadata=create_workspace_data['metadata']) |
26 | 62 | print(json.dumps(response, indent=2)) |
27 | 63 |
|
28 | 64 | workspace_id = response['workspace_id'] |
| 65 | +print("Workspace id ".format(workspace_id)) |
29 | 66 |
|
30 | 67 | response = conversation.get_workspace(workspace_id=workspace_id, export=True) |
31 | 68 | print(json.dumps(response, indent=2)) |
|
48 | 85 | # intents |
49 | 86 | ######################### |
50 | 87 |
|
| 88 | +examples = [{ "text": "good morning"}] |
51 | 89 | response = conversation.create_intent(workspace_id=workspace_id, |
52 | 90 | intent='test_intent', |
53 | | - description='Test intent.') |
| 91 | + description='Test intent.', |
| 92 | + examples=examples) |
54 | 93 | print(json.dumps(response, indent=2)) |
55 | 94 |
|
56 | 95 | response = conversation.get_intent(workspace_id=workspace_id, |
|
160 | 199 | print(json.dumps(response, indent=2)) |
161 | 200 |
|
162 | 201 | response = conversation.get_entity(workspace_id=workspace_id, |
163 | | - entity='test_entity', |
| 202 | + entity=entities[0]['entity'], |
164 | 203 | export=True) |
165 | 204 | print(json.dumps(response, indent=2)) |
166 | 205 |
|
|
223 | 262 |
|
224 | 263 | conversation.delete_entity(workspace_id, 'test_entity') |
225 | 264 |
|
| 265 | +######################### |
| 266 | +# Dialog nodes |
| 267 | +######################### |
| 268 | +create_dialog_node = { |
| 269 | + "dialog_node": "greeting", |
| 270 | + "description": "greeting messages", |
| 271 | + "actions": [ |
| 272 | + { |
| 273 | + "name": "hello", |
| 274 | + "type": "client", |
| 275 | + "parameters": {}, |
| 276 | + "result_variable": "string", |
| 277 | + "credentials": "string" |
| 278 | + } |
| 279 | + ] |
| 280 | +} |
| 281 | +response = conversation.create_dialog_node(workspace_id, |
| 282 | + create_dialog_node['dialog_node'], |
| 283 | + create_dialog_node['description'], |
| 284 | + actions=create_dialog_node['actions']) |
| 285 | +print(json.dumps(response, indent=2)) |
| 286 | + |
| 287 | +response = conversation.get_dialog_node(workspace_id, |
| 288 | + create_dialog_node['dialog_node']) |
| 289 | +print(json.dumps(response, indent=2)) |
| 290 | + |
| 291 | +response = conversation.list_dialog_nodes(workspace_id) |
| 292 | +print(json.dumps(response, indent=2)) |
| 293 | + |
| 294 | +response = conversation.update_dialog_node(workspace_id, |
| 295 | + create_dialog_node['dialog_node'], |
| 296 | + new_dialog_node='updated_node') |
| 297 | +print(json.dumps(response, indent=2)) |
| 298 | + |
| 299 | +response = conversation.delete_dialog_node(workspace_id, 'updated_node') |
| 300 | +print(json.dumps(response, indent=2)) |
| 301 | + |
226 | 302 | ######################### |
227 | 303 | # logs |
228 | 304 | ######################### |
|
0 commit comments