kiln-ai 0.6.1__py3-none-any.whl → 0.7.1__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.

Files changed (44) hide show
  1. kiln_ai/adapters/__init__.py +2 -0
  2. kiln_ai/adapters/adapter_registry.py +19 -0
  3. kiln_ai/adapters/data_gen/test_data_gen_task.py +29 -21
  4. kiln_ai/adapters/fine_tune/__init__.py +14 -0
  5. kiln_ai/adapters/fine_tune/base_finetune.py +186 -0
  6. kiln_ai/adapters/fine_tune/dataset_formatter.py +187 -0
  7. kiln_ai/adapters/fine_tune/finetune_registry.py +11 -0
  8. kiln_ai/adapters/fine_tune/fireworks_finetune.py +308 -0
  9. kiln_ai/adapters/fine_tune/openai_finetune.py +205 -0
  10. kiln_ai/adapters/fine_tune/test_base_finetune.py +290 -0
  11. kiln_ai/adapters/fine_tune/test_dataset_formatter.py +342 -0
  12. kiln_ai/adapters/fine_tune/test_fireworks_tinetune.py +455 -0
  13. kiln_ai/adapters/fine_tune/test_openai_finetune.py +503 -0
  14. kiln_ai/adapters/langchain_adapters.py +103 -13
  15. kiln_ai/adapters/ml_model_list.py +239 -303
  16. kiln_ai/adapters/ollama_tools.py +115 -0
  17. kiln_ai/adapters/provider_tools.py +308 -0
  18. kiln_ai/adapters/repair/repair_task.py +4 -2
  19. kiln_ai/adapters/repair/test_repair_task.py +6 -11
  20. kiln_ai/adapters/test_langchain_adapter.py +229 -18
  21. kiln_ai/adapters/test_ollama_tools.py +42 -0
  22. kiln_ai/adapters/test_prompt_adaptors.py +7 -5
  23. kiln_ai/adapters/test_provider_tools.py +531 -0
  24. kiln_ai/adapters/test_structured_output.py +22 -43
  25. kiln_ai/datamodel/__init__.py +287 -24
  26. kiln_ai/datamodel/basemodel.py +122 -38
  27. kiln_ai/datamodel/model_cache.py +116 -0
  28. kiln_ai/datamodel/registry.py +31 -0
  29. kiln_ai/datamodel/test_basemodel.py +167 -4
  30. kiln_ai/datamodel/test_dataset_split.py +234 -0
  31. kiln_ai/datamodel/test_example_models.py +12 -0
  32. kiln_ai/datamodel/test_model_cache.py +244 -0
  33. kiln_ai/datamodel/test_models.py +215 -1
  34. kiln_ai/datamodel/test_registry.py +96 -0
  35. kiln_ai/utils/config.py +14 -1
  36. kiln_ai/utils/name_generator.py +125 -0
  37. kiln_ai/utils/test_name_geneator.py +47 -0
  38. kiln_ai-0.7.1.dist-info/METADATA +237 -0
  39. kiln_ai-0.7.1.dist-info/RECORD +58 -0
  40. {kiln_ai-0.6.1.dist-info → kiln_ai-0.7.1.dist-info}/WHEEL +1 -1
  41. kiln_ai/adapters/test_ml_model_list.py +0 -181
  42. kiln_ai-0.6.1.dist-info/METADATA +0 -88
  43. kiln_ai-0.6.1.dist-info/RECORD +0 -37
  44. {kiln_ai-0.6.1.dist-info → kiln_ai-0.7.1.dist-info}/licenses/LICENSE.txt +0 -0
