|
8 | 8 | conversation = ConversationV1( |
9 | 9 | username='YOUR SERVICE USERNAME', |
10 | 10 | password='YOUR SERVICE PASSWORD', |
11 | | - version='2016-09-20') |
| 11 | + version='2017-04-21') |
12 | 12 |
|
13 | 13 | # replace with your own workspace_id |
14 | 14 | workspace_id = '0a0c06c1-8e31-4655-9067-58fcac5134fc' |
|
127 | 127 | text='I want financial advice today.') |
128 | 128 | print(json.dumps(response, indent=2)) |
129 | 129 |
|
| 130 | +######################### |
| 131 | +# entities |
| 132 | +######################### |
| 133 | + |
| 134 | +values = [{"value": "juice"}] |
| 135 | +response = conversation.create_entity(workspace_id=workspace_id, |
| 136 | + entity='test_entity', |
| 137 | + description='A test entity.', |
| 138 | + values=values) |
| 139 | +print(json.dumps(response, indent=2)) |
| 140 | + |
| 141 | +response = conversation.get_entity(workspace_id=workspace_id, |
| 142 | + entity='test_entity', |
| 143 | + export=True) |
| 144 | +print(json.dumps(response, indent=2)) |
| 145 | + |
| 146 | +response = conversation.list_entities(workspace_id=workspace_id) |
| 147 | +print(json.dumps(response, indent=2)) |
| 148 | + |
| 149 | +response = conversation.update_entity(workspace_id=workspace_id, |
| 150 | + entity='test_entity', |
| 151 | + new_description='An updated test entity.') |
| 152 | +print(json.dumps(response, indent=2)) |
| 153 | + |
| 154 | +response = conversation.delete_entity(workspace_id=workspace_id, |
| 155 | + entity='test_entity') |
| 156 | +print(json.dumps(response, indent=2)) |
| 157 | + |
| 158 | +######################### |
| 159 | +# synonyms |
| 160 | +######################### |
| 161 | + |
| 162 | +values = [{"value": "orange juice"}] |
| 163 | +conversation.create_entity(workspace_id, 'beverage', values=values) |
| 164 | + |
| 165 | +response = conversation.create_synonym(workspace_id, 'beverage', 'orange juice', 'oj') |
| 166 | +print(json.dumps(response, indent=2)) |
| 167 | + |
| 168 | +response = conversation.get_synonym(workspace_id, 'beverage', 'orange juice', 'oj') |
| 169 | +print(json.dumps(response, indent=2)) |
| 170 | + |
| 171 | +response = conversation.list_synonyms(workspace_id, 'beverage', 'orange juice') |
| 172 | +print(json.dumps(response, indent=2)) |
| 173 | + |
| 174 | +response = conversation.update_synonym(workspace_id, 'beverage', 'orange juice', 'oj', 'OJ') |
| 175 | +print(json.dumps(response, indent=2)) |
| 176 | + |
| 177 | +response = conversation.delete_synonym(workspace_id, 'beverage', 'orange juice', 'OJ') |
| 178 | +print(json.dumps(response, indent=2)) |
| 179 | + |
| 180 | +conversation.delete_entity(workspace_id, 'beverage') |
| 181 | + |
| 182 | +######################### |
| 183 | +# values |
| 184 | +######################### |
| 185 | + |
| 186 | +conversation.create_entity(workspace_id, 'test_entity') |
| 187 | + |
| 188 | +response = conversation.create_value(workspace_id, 'test_entity', 'test') |
| 189 | +print(json.dumps(response, indent=2)) |
| 190 | + |
| 191 | +response = conversation.get_value(workspace_id, 'test_entity', 'test') |
| 192 | +print(json.dumps(response, indent=2)) |
| 193 | + |
| 194 | +response = conversation.list_values(workspace_id, 'test_entity') |
| 195 | +print(json.dumps(response, indent=2)) |
| 196 | + |
| 197 | +response = conversation.update_value(workspace_id, 'test_entity', 'test', 'example') |
| 198 | +print(json.dumps(response, indent=2)) |
| 199 | + |
| 200 | +response = conversation.delete_value(workspace_id, 'test_entity', 'example') |
| 201 | +print(json.dumps(response, indent=2)) |
| 202 | + |
| 203 | +conversation.delete_entity(workspace_id, 'test_entity') |
| 204 | + |
| 205 | +######################### |
| 206 | +# logs |
| 207 | +######################### |
| 208 | + |
| 209 | +response = conversation.list_logs(workspace_id=workspace_id) |
| 210 | +print(json.dumps(response, indent=2)) |
| 211 | + |
130 | 212 | ######################### |
131 | 213 | # clean-up |
132 | 214 | ######################### |
|
0 commit comments