|
| 1 | +import copy |
| 2 | + |
1 | 3 | import pytest |
2 | 4 |
|
3 | 5 | from kili.llm.presentation.client.llm import LlmClientMethods |
|
278 | 280 | "author": "test+admin@kili-technology.com", |
279 | 281 | "created_at": "2024-08-06T12:30:42.122Z", |
280 | 282 | "label_type": "DEFAULT", |
281 | | - "label": {"COMPARISON_JOB": "A_3", "CLASSIFICATION_JOB": ["BOTH_ARE_GOOD"]}, |
| 283 | + "label": { |
| 284 | + "turn": {"COMPARISON_JOB": "A_3", "CLASSIFICATION_JOB": ["BOTH_ARE_GOOD"]}, |
| 285 | + }, |
282 | 286 | } |
283 | 287 | ], |
284 | 288 | }, |
|
353 | 357 | "author": "test+admin@kili-technology.com", |
354 | 358 | "created_at": "2024-08-06T12:30:42.122Z", |
355 | 359 | "label_type": "DEFAULT", |
356 | | - "label": {"COMPARISON_JOB": "B_1"}, |
| 360 | + "label": { |
| 361 | + "turn": {"COMPARISON_JOB": "B_1"}, |
| 362 | + }, |
357 | 363 | } |
358 | 364 | ], |
359 | 365 | }, |
|
442 | 448 | "author": "test+admin@kili-technology.com", |
443 | 449 | "created_at": "2024-08-06T12:30:42.122Z", |
444 | 450 | "label_type": "DEFAULT", |
445 | | - "label": {"COMPARISON_JOB": "A_2"}, |
| 451 | + "label": { |
| 452 | + "turn": {"COMPARISON_JOB": "A_2"}, |
| 453 | + }, |
446 | 454 | } |
447 | 455 | ], |
448 | 456 | }, |
@@ -616,3 +624,88 @@ def test_export_dynamic_empty_json_interface(mocker): |
616 | 624 | kili_llm.export( |
617 | 625 | project_id="project_id", |
618 | 626 | ) |
| 627 | + |
| 628 | + |
| 629 | +def test_export_dynamic_with_conversation_level(mocker): |
| 630 | + updated_mock_json_interface = copy.deepcopy(mock_json_interface) |
| 631 | + |
| 632 | + updated_mock_json_interface["jobs"].update( |
| 633 | + { |
| 634 | + "CLASSIFICATION_JOB_0": { |
| 635 | + "content": { |
| 636 | + "categories": { |
| 637 | + "GOOD": {"children": [], "name": "Good", "id": "category7"}, |
| 638 | + "BAD": {"children": [], "name": "Bad", "id": "category8"}, |
| 639 | + }, |
| 640 | + "input": "radio", |
| 641 | + }, |
| 642 | + "level": "conversation", |
| 643 | + "instruction": "Overall quality", |
| 644 | + "mlTask": "CLASSIFICATION", |
| 645 | + "required": 1, |
| 646 | + "isChild": False, |
| 647 | + "isNew": False, |
| 648 | + }, |
| 649 | + "TRANSCRIPTION_JOB": { |
| 650 | + "content": {"input": "textField"}, |
| 651 | + "level": "conversation", |
| 652 | + "instruction": "Write something about the overall quality", |
| 653 | + "mlTask": "TRANSCRIPTION", |
| 654 | + "required": 1, |
| 655 | + "isChild": False, |
| 656 | + "isNew": False, |
| 657 | + }, |
| 658 | + } |
| 659 | + ) |
| 660 | + |
| 661 | + updated_mock_fetch_assets = copy.deepcopy(mock_fetch_assets) |
| 662 | + updated_mock_fetch_assets[0]["labels"][0]["annotations"].extend( |
| 663 | + [ |
| 664 | + { |
| 665 | + "id": "20241025134207822-9", |
| 666 | + "job": "CLASSIFICATION_JOB_0", |
| 667 | + "path": [], |
| 668 | + "labelId": "clzief6q2003e7tc91jm46uii", |
| 669 | + "chatItemId": None, |
| 670 | + "annotationValue": { |
| 671 | + "categories": ["GOOD"], |
| 672 | + }, |
| 673 | + "__typename": "ClassificationAnnotation", |
| 674 | + }, |
| 675 | + { |
| 676 | + "id": "20241025134209366-10", |
| 677 | + "job": "TRANSCRIPTION_JOB", |
| 678 | + "path": [], |
| 679 | + "labelId": "clzief6q2003e7tc91jm46uii", |
| 680 | + "chatItemId": None, |
| 681 | + "annotationValue": { |
| 682 | + "text": "something", |
| 683 | + }, |
| 684 | + "__typename": "TranscriptionAnnotation", |
| 685 | + }, |
| 686 | + ] |
| 687 | + ) |
| 688 | + |
| 689 | + updated_expected_export = copy.deepcopy(expected_export) |
| 690 | + updated_expected_export[0]["2"]["labels"][0]["label"]["conversation"] = { |
| 691 | + "CLASSIFICATION_JOB_0": ["GOOD"], |
| 692 | + "TRANSCRIPTION_JOB": "something", |
| 693 | + } |
| 694 | + get_project_return_val = { |
| 695 | + "jsonInterface": updated_mock_json_interface, |
| 696 | + "inputType": "LLM_INSTR_FOLLOWING", |
| 697 | + "title": "Test project", |
| 698 | + "id": "project_id", |
| 699 | + "dataConnections": None, |
| 700 | + } |
| 701 | + kili_api_gateway = mocker.MagicMock() |
| 702 | + kili_api_gateway.count_assets.return_value = 3 |
| 703 | + kili_api_gateway.get_project.return_value = get_project_return_val |
| 704 | + kili_api_gateway.list_assets.return_value = updated_mock_fetch_assets |
| 705 | + |
| 706 | + kili_llm = LlmClientMethods(kili_api_gateway) |
| 707 | + |
| 708 | + result = kili_llm.export( |
| 709 | + project_id="project_id", |
| 710 | + ) |
| 711 | + assert result == updated_expected_export |
0 commit comments