kiln-ai 0.0.4__py3-none-any.whl → 0.5.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.

Files changed (33) hide show
  1. kiln_ai/adapters/base_adapter.py +168 -0
  2. kiln_ai/adapters/langchain_adapters.py +113 -0
  3. kiln_ai/adapters/ml_model_list.py +436 -0
  4. kiln_ai/adapters/prompt_builders.py +122 -0
  5. kiln_ai/adapters/repair/repair_task.py +71 -0
  6. kiln_ai/adapters/repair/test_repair_task.py +248 -0
  7. kiln_ai/adapters/test_langchain_adapter.py +50 -0
  8. kiln_ai/adapters/test_ml_model_list.py +99 -0
  9. kiln_ai/adapters/test_prompt_adaptors.py +167 -0
  10. kiln_ai/adapters/test_prompt_builders.py +315 -0
  11. kiln_ai/adapters/test_saving_adapter_results.py +168 -0
  12. kiln_ai/adapters/test_structured_output.py +218 -0
  13. kiln_ai/datamodel/__init__.py +362 -2
  14. kiln_ai/datamodel/basemodel.py +372 -0
  15. kiln_ai/datamodel/json_schema.py +45 -0
  16. kiln_ai/datamodel/test_basemodel.py +277 -0
  17. kiln_ai/datamodel/test_datasource.py +107 -0
  18. kiln_ai/datamodel/test_example_models.py +644 -0
  19. kiln_ai/datamodel/test_json_schema.py +124 -0
  20. kiln_ai/datamodel/test_models.py +190 -0
  21. kiln_ai/datamodel/test_nested_save.py +205 -0
  22. kiln_ai/datamodel/test_output_rating.py +88 -0
  23. kiln_ai/utils/config.py +170 -0
  24. kiln_ai/utils/formatting.py +5 -0
  25. kiln_ai/utils/test_config.py +245 -0
  26. {kiln_ai-0.0.4.dist-info → kiln_ai-0.5.0.dist-info}/METADATA +20 -1
  27. kiln_ai-0.5.0.dist-info/RECORD +29 -0
  28. kiln_ai/__init.__.py +0 -3
  29. kiln_ai/coreadd.py +0 -3
  30. kiln_ai/datamodel/project.py +0 -15
  31. kiln_ai-0.0.4.dist-info/RECORD +0 -8
  32. {kiln_ai-0.0.4.dist-info → kiln_ai-0.5.0.dist-info}/LICENSE.txt +0 -0
  33. {kiln_ai-0.0.4.dist-info → kiln_ai-0.5.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,107 @@
1
+ import pytest
2
+ from kiln_ai.datamodel import DataSource, DataSourceType
3
+ from pydantic import ValidationError
4
+
5
+
6
+ def test_valid_human_data_source():
7
+ data_source = DataSource(
8
+ type=DataSourceType.human, properties={"created_by": "John Doe"}
9
+ )
10
+ assert data_source.type == DataSourceType.human
11
+ assert data_source.properties["created_by"] == "John Doe"
12
+
13
+
14
+ def test_valid_synthetic_data_source():
15
+ data_source = DataSource(
16
+ type=DataSourceType.synthetic,
17
+ properties={
18
+ "model_name": "GPT-4",
19
+ "model_provider": "OpenAI",
20
+ "prompt_builder_name": "completion",
21
+ "adapter_name": "langchain",
22
+ },
23
+ )
24
+ assert data_source.type == DataSourceType.synthetic
25
+ assert data_source.properties["model_name"] == "GPT-4"
26
+ assert data_source.properties["model_provider"] == "OpenAI"
27
+ assert data_source.properties["prompt_builder_name"] == "completion"
28
+ assert data_source.properties["adapter_name"] == "langchain"
29
+
30
+
31
+ def test_missing_required_property():
32
+ with pytest.raises(
33
+ ValidationError, match="'created_by' is required for DataSourceType.human data"
34
+ ):
35
+ DataSource(type=DataSourceType.human)
36
+
37
+
38
+ def test_wrong_property_type():
39
+ with pytest.raises(
40
+ ValidationError,
41
+ match="'model_name' must be of type str for DataSourceType.synthetic data",
42
+ ):
43
+ DataSource(
44
+ type=DataSourceType.synthetic,
45
+ properties={"model_name": 123, "model_provider": "OpenAI"},
46
+ )
47
+
48
+
49
+ def test_not_allowed_property():
50
+ with pytest.raises(
51
+ ValidationError,
52
+ match="'created_by' is not allowed for DataSourceType.synthetic data",
53
+ ):
54
+ DataSource(
55
+ type=DataSourceType.synthetic,
56
+ properties={
57
+ "model_name": "GPT-4",
58
+ "model_provider": "OpenAI",
59
+ "created_by": "John Doe",
60
+ },
61
+ )
62
+
63
+
64
+ def test_extra_properties():
65
+ data_source = DataSource(
66
+ type=DataSourceType.synthetic,
67
+ properties={
68
+ "model_name": "GPT-4",
69
+ "model_provider": "OpenAI",
70
+ "adapter_name": "langchain",
71
+ "temperature": 0.7,
72
+ "max_tokens": 100,
73
+ },
74
+ )
75
+ assert data_source.properties["temperature"] == 0.7
76
+ assert data_source.properties["max_tokens"] == 100
77
+
78
+
79
+ def test_prompt_type_optional_for_synthetic():
80
+ data_source = DataSource(
81
+ type=DataSourceType.synthetic,
82
+ properties={
83
+ "model_name": "GPT-4",
84
+ "model_provider": "OpenAI",
85
+ "adapter_name": "langchain",
86
+ },
87
+ )
88
+ assert "prompt_builder_name" not in data_source.properties
89
+
90
+
91
+ def test_private_data_source_properties_not_serialized():
92
+ data_source = DataSource(
93
+ type=DataSourceType.synthetic,
94
+ properties={
95
+ "model_name": "GPT-4",
96
+ "model_provider": "OpenAI",
97
+ "adapter_name": "langchain",
98
+ },
99
+ )
100
+ serialized = data_source.model_dump()
101
+ assert "_data_source_properties" not in serialized
102
+ assert "properties" in serialized
103
+ assert serialized["properties"] == {
104
+ "model_name": "GPT-4",
105
+ "model_provider": "OpenAI",
106
+ "adapter_name": "langchain",
107
+ }