|
2 | 2 | import tempfile |
3 | 3 |
|
4 | 4 | from kili.llm.presentation.client.llm import LlmClientMethods |
5 | | - |
6 | | -mock_json_interface = { |
7 | | - "jobs": { |
8 | | - "CLASSIFICATION_JOB": { |
9 | | - "content": { |
10 | | - "categories": { |
11 | | - "A_BETTER_THAN_B": { |
12 | | - "children": [], |
13 | | - "name": "A better than B", |
14 | | - "id": "category1", |
15 | | - }, |
16 | | - "B_BETTER_THAN_A": { |
17 | | - "children": [], |
18 | | - "name": "B better than A", |
19 | | - "id": "category2", |
20 | | - }, |
21 | | - "TIE": {"children": [], "name": "Tie", "id": "category3"}, |
22 | | - }, |
23 | | - "input": "radio", |
24 | | - }, |
25 | | - "instruction": "Compare", |
26 | | - "mlTask": "CLASSIFICATION", |
27 | | - "required": 0, |
28 | | - "isChild": False, |
29 | | - "isNew": False, |
30 | | - }, |
31 | | - "TRANSCRIPTION_JOB": { |
32 | | - "content": {"input": "markdown"}, |
33 | | - "instruction": "", |
34 | | - "mlTask": "TRANSCRIPTION", |
35 | | - "required": 0, |
36 | | - "isChild": False, |
37 | | - "isNew": False, |
38 | | - }, |
39 | | - } |
40 | | -} |
41 | | - |
42 | | -mock_fetch_assets = [ |
43 | | - { |
44 | | - "labels": [ |
45 | | - { |
46 | | - "author": { |
47 | | - "id": "user-1", |
48 | | - "email": "test+admin@kili-technology.com", |
49 | | - "firstname": "Test", |
50 | | - "lastname": "Admin", |
51 | | - }, |
52 | | - "jsonResponse": { |
53 | | - "CLASSIFICATION_JOB": {"categories": [{"name": "A_BETTER_THAN_B"}]} |
54 | | - }, |
55 | | - "createdAt": "2024-08-05T13:03:00.051Z", |
56 | | - "isLatestLabelForUser": True, |
57 | | - "isSentBackToQueue": False, |
58 | | - "labelType": "DEFAULT", |
59 | | - "modelName": None, |
60 | | - } |
61 | | - ], |
62 | | - "content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/01.json", |
63 | | - "externalId": "asset#0", |
64 | | - "jsonMetadata": {}, |
65 | | - "status": "LABELED", |
66 | | - }, |
67 | | - { |
68 | | - "labels": [ |
69 | | - { |
70 | | - "author": { |
71 | | - "id": "user-1", |
72 | | - "email": "test+admin@kili-technology.com", |
73 | | - "firstname": "Test", |
74 | | - "lastname": "Admin", |
75 | | - }, |
76 | | - "jsonResponse": { |
77 | | - "CLASSIFICATION_JOB": {"categories": [{"name": "B_BETTER_THAN_A"}]} |
78 | | - }, |
79 | | - "createdAt": "2024-08-05T13:03:03.061Z", |
80 | | - "isLatestLabelForUser": True, |
81 | | - "isSentBackToQueue": False, |
82 | | - "labelType": "DEFAULT", |
83 | | - "modelName": None, |
84 | | - } |
85 | | - ], |
86 | | - "content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/02.json", |
87 | | - "externalId": "asset#1", |
88 | | - "jsonMetadata": {}, |
89 | | - "status": "LABELED", |
90 | | - }, |
91 | | - { |
92 | | - "labels": [ |
93 | | - { |
94 | | - "author": { |
95 | | - "id": "user-1", |
96 | | - "email": "test+admin@kili-technology.com", |
97 | | - "firstname": "Test", |
98 | | - "lastname": "Admin", |
99 | | - }, |
100 | | - "jsonResponse": { |
101 | | - "CLASSIFICATION_JOB": {"categories": [{"name": "TIE"}]}, |
102 | | - "TRANSCRIPTION_JOB": {"text": "There is only some formatting changes\n"}, |
103 | | - }, |
104 | | - "createdAt": "2024-08-05T13:03:16.028Z", |
105 | | - "isLatestLabelForUser": True, |
106 | | - "isSentBackToQueue": True, |
107 | | - "labelType": "DEFAULT", |
108 | | - "modelName": None, |
109 | | - } |
110 | | - ], |
111 | | - "content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/03.json", |
112 | | - "externalId": "asset#2", |
113 | | - "jsonMetadata": {}, |
114 | | - "status": "LABELED", |
115 | | - }, |
116 | | -] |
117 | | - |
118 | | -mock_raw_asset_content = """{ |
119 | | - "prompts": [ |
120 | | - { |
121 | | - "prompt": "BLABLABLA", |
122 | | - "completions": [ |
123 | | - { |
124 | | - "content": "response A1" |
125 | | - }, |
126 | | - { |
127 | | - "content": "response B1" |
128 | | - } |
129 | | - ] |
130 | | - }, |
131 | | - { |
132 | | - "prompt": "BLIBLIBLI", |
133 | | - "completions": [ |
134 | | - { |
135 | | - "content": "response A2" |
136 | | - }, |
137 | | - { |
138 | | - "content": "response B2" |
139 | | - } |
140 | | - ] |
141 | | - } |
142 | | - ], |
143 | | - "type": "markdown", |
144 | | - "version": "0.1" |
145 | | -} |
146 | | -""" |
| 5 | +from tests.unit.services.export.fakes.llm_json_interface import mock_json_interface |
| 6 | +from tests.unit.services.export.fakes.llm_project_assets import mock_fetch_assets |
| 7 | +from tests.unit.services.export.fakes.llm_raw_asset_content import mock_raw_asset_content |
147 | 8 |
|
148 | 9 | expected_export = [ |
149 | 10 | { |
|
0 commit comments