@@ -0,0 +1,125 @@
1
+ from random import choice
2
+ from typing import List
3
+
4
+ ADJECTIVES: List[str] = [
5
+ "Curious",
6
+ "Playful",
7
+ "Mighty",
8
+ "Gentle",
9
+ "Clever",
10
+ "Brave",
11
+ "Cosmic",
12
+ "Dancing",
13
+ "Electric",
14
+ "Fierce",
15
+ "Glowing",
16
+ "Hidden",
17
+ "Infinite",
18
+ "Jolly",
19
+ "Magical",
20
+ "Ancient",
21
+ "Blazing",
22
+ "Celestial",
23
+ "Dazzling",
24
+ "Emerald",
25
+ "Floating",
26
+ "Graceful",
27
+ "Harmonious",
28
+ "Icy",
29
+ "Jade",
30
+ "Kinetic",
31
+ "Luminous",
32
+ "Mystic",
33
+ "Noble",
34
+ "Opal",
35
+ "Peaceful",
36
+ "Quantum",
37
+ "Radiant",
38
+ "Silent",
39
+ "Thundering",
40
+ "Untamed",
41
+ "Vibrant",
42
+ "Whispering",
43
+ "Xenial",
44
+ "Yearning",
45
+ "Zealous",
46
+ "Astral",
47
+ "Boundless",
48
+ "Crimson",
49
+ "Divine",
50
+ "Ethereal",
51
+ "Fabled",
52
+ "Golden",
53
+ "Heroic",
54
+ "Imperial",
55
+ ]
56
+
57
+ NOUNS: List[str] = [
58
+ "Penguin",
59
+ "Dragon",
60
+ "Phoenix",
61
+ "Tiger",
62
+ "Dolphin",
63
+ "Mountain",
64
+ "River",
65
+ "Forest",
66
+ "Cloud",
67
+ "Star",
68
+ "Crystal",
69
+ "Garden",
70
+ "Ocean",
71
+ "Falcon",
72
+ "Wizard",
73
+ "Aurora",
74
+ "Badger",
75
+ "Comet",
76
+ "Dryad",
77
+ "Eagle",
78
+ "Fox",
79
+ "Griffin",
80
+ "Harbor",
81
+ "Island",
82
+ "Jaguar",
83
+ "Knight",
84
+ "Lion",
85
+ "Mermaid",
86
+ "Nebula",
87
+ "Owl",
88
+ "Panther",
89
+ "Quasar",
90
+ "Raven",
91
+ "Serpent",
92
+ "Tempest",
93
+ "Unicorn",
94
+ "Valley",
95
+ "Wolf",
96
+ "Sphinx",
97
+ "Yeti",
98
+ "Zenith",
99
+ "Archer",
100
+ "Beacon",
101
+ "Cascade",
102
+ "Dreamer",
103
+ "Echo",
104
+ "Flame",
105
+ "Glacier",
106
+ "Horizon",
107
+ "Ivy",
108
+ ]
109
+
110
+
111
+ def generate_memorable_name() -> str:
112
+ """
113
+ Generates a memorable two-word name combining a random adjective and noun.
114
+
115
+ Returns:
116
+ str: A memorable name in the format "Adjective Noun"
117
+
118
+ Example:
119
+ >>> generate_memorable_name()
120
+ 'Cosmic Dragon'
121
+ """
122
+ adjective = choice(ADJECTIVES)
123
+ noun = choice(NOUNS)
124
+
125
+ return f"{adjective} {noun}"
@@ -0,0 +1,47 @@
1
+ from kiln_ai.utils.name_generator import ADJECTIVES, NOUNS, generate_memorable_name
2
+
3
+
4
+ def test_generate_memorable_name_format():
5
+ """Test that generated name follows the expected format."""
6
+ name = generate_memorable_name()
7
+
8
+ # Check that we get exactly two words
9
+ words = name.split()
10
+ assert len(words) == 2
11
+
12
+ # Check that first word is an adjective and second word is a noun
13
+ assert words[0] in ADJECTIVES
14
+ assert words[1] in NOUNS
15
+
16
+
17
+ def test_generate_memorable_name_randomness():
18
+ """Test that the function generates different names."""
19
+ names = {generate_memorable_name() for _ in range(100)}
20
+
21
+ # With 50 adjectives and 50 nouns, we should get multiple unique combinations
22
+ # in 100 tries. Using 50 as a reasonable lower bound.
23
+ assert len(names) > 50
24
+
25
+
26
+ def test_generate_memorable_name_string_type():
27
+ """Test that the generated name is a string."""
28
+ name = generate_memorable_name()
29
+ assert isinstance(name, str)
30
+
31
+
32
+ def test_word_lists_not_empty():
33
+ """Test that our word lists contain entries."""
34
+ assert len(ADJECTIVES) > 0
35
+ assert len(NOUNS) > 0
36
+
37
+
38
+ def test_word_lists_are_strings():
39
+ """Test that all entries in word lists are strings."""
40
+ assert all(isinstance(word, str) for word in ADJECTIVES)
41
+ assert all(isinstance(word, str) for word in NOUNS)
42
+
43
+
44
+ def test_word_lists_no_duplicates():
45
+ """Test that word lists don't contain duplicates."""
46
+ assert len(ADJECTIVES) == len(set(ADJECTIVES))
47
+ assert len(NOUNS) == len(set(NOUNS))
@@ -0,0 +1,237 @@
1
+ Metadata-Version: 2.4
2
+ Name: kiln-ai
3
+ Version: 0.7.1
4
+ Summary: Kiln AI
5
+ Project-URL: Homepage, https://getkiln.ai
6
+ Project-URL: Repository, https://github.com/Kiln-AI/kiln
7
+ Project-URL: Documentation, https://kiln-ai.github.io/Kiln/kiln_core_docs/kiln_ai.html
8
+ Project-URL: Issues, https://github.com/Kiln-AI/kiln/issues
9
+ Author-email: "Steve Cosman, Chesterfield Laboratories Inc" <scosman@users.noreply.github.com>
10
+ License-File: LICENSE.txt
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: coverage>=7.6.4
18
+ Requires-Dist: jsonschema>=4.23.0
19
+ Requires-Dist: langchain-aws>=0.2.4
20
+ Requires-Dist: langchain-fireworks>=0.2.5
21
+ Requires-Dist: langchain-groq>=0.2.0
22
+ Requires-Dist: langchain-ollama>=0.2.0
23
+ Requires-Dist: langchain-openai>=0.2.4
24
+ Requires-Dist: langchain>=0.3.5
25
+ Requires-Dist: openai>=1.53.0
26
+ Requires-Dist: pdoc>=15.0.0
27
+ Requires-Dist: pydantic>=2.9.2
28
+ Requires-Dist: pytest-benchmark>=5.1.0
29
+ Requires-Dist: pytest-cov>=6.0.0
30
+ Requires-Dist: pyyaml>=6.0.2
31
+ Requires-Dist: typing-extensions>=4.12.2
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Kiln AI Core Library
35
+
36
+ <p align="center">
37
+ <picture>
38
+ <img width="205" alt="Kiln AI Logo" src="https://github.com/user-attachments/assets/5fbcbdf7-1feb-45c9-bd73-99a46dd0a47f">
39
+ </picture>
40
+ </p>
41
+
42
+ [![PyPI - Version](https://img.shields.io/pypi/v/kiln-ai.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.org/project/kiln-ai)
43
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/kiln-ai.svg)](https://pypi.org/project/kiln-ai)
44
+ [![Docs](https://img.shields.io/badge/docs-pdoc-blue)](https://kiln-ai.github.io/Kiln/kiln_core_docs/index.html)
45
+
46
+ ---
47
+
48
+ ## Installation
49
+
50
+ ```console
51
+ pip install kiln_ai
52
+ ```
53
+
54
+ ## About
55
+
56
+ This package is the Kiln AI core library. There is also a separate desktop application and server package. Learn more about Kiln AI at [getkiln.ai](https://getkiln.ai) and on Github: [github.com/Kiln-AI/kiln](https://github.com/Kiln-AI/kiln).
57
+
58
+ # Guide: Using the Kiln Python Library
59
+
60
+ In this guide we'll walk common examples of how to use the library.
61
+
62
+ ## Documentation
63
+
64
+ The library has a [comprehensive set of docs](https://kiln-ai.github.io/Kiln/kiln_core_docs/index.html).
65
+
66
+ ## Table of Contents
67
+
68
+ - [Using the Kiln Data Model](#using-the-kiln-data-model)
69
+ - [Understanding the Kiln Data Model](#understanding-the-kiln-data-model)
70
+ - [Datamodel Overview](#datamodel-overview)
71
+ - [Load a Project](#load-a-project)
72
+ - [Load an Existing Dataset into a Kiln Task Dataset](#load-an-existing-dataset-into-a-kiln-task-dataset)
73
+ - [Using your Kiln Dataset in a Notebook or Project](#using-your-kiln-dataset-in-a-notebook-or-project)
74
+ - [Using Kiln Dataset in Pandas](#using-kiln-dataset-in-pandas)
75
+ - [Advanced Usage](#advanced-usage)
76
+
77
+ ## Installation
78
+
79
+ ```bash
80
+ pip install kiln-ai
81
+ ```
82
+
83
+ ## Using the Kiln Data Model
84
+
85
+ ### Understanding the Kiln Data Model
86
+
87
+ Kiln projects are simply a directory of files (mostly JSON files with the extension `.kiln`) that describe your project, including tasks, runs, and other data.
88
+
89
+ This dataset design was chosen for several reasons:
90
+
91
+ - Git compatibility: Kiln project folders are easy to collaborate on in git. The filenames use unique IDs to avoid conflicts and allow many people to work in parallel. The files are small and easy to compare using standard diff tools.
92
+ - JSON allows you to easily load and manipulate the data using standard tools (pandas, polars, etc)
93
+
94
+ The Kiln Python library provides a set of Python classes that which help you easily interact with your Kiln dataset. Using the library to load and manipulate your dataset is the fastest way to get started, and will guarantees you don't insert any invalid data into your dataset. There's extensive validation when using the library, so we recommend using it to load and manipulate your dataset over direct JSON manipulation.
95
+
96
+ ### Datamodel Overview
97
+
98
+ - Project: a Kiln Project that organizes related tasks
99
+ - Task: a specific task including prompt instructions, input/output schemas, and requirements
100
+ - TaskRun: a sample (run) of a task including input, output and human rating information
101
+ - DatasetSplit: a frozen collection of task runs divided into train/test/validation splits
102
+ - Finetune: configuration and status tracking for fine-tuning models on task data
103
+
104
+ ### Load a Project
105
+
106
+ Assuming you've created a project in the Kiln UI, you'll have a `project.kiln` file in your `~/Kiln Projects/Project Name` directory.
107
+
108
+ ```python
109
+ from kiln_ai.datamodel import Project
110
+
111
+ project = Project.load_from_file("path/to/your/project.kiln")
112
+ print("Project: ", project.name, " - ", project.description)
113
+
114
+ # List all tasks in the project, and their dataset sizes
115
+ tasks = project.tasks()
116
+ for task in tasks:
117
+ print("Task: ", task.name, " - ", task.description)
118
+ print("Total dataset size:", len(task.runs()))
119
+ ```
120
+
121
+ ### Load an Existing Dataset into a Kiln Task Dataset
122
+
123
+ If you already have a dataset in a file, you can load it into a Kiln project.
124
+
125
+ **Important**: Kiln will validate the input and output schemas, and ensure that each datapoint in the dataset is valid for this task.
126
+
127
+ - Plaintext input/output: ensure "output_json_schema" and "input_json_schema" not set in your Task definition.
128
+ - JSON input/output: ensure "output_json_schema" and "input_json_schema" are valid JSON schemas in your Task definition. Every datapoint in the dataset must be valid JSON fitting the schema.
129
+
130
+ Here's a simple example of how to load a dataset into a Kiln task:
131
+
132
+ ```python
133
+
134
+ import kiln_ai
135
+ import kiln_ai.datamodel
136
+
137
+ # Created a project and task via the UI and put its path here
138
+ task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln"
139
+ task = kiln_ai.datamodel.Task.load_from_file(task_path)
140
+
141
+ # Add data to the task - loop over you dataset and run this for each item
142
+ item = kiln_ai.datamodel.TaskRun(
143
+ parent=task,
144
+ input='{"topic": "AI"}',
145
+ output=kiln_ai.datamodel.TaskOutput(
146
+ output='{"setup": "What is AI?", "punchline": "content_here"}',
147
+ ),
148
+ )
149
+ item.save_to_file()
150
+ print("Saved item to file: ", item.path)
151
+ ```
152
+
153
+ And here's a more complex example of how to load a dataset into a Kiln task. This example sets the source of the data (human in this case, but you can also set it be be synthetic), the created_by property, and a 5-star rating.
154
+
155
+ ```python
156
+ import kiln_ai
157
+ import kiln_ai.datamodel
158
+
159
+ # Created a project and task via the UI and put its path here
160
+ task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln"
161
+ task = kiln_ai.datamodel.Task.load_from_file(task_path)
162
+
163
+ # Add data to the task - loop over you dataset and run this for each item
164
+ item = kiln_ai.datamodel.TaskRun(
165
+ parent=task,
166
+ input='{"topic": "AI"}',
167
+ input_source=kiln_ai.datamodel.DataSource(
168
+ type=kiln_ai.datamodel.DataSourceType.human,
169
+ properties={"created_by": "John Doe"},
170
+ ),
171
+ output=kiln_ai.datamodel.TaskOutput(
172
+ output='{"setup": "What is AI?", "punchline": "content_here"}',
173
+ source=kiln_ai.datamodel.DataSource(
174
+ type=kiln_ai.datamodel.DataSourceType.human,
175
+ properties={"created_by": "Jane Doe"},
176
+ ),
177
+ rating=kiln_ai.datamodel.TaskOutputRating(score=5,type="five_star"),
178
+ ),
179
+ )
180
+ item.save_to_file()
181
+ print("Saved item to file: ", item.path)
182
+ ```
183
+
184
+ ### Using your Kiln Dataset in a Notebook or Project
185
+
186
+ You can use your Kiln dataset in a notebook or project by loading the dataset into a pandas dataframe.
187
+
188
+ ```python
189
+ import kiln_ai
190
+ import kiln_ai.datamodel
191
+
192
+ # Created a project and task via the UI and put its path here
193
+ task_path = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator/task.kiln"
194
+ task = kiln_ai.datamodel.Task.load_from_file(task_path)
195
+
196
+ runs = task.runs()
197
+ for run in runs:
198
+ print(f"Input: {run.input}")
199
+ print(f"Output: {run.output.output}")
200
+
201
+ print(f"Total runs: {len(runs)}")
202
+ ```
203
+
204
+ ### Using Kiln Dataset in Pandas
205
+
206
+ You can also use your Kiln dataset in a pandas dataframe, or a similar script for other tools like polars.
207
+
208
+ ```python
209
+ import glob
210
+ import json
211
+ import pandas as pd
212
+ from pathlib import Path
213
+
214
+ task_dir = "/Users/youruser/Kiln Projects/test project/tasks/632780983478 - Joke Generator"
215
+ dataitem_glob = task_dir + "/runs/*/task_run.kiln"
216
+
217
+ dfs = []
218
+ for file in glob.glob(dataitem_glob):
219
+ js = json.loads(Path(file).read_text())
220
+
221
+ df = pd.DataFrame([{
222
+ "input": js["input"],
223
+ "output": js["output"]["output"],
224
+ }])
225
+
226
+ # Alternatively: you can use pd.json_normalize(js) to get the full json structure
227
+ # df = pd.json_normalize(js)
228
+ dfs.append(df)
229
+ final_df = pd.concat(dfs, ignore_index=True)
230
+ print(final_df)
231
+ ```
232
+
233
+ ### Advanced Usage
234
+
235
+ The library can do a lot more than the examples we've shown here.
236
+
237
+ See the [docs](https://kiln-ai.github.io/Kiln/kiln_core_docs/index.html) for more information.
@@ -0,0 +1,58 @@
1
+ kiln_ai/__init__.py,sha256=Sc4z8LRVFMwJUoc_DPVUriSXTZ6PO9MaJ80PhRbKyB8,34
2
+ kiln_ai/adapters/__init__.py,sha256=8-YlnTh3gsaPeEArFVLIqGE7-tbssI42fub4OQBp_DA,970
3
+ kiln_ai/adapters/adapter_registry.py,sha256=EnB0rUIZ0KbBd2nxkNjwUqOpldwqPDyJ9LzIQoDl2GU,634
4
+ kiln_ai/adapters/base_adapter.py,sha256=E_RfXxzEhW-i066xOhZdPuTM7OPKQv70hDpfMsxfYEs,6145
5
+ kiln_ai/adapters/langchain_adapters.py,sha256=NeTZ8WbQTnVu8rtFX6AwkdjFj2ihyhe_vxNxM-_v2yE,10584
6
+ kiln_ai/adapters/ml_model_list.py,sha256=jEayUwDMYjMJTEL5fJ4jKacWR0OKkQ64q4bL10fnMsE,25062
7
+ kiln_ai/adapters/ollama_tools.py,sha256=0Of6ySbJ2d4j--9laOL6QKgRUQSrqX8dJUIrz20n59s,3561
8
+ kiln_ai/adapters/prompt_builders.py,sha256=Mdu-f1mC9hWIDwoF7Qwd9F99GDx6oNGvtEZN-SrOsNM,10325
9
+ kiln_ai/adapters/provider_tools.py,sha256=Y694_oDm5wKs-WGtnI5FAh1H_wgs0EXUqEcr5rVA6SY,10768
10
+ kiln_ai/adapters/test_langchain_adapter.py,sha256=QiVdCUJJ_uEzD0uA0jYMC3ZO4NTGJLm9iWTwvQfdFxI,12037
11
+ kiln_ai/adapters/test_ollama_tools.py,sha256=2KwYVaj3ySV3ld-z51TCGbJEMdb3MZj2eoEicIWz3Q4,2552
12
+ kiln_ai/adapters/test_prompt_adaptors.py,sha256=Mc0oSYgDLxfP2u3GVR_iDWaYctTQ8Ug1u6UGvWA90lM,7494
13
+ kiln_ai/adapters/test_prompt_builders.py,sha256=sU0bSBZa9Y4Q-mmkDf3HbQ0MNSWk5o9bC9sNgtnBokk,14598
14
+ kiln_ai/adapters/test_provider_tools.py,sha256=b9CDC-Cul2WHoVmON1IOp6BI5jiJNqJCC0rnr1Fm8P8,17468
15
+ kiln_ai/adapters/test_saving_adapter_results.py,sha256=SYYh2xY1zmeKhFHfWAuEY4pEiLd8SitSV5ewGOTmaOI,6447
16
+ kiln_ai/adapters/test_structured_output.py,sha256=9Mgng-HOXiZ_WcJG5cpMWhtsdJt8Rn-7qIouBWvWVoU,9324
17
+ kiln_ai/adapters/data_gen/__init__.py,sha256=QTZWaf7kq5BorhPvexJfwDEKmjRmIbhwW9ei8LW2SIs,276
18
+ kiln_ai/adapters/data_gen/data_gen_prompts.py,sha256=kudjHnAz7L3q0k_NLyTlaIV7M0uRFrxXNcfcnjOE2uc,5810
19
+ kiln_ai/adapters/data_gen/data_gen_task.py,sha256=vwjC47YDrsl4GtBJpK6FWh07TGd8CalhZOX4p4YBX8w,5904
20
+ kiln_ai/adapters/data_gen/test_data_gen_task.py,sha256=TC_n1iWgfLp87q7eNE3ZunVCuk_J25vfw-ohi2qtnp0,9668
21
+ kiln_ai/adapters/fine_tune/__init__.py,sha256=DxdTR60chwgck1aEoVYWyfWi6Ed2ZkdJj0lar-SEAj4,257
22
+ kiln_ai/adapters/fine_tune/base_finetune.py,sha256=-3hyWZXImJomaZeAME6mxbjifQDAn7hwlgTm8VVkxkg,5861
23
+ kiln_ai/adapters/fine_tune/dataset_formatter.py,sha256=DzmUaCaUalTYaX2aNtnb_oucb5ZghI13RDVwtxECMUU,6340
24
+ kiln_ai/adapters/fine_tune/finetune_registry.py,sha256=H1B-opCTlIyd9JlIFTKsY_ctxUX9ziEc49_gnmg1SZg,483
25
+ kiln_ai/adapters/fine_tune/fireworks_finetune.py,sha256=B5o_-A0_Y_QYtgUXZWhKAjR1MeCXvZWz5scZZuK3pMg,13303
26
+ kiln_ai/adapters/fine_tune/openai_finetune.py,sha256=WJKczDN7CA1TJnIokzZu7hbcZiOv9JIRA1scv1zDe8o,8312
27
+ kiln_ai/adapters/fine_tune/test_base_finetune.py,sha256=YOCdQCL5Q0kpBiaU3hccafknCg0kIFRyp16lttR2Io0,9843
28
+ kiln_ai/adapters/fine_tune/test_dataset_formatter.py,sha256=7atbHb4kFtgSmHQMNrSnNpH2ZO8drpnfwKWCsx1p8mM,11127
29
+ kiln_ai/adapters/fine_tune/test_fireworks_tinetune.py,sha256=Y6r5BxsevFeEUHJikfFLeeG6fbPvLOxQpqIMpn-SpvU,15272
30
+ kiln_ai/adapters/fine_tune/test_openai_finetune.py,sha256=EF-f0JbVaPiVXF0eBYbwTKdi5thA45s-XbVB0iUBI00,16629
31
+ kiln_ai/adapters/repair/__init__.py,sha256=dOO9MEpEhjiwzDVFg3MNfA2bKMPlax9iekDatpTkX8E,217
32
+ kiln_ai/adapters/repair/repair_task.py,sha256=L7WTFEpfaGpWXHPQf7BTNL0wiDPbeBIVqn7qNV_SeZc,3354
33
+ kiln_ai/adapters/repair/test_repair_task.py,sha256=JBcyqyQYWniiUo4FSle9kUEsnbTsl5JN1LTRN1SRnrE,7940
34
+ kiln_ai/datamodel/__init__.py,sha256=qavy8MSzO2n9O5KMrMHXkmj2nG949_vK4Q_Y4oSiuqw,24390
35
+ kiln_ai/datamodel/basemodel.py,sha256=H2e_wvhoqqSJLz96xj9uVG-nXp5bgiuPwxJXRI4qZuU,21301
36
+ kiln_ai/datamodel/json_schema.py,sha256=l4BIq1ItLHgcSHqsqDOchegLLHY48U4yR0SP2aMb4i0,2449
37
+ kiln_ai/datamodel/model_cache.py,sha256=d8VjPp0p5BhrGSkx9soKyxO6VWW-bcesNSJI21ySvmA,4369
38
+ kiln_ai/datamodel/registry.py,sha256=XwGFXJFKZtOpR1Z9ven6SftggfADdZRm8TFxCEVtfUQ,957
39
+ kiln_ai/datamodel/test_basemodel.py,sha256=r40jWaW1073ZdIhHe-GHFE8jJDD9ocauItInOsK8pWU,15234
40
+ kiln_ai/datamodel/test_dataset_split.py,sha256=aBjHVyTdt4mWXEKBkvvchEEZSj8jUwhXRZ37LbBxTi4,7265
41
+ kiln_ai/datamodel/test_datasource.py,sha256=GAiZz31qezVVPwFqnt8wHMu15WvtlV89jw8C1Ue6YNI,3165
42
+ kiln_ai/datamodel/test_example_models.py,sha256=9Jhc0bvbM4hCjJGiQNgWH5rwyIsGuneAD8h4o1P3zAY,20356
43
+ kiln_ai/datamodel/test_json_schema.py,sha256=vdLnTQxxrcmuSrf6iOmkrmpfh7JnxqIw4B4dbDAAcZ4,3199
44
+ kiln_ai/datamodel/test_model_cache.py,sha256=9HvK2etVZJyepdlRz5ja7u1CnyzhsV4_BupJF77yBxE,7285
45
+ kiln_ai/datamodel/test_models.py,sha256=-ygQe8XeiZcZJxaffgK5KudRzHXs52ZDEDUSoz8B7eI,13665
46
+ kiln_ai/datamodel/test_nested_save.py,sha256=xciCddqvPyKyoyjC5Lx_3Kh1t4LJv1xYRAPazR3SRcs,5588
47
+ kiln_ai/datamodel/test_output_rating.py,sha256=iw7fVUAPORA-0-VFiikZV3NDycGFaFMHSX1a38t_aQA,2647
48
+ kiln_ai/datamodel/test_registry.py,sha256=PhS4anLi5Bf_023obuTlO5DALhtPB8WIc_bX12Yg6Po,2705
49
+ kiln_ai/utils/__init__.py,sha256=PTD0MwBCKAMIOGsTAwsFaJOusTJJoRFTfOGqRvCaU-E,142
50
+ kiln_ai/utils/config.py,sha256=BZpARYTcK0vNGo_h-0Fjp9aP-1xZYAGEuYS0HdBWWHA,5946
51
+ kiln_ai/utils/formatting.py,sha256=VtB9oag0lOGv17dwT7OPX_3HzBfaU9GsLH-iLete0yM,97
52
+ kiln_ai/utils/name_generator.py,sha256=v26TgpCwQbhQFcZvzgjZvURinjrOyyFhxpsI6NQrHKc,1914
53
+ kiln_ai/utils/test_config.py,sha256=pTYItz5WD15rTRdxKE7vszXF_mb-dik2qrFWzkVemEY,7671
54
+ kiln_ai/utils/test_name_geneator.py,sha256=9-hSTBshyakqlPbFnNcggwLrL7lcPTitauBYHg9jFWI,1513
55
+ kiln_ai-0.7.1.dist-info/METADATA,sha256=Hl--1C_wZrj_ui9WByLBgjrSzielnezjX8CR7JCJboQ,9050
56
+ kiln_ai-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
57
+ kiln_ai-0.7.1.dist-info/licenses/LICENSE.txt,sha256=_NA5pnTYgRRr4qH6lE3X-TuZJ8iRcMUi5ASoGr-lEx8,1209
58
+ kiln_ai-0.7.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,181 +0,0 @@
1
- import json
2
- from unittest.mock import patch
3
-
4
- import pytest
5
-
6
- from kiln_ai.adapters.ml_model_list import (
7
- ModelName,
8
- ModelProviderName,
9
- OllamaConnection,
10
- check_provider_warnings,
11
- get_model_and_provider,
12
- ollama_model_supported,
13
- parse_ollama_tags,
14
- provider_name_from_id,
15
- provider_warnings,
16
- )
17
-
18
-
19
- @pytest.fixture
20
- def mock_config():
21
- with patch("kiln_ai.adapters.ml_model_list.get_config_value") as mock:
22
- yield mock
23
-
24
-
25
- def test_check_provider_warnings_no_warning(mock_config):
26
- mock_config.return_value = "some_value"
27
-
28
- # This should not raise an exception
29
- check_provider_warnings(ModelProviderName.amazon_bedrock)
30
-
31
-
32
- def test_check_provider_warnings_missing_key(mock_config):
33
- mock_config.return_value = None
34
-
35
- with pytest.raises(ValueError) as exc_info:
36
- check_provider_warnings(ModelProviderName.amazon_bedrock)
37
-
38
- assert provider_warnings[ModelProviderName.amazon_bedrock].message in str(
39
- exc_info.value
40
- )
41
-
42
-
43
- def test_check_provider_warnings_unknown_provider():
44
- # This should not raise an exception, as no settings are required for unknown providers
45
- check_provider_warnings("unknown_provider")
46
-
47
-
48
- @pytest.mark.parametrize(
49
- "provider_name",
50
- [
51
- ModelProviderName.amazon_bedrock,
52
- ModelProviderName.openrouter,
53
- ModelProviderName.groq,
54
- ModelProviderName.openai,
55
- ],
56
- )
57
- def test_check_provider_warnings_all_providers(mock_config, provider_name):
58
- mock_config.return_value = None
59
-
60
- with pytest.raises(ValueError) as exc_info:
61
- check_provider_warnings(provider_name)
62
-
63
- assert provider_warnings[provider_name].message in str(exc_info.value)
64
-
65
-
66
- def test_check_provider_warnings_partial_keys_set(mock_config):
67
- def mock_get(key):
68
- return "value" if key == "bedrock_access_key" else None
69
-
70
- mock_config.side_effect = mock_get
71
-
72
- with pytest.raises(ValueError) as exc_info:
73
- check_provider_warnings(ModelProviderName.amazon_bedrock)
74
-
75
- assert provider_warnings[ModelProviderName.amazon_bedrock].message in str(
76
- exc_info.value
77
- )
78
-
79
-
80
- def test_provider_name_from_id_unknown_provider():
81
- assert (
82
- provider_name_from_id("unknown_provider")
83
- == "Unknown provider: unknown_provider"
84
- )
85
-
86
-
87
- def test_provider_name_from_id_case_sensitivity():
88
- assert (
89
- provider_name_from_id(ModelProviderName.amazon_bedrock.upper())
90
- == "Unknown provider: AMAZON_BEDROCK"
91
- )
92
-
93
-
94
- @pytest.mark.parametrize(
95
- "provider_id, expected_name",
96
- [
97
- (ModelProviderName.amazon_bedrock, "Amazon Bedrock"),
98
- (ModelProviderName.openrouter, "OpenRouter"),
99
- (ModelProviderName.groq, "Groq"),
100
- (ModelProviderName.ollama, "Ollama"),
101
- (ModelProviderName.openai, "OpenAI"),
102
- ],
103
- )
104
- def test_provider_name_from_id_parametrized(provider_id, expected_name):
105
- assert provider_name_from_id(provider_id) == expected_name
106
-
107
-
108
- def test_parse_ollama_tags_no_models():
109
- json_response = '{"models":[{"name":"phi3.5:latest","model":"phi3.5:latest","modified_at":"2024-10-02T12:04:35.191519822-04:00","size":2176178843,"digest":"61819fb370a3c1a9be6694869331e5f85f867a079e9271d66cb223acb81d04ba","details":{"parent_model":"","format":"gguf","family":"phi3","families":["phi3"],"parameter_size":"3.8B","quantization_level":"Q4_0"}},{"name":"gemma2:2b","model":"gemma2:2b","modified_at":"2024-09-09T16:46:38.64348929-04:00","size":1629518495,"digest":"8ccf136fdd5298f3ffe2d69862750ea7fb56555fa4d5b18c04e3fa4d82ee09d7","details":{"parent_model":"","format":"gguf","family":"gemma2","families":["gemma2"],"parameter_size":"2.6B","quantization_level":"Q4_0"}},{"name":"llama3.1:latest","model":"llama3.1:latest","modified_at":"2024-09-01T17:19:43.481523695-04:00","size":4661230720,"digest":"f66fc8dc39ea206e03ff6764fcc696b1b4dfb693f0b6ef751731dd4e6269046e","details":{"parent_model":"","format":"gguf","family":"llama","families":["llama"],"parameter_size":"8.0B","quantization_level":"Q4_0"}}]}'
110
- tags = json.loads(json_response)
111
- print(json.dumps(tags, indent=2))
112
- conn = parse_ollama_tags(tags)
113
- assert "phi3.5:latest" in conn.models
114
- assert "gemma2:2b" in conn.models
115
- assert "llama3.1:latest" in conn.models
116
-
117
-
118
- def test_ollama_model_supported():
119
- conn = OllamaConnection(
120
- models=["phi3.5:latest", "gemma2:2b", "llama3.1:latest"], message="Connected"
121
- )
122
- assert ollama_model_supported(conn, "phi3.5:latest")
123
- assert ollama_model_supported(conn, "phi3.5")
124
- assert ollama_model_supported(conn, "gemma2:2b")
125
- assert ollama_model_supported(conn, "llama3.1:latest")
126
- assert ollama_model_supported(conn, "llama3.1")
127
- assert not ollama_model_supported(conn, "unknown_model")
128
-
129
-
130
- def test_get_model_and_provider_valid():
131
- # Test with a known valid model and provider combination
132
- model, provider = get_model_and_provider(
133
- ModelName.phi_3_5, ModelProviderName.ollama
134
- )
135
-
136
- assert model is not None
137
- assert provider is not None
138
- assert model.name == ModelName.phi_3_5
139
- assert provider.name == ModelProviderName.ollama
140
- assert provider.provider_options["model"] == "phi3.5"
141
-
142
-
143
- def test_get_model_and_provider_invalid_model():
144
- # Test with an invalid model name
145
- model, provider = get_model_and_provider(
146
- "nonexistent_model", ModelProviderName.ollama
147
- )
148
-
149
- assert model is None
150
- assert provider is None
151
-
152
-
153
- def test_get_model_and_provider_invalid_provider():
154
- # Test with a valid model but invalid provider
155
- model, provider = get_model_and_provider(ModelName.phi_3_5, "nonexistent_provider")
156
-
157
- assert model is None
158
- assert provider is None
159
-
160
-
161
- def test_get_model_and_provider_valid_model_wrong_provider():
162
- # Test with a valid model but a provider that doesn't support it
163
- model, provider = get_model_and_provider(
164
- ModelName.phi_3_5, ModelProviderName.amazon_bedrock
165
- )
166
-
167
- assert model is None
168
- assert provider is None
169
-
170
-
171
- def test_get_model_and_provider_multiple_providers():
172
- # Test with a model that has multiple providers
173
- model, provider = get_model_and_provider(
174
- ModelName.llama_3_1_70b, ModelProviderName.groq
175
- )
176
-
177
- assert model is not None
178
- assert provider is not None
179
- assert model.name == ModelName.llama_3_1_70b
180
- assert provider.name == ModelProviderName.groq
181
- assert provider.provider_options["model"] == "llama-3.1-70b-versatile"