|
30 | 30 |
|
31 | 31 | from box_sdk_gen.managers.uploads import UploadFileAttributesParentField |
32 | 32 |
|
33 | | -from box_sdk_gen.schemas.ai_extract_response import AiExtractResponse |
| 33 | +from box_sdk_gen.schemas.ai_extract_structured_response import ( |
| 34 | + AiExtractStructuredResponse, |
| 35 | +) |
34 | 36 |
|
35 | 37 | from box_sdk_gen.managers.ai import CreateAiExtractStructuredFields |
36 | 38 |
|
@@ -266,7 +268,7 @@ def testAIExtractStructuredWithFields(): |
266 | 268 | ) |
267 | 269 | file: FileFull = uploaded_files.entries[0] |
268 | 270 | delay_in_seconds(5) |
269 | | - response: AiExtractResponse = client.ai.create_ai_extract_structured( |
| 271 | + response: AiExtractStructuredResponse = client.ai.create_ai_extract_structured( |
270 | 272 | [AiItemBase(id=file.id)], |
271 | 273 | fields=[ |
272 | 274 | CreateAiExtractStructuredFields( |
@@ -311,16 +313,22 @@ def testAIExtractStructuredWithFields(): |
311 | 313 | ], |
312 | 314 | ai_agent=agent_ignoring_overriding_embeddings_model, |
313 | 315 | ) |
314 | | - assert to_string(get_value_from_object_raw_data(response, 'firstName')) == 'John' |
315 | | - assert to_string(get_value_from_object_raw_data(response, 'lastName')) == 'Doe' |
| 316 | + assert to_string( |
| 317 | + get_value_from_object_raw_data(response, 'answer.hobby') |
| 318 | + ) == to_string(['guitar']) |
316 | 319 | assert ( |
317 | | - to_string(get_value_from_object_raw_data(response, 'dateOfBirth')) |
318 | | - == '1990-07-04' |
| 320 | + to_string(get_value_from_object_raw_data(response, 'answer.firstName')) |
| 321 | + == 'John' |
319 | 322 | ) |
320 | | - assert to_string(get_value_from_object_raw_data(response, 'age')) == '34' |
321 | | - assert to_string(get_value_from_object_raw_data(response, 'hobby')) == to_string( |
322 | | - ['guitar'] |
| 323 | + assert ( |
| 324 | + to_string(get_value_from_object_raw_data(response, 'answer.lastName')) == 'Doe' |
323 | 325 | ) |
| 326 | + assert ( |
| 327 | + to_string(get_value_from_object_raw_data(response, 'answer.dateOfBirth')) |
| 328 | + == '1990-07-04' |
| 329 | + ) |
| 330 | + assert to_string(get_value_from_object_raw_data(response, 'answer.age')) == '34' |
| 331 | + assert response.completion_reason == 'done' |
324 | 332 | client.files.delete_file_by_id(file.id) |
325 | 333 |
|
326 | 334 |
|
@@ -378,22 +386,28 @@ def testAIExtractStructuredWithMetadataTemplate(): |
378 | 386 | ), |
379 | 387 | ], |
380 | 388 | ) |
381 | | - response: AiExtractResponse = client.ai.create_ai_extract_structured( |
| 389 | + response: AiExtractStructuredResponse = client.ai.create_ai_extract_structured( |
382 | 390 | [AiItemBase(id=file.id)], |
383 | 391 | metadata_template=CreateAiExtractStructuredMetadataTemplate( |
384 | 392 | template_key=template_key, scope='enterprise' |
385 | 393 | ), |
386 | 394 | ) |
387 | | - assert to_string(get_value_from_object_raw_data(response, 'firstName')) == 'John' |
388 | | - assert to_string(get_value_from_object_raw_data(response, 'lastName')) == 'Doe' |
389 | 395 | assert ( |
390 | | - to_string(get_value_from_object_raw_data(response, 'dateOfBirth')) |
391 | | - == '1990-07-04T00:00:00Z' |
| 396 | + to_string(get_value_from_object_raw_data(response, 'answer.firstName')) |
| 397 | + == 'John' |
| 398 | + ) |
| 399 | + assert ( |
| 400 | + to_string(get_value_from_object_raw_data(response, 'answer.lastName')) == 'Doe' |
392 | 401 | ) |
393 | | - assert to_string(get_value_from_object_raw_data(response, 'age')) == '34' |
394 | | - assert to_string(get_value_from_object_raw_data(response, 'hobby')) == to_string( |
395 | | - ['guitar'] |
| 402 | + assert ( |
| 403 | + to_string(get_value_from_object_raw_data(response, 'answer.dateOfBirth')) |
| 404 | + == '1990-07-04T00:00:00Z' |
396 | 405 | ) |
| 406 | + assert to_string(get_value_from_object_raw_data(response, 'answer.age')) == '34' |
| 407 | + assert to_string( |
| 408 | + get_value_from_object_raw_data(response, 'answer.hobby') |
| 409 | + ) == to_string(['guitar']) |
| 410 | + assert response.completion_reason == 'done' |
397 | 411 | client.metadata_templates.delete_metadata_template( |
398 | 412 | DeleteMetadataTemplateScope.ENTERPRISE, template.template_key |
399 | 413 | ) |
|
0 commit comments