-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(LAB-3105): add tests on llm_v1 format
- Loading branch information
1 parent
eb4e85b
commit aeccef6
Showing
11 changed files
with
539 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,148 +2,9 @@ | |
import tempfile | ||
|
||
from kili.llm.presentation.client.llm import LlmClientMethods | ||
|
||
mock_json_interface = { | ||
"jobs": { | ||
"CLASSIFICATION_JOB": { | ||
"content": { | ||
"categories": { | ||
"A_BETTER_THAN_B": { | ||
"children": [], | ||
"name": "A better than B", | ||
"id": "category1", | ||
}, | ||
"B_BETTER_THAN_A": { | ||
"children": [], | ||
"name": "B better than A", | ||
"id": "category2", | ||
}, | ||
"TIE": {"children": [], "name": "Tie", "id": "category3"}, | ||
}, | ||
"input": "radio", | ||
}, | ||
"instruction": "Compare", | ||
"mlTask": "CLASSIFICATION", | ||
"required": 0, | ||
"isChild": False, | ||
"isNew": False, | ||
}, | ||
"TRANSCRIPTION_JOB": { | ||
"content": {"input": "markdown"}, | ||
"instruction": "", | ||
"mlTask": "TRANSCRIPTION", | ||
"required": 0, | ||
"isChild": False, | ||
"isNew": False, | ||
}, | ||
} | ||
} | ||
|
||
mock_fetch_assets = [ | ||
{ | ||
"labels": [ | ||
{ | ||
"author": { | ||
"id": "user-1", | ||
"email": "[email protected]", | ||
"firstname": "Test", | ||
"lastname": "Admin", | ||
}, | ||
"jsonResponse": { | ||
"CLASSIFICATION_JOB": {"categories": [{"name": "A_BETTER_THAN_B"}]} | ||
}, | ||
"createdAt": "2024-08-05T13:03:00.051Z", | ||
"isLatestLabelForUser": True, | ||
"isSentBackToQueue": False, | ||
"labelType": "DEFAULT", | ||
"modelName": None, | ||
} | ||
], | ||
"content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/01.json", | ||
"externalId": "asset#0", | ||
"jsonMetadata": {}, | ||
"status": "LABELED", | ||
}, | ||
{ | ||
"labels": [ | ||
{ | ||
"author": { | ||
"id": "user-1", | ||
"email": "[email protected]", | ||
"firstname": "Test", | ||
"lastname": "Admin", | ||
}, | ||
"jsonResponse": { | ||
"CLASSIFICATION_JOB": {"categories": [{"name": "B_BETTER_THAN_A"}]} | ||
}, | ||
"createdAt": "2024-08-05T13:03:03.061Z", | ||
"isLatestLabelForUser": True, | ||
"isSentBackToQueue": False, | ||
"labelType": "DEFAULT", | ||
"modelName": None, | ||
} | ||
], | ||
"content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/02.json", | ||
"externalId": "asset#1", | ||
"jsonMetadata": {}, | ||
"status": "LABELED", | ||
}, | ||
{ | ||
"labels": [ | ||
{ | ||
"author": { | ||
"id": "user-1", | ||
"email": "[email protected]", | ||
"firstname": "Test", | ||
"lastname": "Admin", | ||
}, | ||
"jsonResponse": { | ||
"CLASSIFICATION_JOB": {"categories": [{"name": "TIE"}]}, | ||
"TRANSCRIPTION_JOB": {"text": "There is only some formatting changes\n"}, | ||
}, | ||
"createdAt": "2024-08-05T13:03:16.028Z", | ||
"isLatestLabelForUser": True, | ||
"isSentBackToQueue": True, | ||
"labelType": "DEFAULT", | ||
"modelName": None, | ||
} | ||
], | ||
"content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/03.json", | ||
"externalId": "asset#2", | ||
"jsonMetadata": {}, | ||
"status": "LABELED", | ||
}, | ||
] | ||
|
||
mock_raw_asset_content = """{ | ||
"prompts": [ | ||
{ | ||
"prompt": "BLABLABLA", | ||
"completions": [ | ||
{ | ||
"content": "response A1" | ||
}, | ||
{ | ||
"content": "response B1" | ||
} | ||
] | ||
}, | ||
{ | ||
"prompt": "BLIBLIBLI", | ||
"completions": [ | ||
{ | ||
"content": "response A2" | ||
}, | ||
{ | ||
"content": "response B2" | ||
} | ||
] | ||
} | ||
], | ||
"type": "markdown", | ||
"version": "0.1" | ||
} | ||
""" | ||
from tests.unit.services.export.fakes.llm_json_interface import mock_json_interface | ||
from tests.unit.services.export.fakes.llm_project_assets import mock_fetch_assets | ||
from tests.unit.services.export.fakes.llm_raw_asset_content import mock_raw_asset_content | ||
|
||
expected_export = [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
mock_json_interface = { | ||
"jobs": { | ||
"CLASSIFICATION_JOB": { | ||
"content": { | ||
"categories": { | ||
"A_BETTER_THAN_B": { | ||
"children": [], | ||
"name": "A better than B", | ||
"id": "category1", | ||
}, | ||
"B_BETTER_THAN_A": { | ||
"children": [], | ||
"name": "B better than A", | ||
"id": "category2", | ||
}, | ||
"TIE": {"children": [], "name": "Tie", "id": "category3"}, | ||
}, | ||
"input": "radio", | ||
}, | ||
"instruction": "Compare", | ||
"mlTask": "CLASSIFICATION", | ||
"required": 0, | ||
"isChild": False, | ||
"isNew": False, | ||
}, | ||
"TRANSCRIPTION_JOB": { | ||
"content": {"input": "markdown"}, | ||
"instruction": "", | ||
"mlTask": "TRANSCRIPTION", | ||
"required": 0, | ||
"isChild": False, | ||
"isNew": False, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
mock_fetch_assets = [ | ||
{ | ||
"labels": [ | ||
{ | ||
"author": { | ||
"id": "user-1", | ||
"email": "[email protected]", | ||
"firstname": "Test", | ||
"lastname": "Admin", | ||
}, | ||
"jsonResponse": { | ||
"CLASSIFICATION_JOB": {"categories": [{"name": "A_BETTER_THAN_B"}]} | ||
}, | ||
"createdAt": "2024-08-05T13:03:00.051Z", | ||
"isLatestLabelForUser": True, | ||
"isSentBackToQueue": False, | ||
"labelType": "DEFAULT", | ||
"modelName": None, | ||
} | ||
], | ||
"content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/01.json", | ||
"externalId": "asset#0", | ||
"jsonMetadata": {}, | ||
"status": "LABELED", | ||
}, | ||
{ | ||
"labels": [ | ||
{ | ||
"author": { | ||
"id": "user-1", | ||
"email": "[email protected]", | ||
"firstname": "Test", | ||
"lastname": "Admin", | ||
}, | ||
"jsonResponse": { | ||
"CLASSIFICATION_JOB": {"categories": [{"name": "B_BETTER_THAN_A"}]} | ||
}, | ||
"createdAt": "2024-08-05T13:03:03.061Z", | ||
"isLatestLabelForUser": True, | ||
"isSentBackToQueue": False, | ||
"labelType": "DEFAULT", | ||
"modelName": None, | ||
} | ||
], | ||
"content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/02.json", | ||
"externalId": "asset#1", | ||
"jsonMetadata": {}, | ||
"status": "LABELED", | ||
}, | ||
{ | ||
"labels": [ | ||
{ | ||
"author": { | ||
"id": "user-1", | ||
"email": "[email protected]", | ||
"firstname": "Test", | ||
"lastname": "Admin", | ||
}, | ||
"jsonResponse": { | ||
"CLASSIFICATION_JOB": {"categories": [{"name": "TIE"}]}, | ||
"TRANSCRIPTION_JOB": {"text": "There is only some formatting changes\n"}, | ||
}, | ||
"createdAt": "2024-08-05T13:03:16.028Z", | ||
"isLatestLabelForUser": True, | ||
"isSentBackToQueue": True, | ||
"labelType": "DEFAULT", | ||
"modelName": None, | ||
} | ||
], | ||
"content": "https://storage.googleapis.com/label-public-staging/demo-projects/LLM/03.json", | ||
"externalId": "asset#2", | ||
"jsonMetadata": {}, | ||
"status": "LABELED", | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
mock_raw_asset_content = """{ | ||
"prompts": [ | ||
{ | ||
"prompt": "BLABLABLA", | ||
"completions": [ | ||
{ | ||
"content": "response A1" | ||
}, | ||
{ | ||
"content": "response B1" | ||
} | ||
] | ||
}, | ||
{ | ||
"prompt": "BLIBLIBLI", | ||
"completions": [ | ||
{ | ||
"content": "response A2" | ||
}, | ||
{ | ||
"content": "response B2" | ||
} | ||
] | ||
} | ||
], | ||
"type": "markdown", | ||
"version": "0.1" | ||
} | ||
""" |
Oops, something went wrong.