chatan 0.1.0__py3-none-any.whl → 0.1.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.
chatan/__init__.py
CHANGED
chatan/generator.py
CHANGED
@@ -58,14 +58,24 @@ class AnthropicGenerator(BaseGenerator):
|
|
58
58
|
|
59
59
|
class GeneratorFunction:
|
60
60
|
"""Callable generator function for use in dataset schemas."""
|
61
|
-
|
62
|
-
def __init__(
|
61
|
+
|
62
|
+
def __init__(
|
63
|
+
self,
|
64
|
+
generator: BaseGenerator,
|
65
|
+
prompt_template: str,
|
66
|
+
variables: Optional[Dict[str, Any]] = None,
|
67
|
+
):
|
63
68
|
self.generator = generator
|
64
69
|
self.prompt_template = prompt_template
|
65
|
-
|
70
|
+
self.variables = variables or {}
|
71
|
+
|
66
72
|
def __call__(self, context: Dict[str, Any]) -> str:
|
67
73
|
"""Generate content with context substitution."""
|
68
|
-
|
74
|
+
merged = dict(context)
|
75
|
+
for key, value in self.variables.items():
|
76
|
+
merged[key] = value(context) if callable(value) else value
|
77
|
+
|
78
|
+
prompt = self.prompt_template.format(**merged)
|
69
79
|
result = self.generator.generate(prompt)
|
70
80
|
return result.strip() if isinstance(result, str) else result
|
71
81
|
|
@@ -81,9 +91,19 @@ class GeneratorClient:
|
|
81
91
|
else:
|
82
92
|
raise ValueError(f"Unsupported provider: {provider}")
|
83
93
|
|
84
|
-
def __call__(self, prompt_template: str) -> GeneratorFunction:
|
85
|
-
"""Create a generator function.
|
86
|
-
|
94
|
+
def __call__(self, prompt_template: str, **variables) -> GeneratorFunction:
|
95
|
+
"""Create a generator function.
|
96
|
+
|
97
|
+
Parameters
|
98
|
+
----------
|
99
|
+
prompt_template:
|
100
|
+
Template string for the prompt.
|
101
|
+
**variables:
|
102
|
+
Optional variables to include when formatting the prompt. If a value
|
103
|
+
is callable it will be invoked with the row context when the
|
104
|
+
generator function is executed.
|
105
|
+
"""
|
106
|
+
return GeneratorFunction(self._generator, prompt_template, variables)
|
87
107
|
|
88
108
|
|
89
109
|
# Factory function
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: chatan
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.1
|
4
4
|
Summary: Create synthetic datasets with LLM generators and samplers
|
5
5
|
Project-URL: Documentation, https://github.com/cdreetz/chatan#readme
|
6
6
|
Project-URL: Issues, https://github.com/cdreetz/chatan/issues
|
@@ -0,0 +1,7 @@
|
|
1
|
+
chatan/__init__.py,sha256=SebE8sKfiXl3FC0iwYi7ft9piJgOVdRXnj6g17z5rzo,233
|
2
|
+
chatan/dataset.py,sha256=t6RrrQchsD2dROD886IfnlXWnn-F-IAWMcEIK0SS3xg,4358
|
3
|
+
chatan/generator.py,sha256=zAOVxd2iY_KMK21dCMeFhvsJu2q8NEwch5jGJP-Me9s,3914
|
4
|
+
chatan/sampler.py,sha256=0X6AVQK20py4SwKnsppZC2yAZnP_jBhRxt9MfT1e-k4,4812
|
5
|
+
chatan-0.1.1.dist-info/METADATA,sha256=cCZgPzZaGvLWBDqDBj3dS7Fzh-l4HFFqGDoy01n5Sw8,2549
|
6
|
+
chatan-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
+
chatan-0.1.1.dist-info/RECORD,,
|
chatan-0.1.0.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
chatan/__init__.py,sha256=GdCxiObHomq4-2TyqS2dfEd2EuDYGpi2AkvC5QIb3mU,233
|
2
|
-
chatan/dataset.py,sha256=t6RrrQchsD2dROD886IfnlXWnn-F-IAWMcEIK0SS3xg,4358
|
3
|
-
chatan/generator.py,sha256=kj8axCWI00F8R0DJL831AUtK41Bvv2VL4nOweTgGfGc,3286
|
4
|
-
chatan/sampler.py,sha256=0X6AVQK20py4SwKnsppZC2yAZnP_jBhRxt9MfT1e-k4,4812
|
5
|
-
chatan-0.1.0.dist-info/METADATA,sha256=A5L6T8zlmoO5tKG30kmjQKQnOcCivSypaw8TFd4fS_k,2549
|
6
|
-
chatan-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
7
|
-
chatan-0.1.0.dist-info/RECORD,,
|
File without changes
|