kiln-ai 0.15.0__py3-none-any.whl → 0.17.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of kiln-ai might be problematic. Click here for more details.
- kiln_ai/adapters/__init__.py +2 -0
- kiln_ai/adapters/adapter_registry.py +22 -44
- kiln_ai/adapters/chat/__init__.py +8 -0
- kiln_ai/adapters/chat/chat_formatter.py +234 -0
- kiln_ai/adapters/chat/test_chat_formatter.py +131 -0
- kiln_ai/adapters/data_gen/test_data_gen_task.py +19 -6
- kiln_ai/adapters/eval/base_eval.py +8 -6
- kiln_ai/adapters/eval/eval_runner.py +9 -65
- kiln_ai/adapters/eval/g_eval.py +26 -8
- kiln_ai/adapters/eval/test_base_eval.py +166 -15
- kiln_ai/adapters/eval/test_eval_runner.py +3 -0
- kiln_ai/adapters/eval/test_g_eval.py +1 -0
- kiln_ai/adapters/fine_tune/base_finetune.py +2 -2
- kiln_ai/adapters/fine_tune/dataset_formatter.py +153 -197
- kiln_ai/adapters/fine_tune/test_base_finetune.py +10 -10
- kiln_ai/adapters/fine_tune/test_dataset_formatter.py +402 -211
- kiln_ai/adapters/fine_tune/test_fireworks_tinetune.py +3 -3
- kiln_ai/adapters/fine_tune/test_openai_finetune.py +6 -6
- kiln_ai/adapters/fine_tune/test_together_finetune.py +1 -0
- kiln_ai/adapters/fine_tune/test_vertex_finetune.py +4 -4
- kiln_ai/adapters/fine_tune/together_finetune.py +12 -1
- kiln_ai/adapters/ml_model_list.py +556 -45
- kiln_ai/adapters/model_adapters/base_adapter.py +100 -35
- kiln_ai/adapters/model_adapters/litellm_adapter.py +116 -100
- kiln_ai/adapters/model_adapters/litellm_config.py +3 -2
- kiln_ai/adapters/model_adapters/test_base_adapter.py +299 -52
- kiln_ai/adapters/model_adapters/test_litellm_adapter.py +121 -22
- kiln_ai/adapters/model_adapters/test_saving_adapter_results.py +44 -2
- kiln_ai/adapters/model_adapters/test_structured_output.py +48 -18
- kiln_ai/adapters/parsers/base_parser.py +0 -3
- kiln_ai/adapters/parsers/parser_registry.py +5 -3
- kiln_ai/adapters/parsers/r1_parser.py +17 -2
- kiln_ai/adapters/parsers/request_formatters.py +40 -0
- kiln_ai/adapters/parsers/test_parser_registry.py +2 -2
- kiln_ai/adapters/parsers/test_r1_parser.py +44 -1
- kiln_ai/adapters/parsers/test_request_formatters.py +76 -0
- kiln_ai/adapters/prompt_builders.py +14 -17
- kiln_ai/adapters/provider_tools.py +39 -4
- kiln_ai/adapters/repair/test_repair_task.py +27 -5
- kiln_ai/adapters/test_adapter_registry.py +88 -28
- kiln_ai/adapters/test_ml_model_list.py +158 -0
- kiln_ai/adapters/test_prompt_adaptors.py +17 -3
- kiln_ai/adapters/test_prompt_builders.py +27 -19
- kiln_ai/adapters/test_provider_tools.py +130 -12
- kiln_ai/datamodel/__init__.py +2 -2
- kiln_ai/datamodel/datamodel_enums.py +43 -4
- kiln_ai/datamodel/dataset_filters.py +69 -1
- kiln_ai/datamodel/dataset_split.py +4 -0
- kiln_ai/datamodel/eval.py +8 -0
- kiln_ai/datamodel/finetune.py +13 -7
- kiln_ai/datamodel/prompt_id.py +1 -0
- kiln_ai/datamodel/task.py +68 -7
- kiln_ai/datamodel/task_output.py +1 -1
- kiln_ai/datamodel/task_run.py +39 -7
- kiln_ai/datamodel/test_basemodel.py +5 -8
- kiln_ai/datamodel/test_dataset_filters.py +82 -0
- kiln_ai/datamodel/test_dataset_split.py +2 -8
- kiln_ai/datamodel/test_example_models.py +54 -0
- kiln_ai/datamodel/test_models.py +80 -9
- kiln_ai/datamodel/test_task.py +168 -2
- kiln_ai/utils/async_job_runner.py +106 -0
- kiln_ai/utils/config.py +3 -2
- kiln_ai/utils/dataset_import.py +81 -19
- kiln_ai/utils/logging.py +165 -0
- kiln_ai/utils/test_async_job_runner.py +199 -0
- kiln_ai/utils/test_config.py +23 -0
- kiln_ai/utils/test_dataset_import.py +272 -10
- {kiln_ai-0.15.0.dist-info → kiln_ai-0.17.0.dist-info}/METADATA +1 -1
- kiln_ai-0.17.0.dist-info/RECORD +113 -0
- kiln_ai-0.15.0.dist-info/RECORD +0 -104
- {kiln_ai-0.15.0.dist-info → kiln_ai-0.17.0.dist-info}/WHEEL +0 -0
- {kiln_ai-0.15.0.dist-info → kiln_ai-0.17.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -13,11 +13,11 @@ from kiln_ai.adapters.fine_tune.dataset_formatter import DatasetFormat, DatasetF
|
|
|
13
13
|
from kiln_ai.adapters.fine_tune.fireworks_finetune import FireworksFinetune
|
|
14
14
|
from kiln_ai.datamodel import (
|
|
15
15
|
DatasetSplit,
|
|
16
|
-
FinetuneDataStrategy,
|
|
17
16
|
StructuredOutputMode,
|
|
18
17
|
Task,
|
|
19
18
|
)
|
|
20
19
|
from kiln_ai.datamodel import Finetune as FinetuneModel
|
|
20
|
+
from kiln_ai.datamodel.datamodel_enums import ChatStrategy
|
|
21
21
|
from kiln_ai.datamodel.dataset_split import Train80Test20SplitDefinition
|
|
22
22
|
from kiln_ai.utils.config import Config
|
|
23
23
|
|
|
@@ -232,8 +232,8 @@ def mock_task():
|
|
|
232
232
|
@pytest.mark.parametrize(
|
|
233
233
|
"data_strategy,thinking_instructions",
|
|
234
234
|
[
|
|
235
|
-
(
|
|
236
|
-
(
|
|
235
|
+
(ChatStrategy.two_message_cot, "thinking instructions"),
|
|
236
|
+
(ChatStrategy.single_turn, None),
|
|
237
237
|
],
|
|
238
238
|
)
|
|
239
239
|
async def test_generate_and_upload_jsonl_success(
|
|
@@ -12,11 +12,11 @@ from kiln_ai.adapters.fine_tune.dataset_formatter import DatasetFormat, DatasetF
|
|
|
12
12
|
from kiln_ai.adapters.fine_tune.openai_finetune import OpenAIFinetune
|
|
13
13
|
from kiln_ai.datamodel import (
|
|
14
14
|
DatasetSplit,
|
|
15
|
-
FinetuneDataStrategy,
|
|
16
15
|
StructuredOutputMode,
|
|
17
16
|
Task,
|
|
18
17
|
)
|
|
19
18
|
from kiln_ai.datamodel import Finetune as FinetuneModel
|
|
19
|
+
from kiln_ai.datamodel.datamodel_enums import ChatStrategy
|
|
20
20
|
from kiln_ai.datamodel.dataset_split import Train80Test20SplitDefinition
|
|
21
21
|
from kiln_ai.utils.config import Config
|
|
22
22
|
|
|
@@ -35,7 +35,7 @@ def openai_finetune(tmp_path):
|
|
|
35
35
|
system_message="Test system message",
|
|
36
36
|
fine_tune_model_id="ft-123",
|
|
37
37
|
path=tmp_file,
|
|
38
|
-
data_strategy=
|
|
38
|
+
data_strategy=ChatStrategy.single_turn,
|
|
39
39
|
),
|
|
40
40
|
)
|
|
41
41
|
return finetune
|
|
@@ -247,7 +247,7 @@ async def test_generate_and_upload_jsonl_success(
|
|
|
247
247
|
mock_formatter.dump_to_file.assert_called_once_with(
|
|
248
248
|
"train",
|
|
249
249
|
DatasetFormat.OPENAI_CHAT_JSONL,
|
|
250
|
-
|
|
250
|
+
ChatStrategy.single_turn,
|
|
251
251
|
)
|
|
252
252
|
|
|
253
253
|
# Verify file was opened and uploaded
|
|
@@ -299,7 +299,7 @@ async def test_generate_and_upload_jsonl_schema_success(
|
|
|
299
299
|
mock_formatter.dump_to_file.assert_called_once_with(
|
|
300
300
|
"train",
|
|
301
301
|
DatasetFormat.OPENAI_CHAT_JSON_SCHEMA_JSONL,
|
|
302
|
-
|
|
302
|
+
ChatStrategy.single_turn,
|
|
303
303
|
)
|
|
304
304
|
|
|
305
305
|
# Verify file was opened and uploaded
|
|
@@ -555,8 +555,8 @@ async def test_status_updates_latest_status(openai_finetune, mock_response):
|
|
|
555
555
|
@pytest.mark.parametrize(
|
|
556
556
|
"data_strategy,thinking_instructions",
|
|
557
557
|
[
|
|
558
|
-
(
|
|
559
|
-
(
|
|
558
|
+
(ChatStrategy.two_message_cot, "Custom thinking instructions"),
|
|
559
|
+
(ChatStrategy.single_turn, None),
|
|
560
560
|
],
|
|
561
561
|
)
|
|
562
562
|
async def test_generate_and_upload_jsonl_with_data_strategy(
|
|
@@ -183,6 +183,7 @@ async def test_status_job_states(
|
|
|
183
183
|
# Mock the retrieve method of the fine_tuning object
|
|
184
184
|
mock_job = MagicMock()
|
|
185
185
|
mock_job.status = together_status
|
|
186
|
+
mock_job.output_name = None
|
|
186
187
|
mock_together_client.fine_tuning.retrieve.return_value = mock_job
|
|
187
188
|
|
|
188
189
|
status = await together_finetune.status()
|
|
@@ -12,11 +12,11 @@ from kiln_ai.adapters.fine_tune.dataset_formatter import DatasetFormat, DatasetF
|
|
|
12
12
|
from kiln_ai.adapters.fine_tune.vertex_finetune import VertexFinetune
|
|
13
13
|
from kiln_ai.datamodel import (
|
|
14
14
|
DatasetSplit,
|
|
15
|
-
FinetuneDataStrategy,
|
|
16
15
|
StructuredOutputMode,
|
|
17
16
|
Task,
|
|
18
17
|
)
|
|
19
18
|
from kiln_ai.datamodel import Finetune as FinetuneModel
|
|
19
|
+
from kiln_ai.datamodel.datamodel_enums import ChatStrategy
|
|
20
20
|
from kiln_ai.datamodel.dataset_split import Train80Test20SplitDefinition
|
|
21
21
|
from kiln_ai.utils.config import Config
|
|
22
22
|
|
|
@@ -35,7 +35,7 @@ def vertex_finetune(tmp_path):
|
|
|
35
35
|
system_message="Test system message",
|
|
36
36
|
fine_tune_model_id="ft-123",
|
|
37
37
|
path=tmp_file,
|
|
38
|
-
data_strategy=
|
|
38
|
+
data_strategy=ChatStrategy.single_turn,
|
|
39
39
|
),
|
|
40
40
|
)
|
|
41
41
|
return finetune
|
|
@@ -252,8 +252,8 @@ async def test_status_model_id_update_exception(vertex_finetune, mock_response):
|
|
|
252
252
|
@pytest.mark.parametrize(
|
|
253
253
|
"data_strategy,thinking_instructions",
|
|
254
254
|
[
|
|
255
|
-
(
|
|
256
|
-
(
|
|
255
|
+
(ChatStrategy.two_message_cot, "Custom thinking instructions"),
|
|
256
|
+
(ChatStrategy.single_turn, None),
|
|
257
257
|
],
|
|
258
258
|
)
|
|
259
259
|
async def test_generate_and_upload_jsonl(
|
|
@@ -66,6 +66,12 @@ class TogetherFinetune(BaseFinetuneAdapter):
|
|
|
66
66
|
# retrieve the fine-tuning job
|
|
67
67
|
together_finetune = self.client.fine_tuning.retrieve(id=fine_tuning_job_id)
|
|
68
68
|
|
|
69
|
+
# update the fine tune model ID if it has changed (sometimes it's not set at training time)
|
|
70
|
+
if self.datamodel.fine_tune_model_id != together_finetune.output_name:
|
|
71
|
+
self.datamodel.fine_tune_model_id = together_finetune.output_name
|
|
72
|
+
if self.datamodel.path:
|
|
73
|
+
self.datamodel.save_to_file()
|
|
74
|
+
|
|
69
75
|
status = together_finetune.status
|
|
70
76
|
if status in _pending_statuses:
|
|
71
77
|
return FineTuneStatus(
|
|
@@ -135,8 +141,13 @@ class TogetherFinetune(BaseFinetuneAdapter):
|
|
|
135
141
|
**self._build_finetune_parameters(),
|
|
136
142
|
)
|
|
137
143
|
|
|
138
|
-
# 2 different IDs, output_name is the name of the model that results from the fine-tune job, the
|
|
144
|
+
# 2 different IDs, output_name is the name of the model that results from the fine-tune job, while the id is the ID of the fine-tune job itself
|
|
145
|
+
if not together_finetune.id:
|
|
146
|
+
raise ValueError(
|
|
147
|
+
"Together failed to return a fine-tune job ID. While tuning job was dispatched, Kiln never received the ID so won't be able to reference it. Check for errors before dispatching more jobs."
|
|
148
|
+
)
|
|
139
149
|
self.datamodel.provider_id = together_finetune.id
|
|
150
|
+
# Output name is sometimes returned here, and save it if it is. But it might be populated later by status call
|
|
140
151
|
self.datamodel.fine_tune_model_id = together_finetune.output_name
|
|
141
152
|
|
|
142
153
|
if self.datamodel.path:
|