hamtaa-texttools 1.1.9__py3-none-any.whl → 1.1.11__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.
- {hamtaa_texttools-1.1.9.dist-info → hamtaa_texttools-1.1.11.dist-info}/METADATA +22 -20
- hamtaa_texttools-1.1.11.dist-info/RECORD +30 -0
- texttools/__init__.py +4 -2
- texttools/batch/batch_config.py +26 -0
- texttools/batch/batch_runner.py +66 -103
- texttools/batch/{batch_manager.py → internals/batch_manager.py} +24 -24
- texttools/batch/internals/utils.py +16 -0
- texttools/tools/async_tools.py +54 -45
- texttools/tools/internals/async_operator.py +18 -66
- texttools/tools/internals/base_operator.py +3 -35
- texttools/tools/internals/prompt_loader.py +8 -7
- texttools/tools/internals/{operator.py → sync_operator.py} +18 -66
- texttools/tools/sync_tools.py +55 -46
- hamtaa_texttools-1.1.9.dist-info/RECORD +0 -30
- texttools/batch/__init__.py +0 -3
- texttools/tools/__init__.py +0 -4
- {hamtaa_texttools-1.1.9.dist-info → hamtaa_texttools-1.1.11.dist-info}/WHEEL +0 -0
- {hamtaa_texttools-1.1.9.dist-info → hamtaa_texttools-1.1.11.dist-info}/licenses/LICENSE +0 -0
- {hamtaa_texttools-1.1.9.dist-info → hamtaa_texttools-1.1.11.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, TypeVar, Type,
|
|
1
|
+
from typing import Any, TypeVar, Type, Callable
|
|
2
2
|
import logging
|
|
3
3
|
|
|
4
4
|
from openai import OpenAI
|
|
@@ -25,8 +25,7 @@ class Operator(BaseOperator):
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
def __init__(self, client: OpenAI, model: str):
|
|
28
|
-
|
|
29
|
-
self.model = model
|
|
28
|
+
super().__init__(client, model)
|
|
30
29
|
|
|
31
30
|
def _analyze(self, prompt_configs: dict[str, str], temperature: float) -> str:
|
|
32
31
|
"""
|
|
@@ -35,8 +34,8 @@ class Operator(BaseOperator):
|
|
|
35
34
|
"""
|
|
36
35
|
analyze_prompt = prompt_configs["analyze_template"]
|
|
37
36
|
analyze_message = [self._build_user_message(analyze_prompt)]
|
|
38
|
-
completion = self.
|
|
39
|
-
model=self.
|
|
37
|
+
completion = self._client.chat.completions.create(
|
|
38
|
+
model=self._model,
|
|
40
39
|
messages=analyze_message,
|
|
41
40
|
temperature=temperature,
|
|
42
41
|
)
|
|
@@ -56,7 +55,7 @@ class Operator(BaseOperator):
|
|
|
56
55
|
Returns both the parsed object and the raw completion for logging.
|
|
57
56
|
"""
|
|
58
57
|
request_kwargs = {
|
|
59
|
-
"model": self.
|
|
58
|
+
"model": self._model,
|
|
60
59
|
"messages": message,
|
|
61
60
|
"response_format": output_model,
|
|
62
61
|
"temperature": temperature,
|
|
@@ -66,43 +65,10 @@ class Operator(BaseOperator):
|
|
|
66
65
|
request_kwargs["logprobs"] = True
|
|
67
66
|
request_kwargs["top_logprobs"] = top_logprobs
|
|
68
67
|
|
|
69
|
-
completion = self.
|
|
68
|
+
completion = self._client.beta.chat.completions.parse(**request_kwargs)
|
|
70
69
|
parsed = completion.choices[0].message.parsed
|
|
71
70
|
return parsed, completion
|
|
72
71
|
|
|
73
|
-
def _vllm_completion(
|
|
74
|
-
self,
|
|
75
|
-
message: list[dict[str, str]],
|
|
76
|
-
output_model: Type[T],
|
|
77
|
-
temperature: float,
|
|
78
|
-
logprobs: bool = False,
|
|
79
|
-
top_logprobs: int = 3,
|
|
80
|
-
) -> tuple[T, Any]:
|
|
81
|
-
"""
|
|
82
|
-
Generates a completion using vLLM with JSON schema guidance.
|
|
83
|
-
Returns the parsed output model and raw completion.
|
|
84
|
-
"""
|
|
85
|
-
json_schema = output_model.model_json_schema()
|
|
86
|
-
|
|
87
|
-
# Build kwargs dynamically
|
|
88
|
-
request_kwargs = {
|
|
89
|
-
"model": self.model,
|
|
90
|
-
"messages": message,
|
|
91
|
-
"extra_body": {"guided_json": json_schema},
|
|
92
|
-
"temperature": temperature,
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if logprobs:
|
|
96
|
-
request_kwargs["logprobs"] = True
|
|
97
|
-
request_kwargs["top_logprobs"] = top_logprobs
|
|
98
|
-
|
|
99
|
-
completion = self.client.chat.completions.create(**request_kwargs)
|
|
100
|
-
response = completion.choices[0].message.content
|
|
101
|
-
|
|
102
|
-
# Convert the string response to output model
|
|
103
|
-
parsed = self._convert_to_output_model(response, output_model)
|
|
104
|
-
return parsed, completion
|
|
105
|
-
|
|
106
72
|
def run(
|
|
107
73
|
self,
|
|
108
74
|
# User parameters
|
|
@@ -114,10 +80,10 @@ class Operator(BaseOperator):
|
|
|
114
80
|
logprobs: bool,
|
|
115
81
|
top_logprobs: int | None,
|
|
116
82
|
validator: Callable[[Any], bool] | None,
|
|
83
|
+
max_validation_retries: int | None,
|
|
117
84
|
# Internal parameters
|
|
118
85
|
prompt_file: str,
|
|
119
86
|
output_model: Type[T],
|
|
120
|
-
resp_format: Literal["vllm", "parse"],
|
|
121
87
|
mode: str | None,
|
|
122
88
|
**extra_kwargs,
|
|
123
89
|
) -> ToolOutput:
|
|
@@ -159,14 +125,9 @@ class Operator(BaseOperator):
|
|
|
159
125
|
messages.append(self._build_user_message(prompt_configs["main_template"]))
|
|
160
126
|
messages
|
|
161
127
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
)
|
|
166
|
-
elif resp_format == "parse":
|
|
167
|
-
parsed, completion = self._parse_completion(
|
|
168
|
-
messages, output_model, temperature, logprobs, top_logprobs
|
|
169
|
-
)
|
|
128
|
+
parsed, completion = self._parse_completion(
|
|
129
|
+
messages, output_model, temperature, logprobs, top_logprobs
|
|
130
|
+
)
|
|
170
131
|
|
|
171
132
|
# Ensure output_model has a `result` field
|
|
172
133
|
if not hasattr(parsed, "result"):
|
|
@@ -179,7 +140,7 @@ class Operator(BaseOperator):
|
|
|
179
140
|
|
|
180
141
|
# Retry logic if validation fails
|
|
181
142
|
if validator and not validator(output.result):
|
|
182
|
-
for attempt in range(
|
|
143
|
+
for attempt in range(max_validation_retries):
|
|
183
144
|
logger.warning(
|
|
184
145
|
f"Validation failed, retrying for the {attempt + 1} time."
|
|
185
146
|
)
|
|
@@ -187,22 +148,13 @@ class Operator(BaseOperator):
|
|
|
187
148
|
# Generate new temperature for retry
|
|
188
149
|
retry_temperature = self._get_retry_temp(temperature)
|
|
189
150
|
try:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
)
|
|
198
|
-
elif resp_format == "parse":
|
|
199
|
-
parsed, completion = self._parse_completion(
|
|
200
|
-
messages,
|
|
201
|
-
output_model,
|
|
202
|
-
retry_temperature,
|
|
203
|
-
logprobs,
|
|
204
|
-
top_logprobs,
|
|
205
|
-
)
|
|
151
|
+
parsed, completion = self._parse_completion(
|
|
152
|
+
messages,
|
|
153
|
+
output_model,
|
|
154
|
+
retry_temperature,
|
|
155
|
+
logprobs,
|
|
156
|
+
top_logprobs,
|
|
157
|
+
)
|
|
206
158
|
|
|
207
159
|
output.result = parsed.result
|
|
208
160
|
|
texttools/tools/sync_tools.py
CHANGED
|
@@ -2,8 +2,8 @@ from typing import Literal, Any, Callable
|
|
|
2
2
|
|
|
3
3
|
from openai import OpenAI
|
|
4
4
|
|
|
5
|
-
from texttools.tools.internals.
|
|
6
|
-
import texttools.tools.internals.output_models as
|
|
5
|
+
from texttools.tools.internals.sync_operator import Operator
|
|
6
|
+
import texttools.tools.internals.output_models as OM
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class TheTool:
|
|
@@ -22,7 +22,7 @@ class TheTool:
|
|
|
22
22
|
client: OpenAI,
|
|
23
23
|
model: str,
|
|
24
24
|
):
|
|
25
|
-
self.
|
|
25
|
+
self._operator = Operator(client=client, model=model)
|
|
26
26
|
|
|
27
27
|
def categorize(
|
|
28
28
|
self,
|
|
@@ -33,7 +33,8 @@ class TheTool:
|
|
|
33
33
|
logprobs: bool = False,
|
|
34
34
|
top_logprobs: int | None = None,
|
|
35
35
|
validator: Callable[[Any], bool] | None = None,
|
|
36
|
-
|
|
36
|
+
max_validation_retries: int | None = None,
|
|
37
|
+
) -> OM.ToolOutput:
|
|
37
38
|
"""
|
|
38
39
|
Categorize a text into a single Islamic studies domain category.
|
|
39
40
|
|
|
@@ -43,7 +44,7 @@ class TheTool:
|
|
|
43
44
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
44
45
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
45
46
|
"""
|
|
46
|
-
return self.
|
|
47
|
+
return self._operator.run(
|
|
47
48
|
# User parameters
|
|
48
49
|
text=text,
|
|
49
50
|
with_analysis=with_analysis,
|
|
@@ -52,10 +53,10 @@ class TheTool:
|
|
|
52
53
|
logprobs=logprobs,
|
|
53
54
|
top_logprobs=top_logprobs,
|
|
54
55
|
validator=validator,
|
|
56
|
+
max_validation_retries=max_validation_retries,
|
|
55
57
|
# Internal parameters
|
|
56
58
|
prompt_file="categorizer.yaml",
|
|
57
|
-
output_model=
|
|
58
|
-
resp_format="parse",
|
|
59
|
+
output_model=OM.CategorizerOutput,
|
|
59
60
|
mode=None,
|
|
60
61
|
output_lang=None,
|
|
61
62
|
)
|
|
@@ -70,7 +71,8 @@ class TheTool:
|
|
|
70
71
|
logprobs: bool = False,
|
|
71
72
|
top_logprobs: int | None = None,
|
|
72
73
|
validator: Callable[[Any], bool] | None = None,
|
|
73
|
-
|
|
74
|
+
max_validation_retries: int | None = None,
|
|
75
|
+
) -> OM.ToolOutput:
|
|
74
76
|
"""
|
|
75
77
|
Extract salient keywords from text.
|
|
76
78
|
|
|
@@ -80,7 +82,7 @@ class TheTool:
|
|
|
80
82
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
81
83
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
82
84
|
"""
|
|
83
|
-
return self.
|
|
85
|
+
return self._operator.run(
|
|
84
86
|
# User parameters
|
|
85
87
|
text=text,
|
|
86
88
|
with_analysis=with_analysis,
|
|
@@ -90,10 +92,10 @@ class TheTool:
|
|
|
90
92
|
logprobs=logprobs,
|
|
91
93
|
top_logprobs=top_logprobs,
|
|
92
94
|
validator=validator,
|
|
95
|
+
max_validation_retries=max_validation_retries,
|
|
93
96
|
# Internal parameters
|
|
94
97
|
prompt_file="extract_keywords.yaml",
|
|
95
|
-
output_model=
|
|
96
|
-
resp_format="parse",
|
|
98
|
+
output_model=OM.ListStrOutput,
|
|
97
99
|
mode=None,
|
|
98
100
|
)
|
|
99
101
|
|
|
@@ -107,7 +109,8 @@ class TheTool:
|
|
|
107
109
|
logprobs: bool = False,
|
|
108
110
|
top_logprobs: int | None = None,
|
|
109
111
|
validator: Callable[[Any], bool] | None = None,
|
|
110
|
-
|
|
112
|
+
max_validation_retries: int | None = None,
|
|
113
|
+
) -> OM.ToolOutput:
|
|
111
114
|
"""
|
|
112
115
|
Perform Named Entity Recognition (NER) over the input text.
|
|
113
116
|
|
|
@@ -117,7 +120,7 @@ class TheTool:
|
|
|
117
120
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
118
121
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
119
122
|
"""
|
|
120
|
-
return self.
|
|
123
|
+
return self._operator.run(
|
|
121
124
|
# User parameters
|
|
122
125
|
text=text,
|
|
123
126
|
with_analysis=with_analysis,
|
|
@@ -127,10 +130,10 @@ class TheTool:
|
|
|
127
130
|
logprobs=logprobs,
|
|
128
131
|
top_logprobs=top_logprobs,
|
|
129
132
|
validator=validator,
|
|
133
|
+
max_validation_retries=max_validation_retries,
|
|
130
134
|
# Internal parameters
|
|
131
135
|
prompt_file="extract_entities.yaml",
|
|
132
|
-
output_model=
|
|
133
|
-
resp_format="parse",
|
|
136
|
+
output_model=OM.ListDictStrStrOutput,
|
|
134
137
|
mode=None,
|
|
135
138
|
)
|
|
136
139
|
|
|
@@ -143,7 +146,8 @@ class TheTool:
|
|
|
143
146
|
logprobs: bool = False,
|
|
144
147
|
top_logprobs: int | None = None,
|
|
145
148
|
validator: Callable[[Any], bool] | None = None,
|
|
146
|
-
|
|
149
|
+
max_validation_retries: int | None = None,
|
|
150
|
+
) -> OM.ToolOutput:
|
|
147
151
|
"""
|
|
148
152
|
Detect if the input is phrased as a question.
|
|
149
153
|
|
|
@@ -153,7 +157,7 @@ class TheTool:
|
|
|
153
157
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
154
158
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
155
159
|
"""
|
|
156
|
-
return self.
|
|
160
|
+
return self._operator.run(
|
|
157
161
|
# User parameters
|
|
158
162
|
text=text,
|
|
159
163
|
with_analysis=with_analysis,
|
|
@@ -162,10 +166,10 @@ class TheTool:
|
|
|
162
166
|
logprobs=logprobs,
|
|
163
167
|
top_logprobs=top_logprobs,
|
|
164
168
|
validator=validator,
|
|
169
|
+
max_validation_retries=max_validation_retries,
|
|
165
170
|
# Internal parameters
|
|
166
171
|
prompt_file="is_question.yaml",
|
|
167
|
-
output_model=
|
|
168
|
-
resp_format="parse",
|
|
172
|
+
output_model=OM.BoolOutput,
|
|
169
173
|
mode=None,
|
|
170
174
|
output_lang=None,
|
|
171
175
|
)
|
|
@@ -180,7 +184,8 @@ class TheTool:
|
|
|
180
184
|
logprobs: bool = False,
|
|
181
185
|
top_logprobs: int | None = None,
|
|
182
186
|
validator: Callable[[Any], bool] | None = None,
|
|
183
|
-
|
|
187
|
+
max_validation_retries: int | None = None,
|
|
188
|
+
) -> OM.ToolOutput:
|
|
184
189
|
"""
|
|
185
190
|
Generate a single question from the given text.
|
|
186
191
|
|
|
@@ -190,7 +195,7 @@ class TheTool:
|
|
|
190
195
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
191
196
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
192
197
|
"""
|
|
193
|
-
return self.
|
|
198
|
+
return self._operator.run(
|
|
194
199
|
# User parameters
|
|
195
200
|
text=text,
|
|
196
201
|
with_analysis=with_analysis,
|
|
@@ -200,10 +205,10 @@ class TheTool:
|
|
|
200
205
|
logprobs=logprobs,
|
|
201
206
|
top_logprobs=top_logprobs,
|
|
202
207
|
validator=validator,
|
|
208
|
+
max_validation_retries=max_validation_retries,
|
|
203
209
|
# Internal parameters
|
|
204
210
|
prompt_file="text_to_question.yaml",
|
|
205
|
-
output_model=
|
|
206
|
-
resp_format="parse",
|
|
211
|
+
output_model=OM.StrOutput,
|
|
207
212
|
mode=None,
|
|
208
213
|
)
|
|
209
214
|
|
|
@@ -218,7 +223,8 @@ class TheTool:
|
|
|
218
223
|
top_logprobs: int | None = None,
|
|
219
224
|
mode: Literal["default", "reason"] = "default",
|
|
220
225
|
validator: Callable[[Any], bool] | None = None,
|
|
221
|
-
|
|
226
|
+
max_validation_retries: int | None = None,
|
|
227
|
+
) -> OM.ToolOutput:
|
|
222
228
|
"""
|
|
223
229
|
Merge multiple questions into a single unified question.
|
|
224
230
|
|
|
@@ -229,7 +235,7 @@ class TheTool:
|
|
|
229
235
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
230
236
|
"""
|
|
231
237
|
text = ", ".join(text)
|
|
232
|
-
return self.
|
|
238
|
+
return self._operator.run(
|
|
233
239
|
# User parameters
|
|
234
240
|
text=text,
|
|
235
241
|
with_analysis=with_analysis,
|
|
@@ -239,10 +245,10 @@ class TheTool:
|
|
|
239
245
|
logprobs=logprobs,
|
|
240
246
|
top_logprobs=top_logprobs,
|
|
241
247
|
validator=validator,
|
|
248
|
+
max_validation_retries=max_validation_retries,
|
|
242
249
|
# Internal parameters
|
|
243
250
|
prompt_file="merge_questions.yaml",
|
|
244
|
-
output_model=
|
|
245
|
-
resp_format="parse",
|
|
251
|
+
output_model=OM.StrOutput,
|
|
246
252
|
mode=mode,
|
|
247
253
|
)
|
|
248
254
|
|
|
@@ -257,7 +263,8 @@ class TheTool:
|
|
|
257
263
|
top_logprobs: int | None = None,
|
|
258
264
|
mode: Literal["positive", "negative", "hard_negative"] = "positive",
|
|
259
265
|
validator: Callable[[Any], bool] | None = None,
|
|
260
|
-
|
|
266
|
+
max_validation_retries: int | None = None,
|
|
267
|
+
) -> OM.ToolOutput:
|
|
261
268
|
"""
|
|
262
269
|
Rewrite a text with different modes.
|
|
263
270
|
|
|
@@ -267,7 +274,7 @@ class TheTool:
|
|
|
267
274
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
268
275
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
269
276
|
"""
|
|
270
|
-
return self.
|
|
277
|
+
return self._operator.run(
|
|
271
278
|
# User parameters
|
|
272
279
|
text=text,
|
|
273
280
|
with_analysis=with_analysis,
|
|
@@ -277,10 +284,10 @@ class TheTool:
|
|
|
277
284
|
logprobs=logprobs,
|
|
278
285
|
top_logprobs=top_logprobs,
|
|
279
286
|
validator=validator,
|
|
287
|
+
max_validation_retries=max_validation_retries,
|
|
280
288
|
# Internal parameters
|
|
281
289
|
prompt_file="rewrite.yaml",
|
|
282
|
-
output_model=
|
|
283
|
-
resp_format="parse",
|
|
290
|
+
output_model=OM.StrOutput,
|
|
284
291
|
mode=mode,
|
|
285
292
|
)
|
|
286
293
|
|
|
@@ -295,7 +302,8 @@ class TheTool:
|
|
|
295
302
|
logprobs: bool = False,
|
|
296
303
|
top_logprobs: int | None = None,
|
|
297
304
|
validator: Callable[[Any], bool] | None = None,
|
|
298
|
-
|
|
305
|
+
max_validation_retries: int | None = None,
|
|
306
|
+
) -> OM.ToolOutput:
|
|
299
307
|
"""
|
|
300
308
|
Generate a list of questions about a subject.
|
|
301
309
|
|
|
@@ -305,7 +313,7 @@ class TheTool:
|
|
|
305
313
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
306
314
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
307
315
|
"""
|
|
308
|
-
return self.
|
|
316
|
+
return self._operator.run(
|
|
309
317
|
# User parameters
|
|
310
318
|
text=text,
|
|
311
319
|
number_of_questions=number_of_questions,
|
|
@@ -316,10 +324,10 @@ class TheTool:
|
|
|
316
324
|
logprobs=logprobs,
|
|
317
325
|
top_logprobs=top_logprobs,
|
|
318
326
|
validator=validator,
|
|
327
|
+
max_validation_retries=max_validation_retries,
|
|
319
328
|
# Internal parameters
|
|
320
329
|
prompt_file="subject_to_question.yaml",
|
|
321
|
-
output_model=
|
|
322
|
-
resp_format="parse",
|
|
330
|
+
output_model=OM.ReasonListStrOutput,
|
|
323
331
|
mode=None,
|
|
324
332
|
)
|
|
325
333
|
|
|
@@ -333,7 +341,8 @@ class TheTool:
|
|
|
333
341
|
logprobs: bool = False,
|
|
334
342
|
top_logprobs: int | None = None,
|
|
335
343
|
validator: Callable[[Any], bool] | None = None,
|
|
336
|
-
|
|
344
|
+
max_validation_retries: int | None = None,
|
|
345
|
+
) -> OM.ToolOutput:
|
|
337
346
|
"""
|
|
338
347
|
Summarize the given subject text.
|
|
339
348
|
|
|
@@ -343,7 +352,7 @@ class TheTool:
|
|
|
343
352
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
344
353
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
345
354
|
"""
|
|
346
|
-
return self.
|
|
355
|
+
return self._operator.run(
|
|
347
356
|
# User parameters
|
|
348
357
|
text=text,
|
|
349
358
|
with_analysis=with_analysis,
|
|
@@ -353,10 +362,10 @@ class TheTool:
|
|
|
353
362
|
logprobs=logprobs,
|
|
354
363
|
top_logprobs=top_logprobs,
|
|
355
364
|
validator=validator,
|
|
365
|
+
max_validation_retries=max_validation_retries,
|
|
356
366
|
# Internal parameters
|
|
357
367
|
prompt_file="summarize.yaml",
|
|
358
|
-
output_model=
|
|
359
|
-
resp_format="parse",
|
|
368
|
+
output_model=OM.StrOutput,
|
|
360
369
|
mode=None,
|
|
361
370
|
)
|
|
362
371
|
|
|
@@ -370,7 +379,8 @@ class TheTool:
|
|
|
370
379
|
logprobs: bool = False,
|
|
371
380
|
top_logprobs: int | None = None,
|
|
372
381
|
validator: Callable[[Any], bool] | None = None,
|
|
373
|
-
|
|
382
|
+
max_validation_retries: int | None = None,
|
|
383
|
+
) -> OM.ToolOutput:
|
|
374
384
|
"""
|
|
375
385
|
Translate text between languages.
|
|
376
386
|
|
|
@@ -380,7 +390,7 @@ class TheTool:
|
|
|
380
390
|
- logprobs (list | None): Probability data if logprobs enabled
|
|
381
391
|
- analysis (str | None): Detailed reasoning if with_analysis enabled
|
|
382
392
|
"""
|
|
383
|
-
return self.
|
|
393
|
+
return self._operator.run(
|
|
384
394
|
# User parameters
|
|
385
395
|
text=text,
|
|
386
396
|
target_language=target_language,
|
|
@@ -390,10 +400,10 @@ class TheTool:
|
|
|
390
400
|
logprobs=logprobs,
|
|
391
401
|
top_logprobs=top_logprobs,
|
|
392
402
|
validator=validator,
|
|
403
|
+
max_validation_retries=max_validation_retries,
|
|
393
404
|
# Internal parameters
|
|
394
405
|
prompt_file="translate.yaml",
|
|
395
|
-
output_model=
|
|
396
|
-
resp_format="parse",
|
|
406
|
+
output_model=OM.StrOutput,
|
|
397
407
|
mode=None,
|
|
398
408
|
output_lang=None,
|
|
399
409
|
)
|
|
@@ -406,7 +416,7 @@ class TheTool:
|
|
|
406
416
|
temperature: float | None = None,
|
|
407
417
|
logprobs: bool | None = None,
|
|
408
418
|
top_logprobs: int | None = None,
|
|
409
|
-
) ->
|
|
419
|
+
) -> OM.ToolOutput:
|
|
410
420
|
"""
|
|
411
421
|
Custom tool that can do almost anything!
|
|
412
422
|
|
|
@@ -414,7 +424,7 @@ class TheTool:
|
|
|
414
424
|
ToolOutput: Object with fields:
|
|
415
425
|
- result (str): The output result
|
|
416
426
|
"""
|
|
417
|
-
return self.
|
|
427
|
+
return self._operator.run(
|
|
418
428
|
# User paramaeters
|
|
419
429
|
text=prompt,
|
|
420
430
|
output_model=output_model,
|
|
@@ -425,7 +435,6 @@ class TheTool:
|
|
|
425
435
|
top_logprobs=top_logprobs,
|
|
426
436
|
# Internal parameters
|
|
427
437
|
prompt_file="run_custom.yaml",
|
|
428
|
-
resp_format="parse",
|
|
429
438
|
user_prompt=None,
|
|
430
439
|
with_analysis=False,
|
|
431
440
|
mode=None,
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
hamtaa_texttools-1.1.9.dist-info/licenses/LICENSE,sha256=Hb2YOBKy2MJQLnyLrX37B4ZVuac8eaIcE71SvVIMOLg,1082
|
|
2
|
-
texttools/__init__.py,sha256=lFYe1jdssHC1h8qcPpV3whANxiDi8aiiFdY-7L0Ck10,164
|
|
3
|
-
texttools/batch/__init__.py,sha256=DJGJTfR6F3Yv4_alsj9g1tesGzdcSV27Zw74DonhW_s,102
|
|
4
|
-
texttools/batch/batch_manager.py,sha256=ZgLiO9maCHnx2cJbUjsYXFnlUsMLI2TP3Vc9uKU0BLg,8706
|
|
5
|
-
texttools/batch/batch_runner.py,sha256=X0YQmaowO_jUSAFWBHdxOLoRrX_gvmrJDgp9qPlOSEw,10254
|
|
6
|
-
texttools/prompts/README.md,sha256=-5YO93CN93QLifqZpUeUnCOCBbDiOTV-cFQeJ7Gg0I4,1377
|
|
7
|
-
texttools/prompts/categorizer.yaml,sha256=GMqIIzQFhgnlpkgU1qi3FAD3mD4A2jiWD5TilQ2XnnE,1204
|
|
8
|
-
texttools/prompts/extract_entities.yaml,sha256=KiKjeDpHaeh3JVtZ6q1pa3k4DYucUIU9WnEcRTCA-SE,651
|
|
9
|
-
texttools/prompts/extract_keywords.yaml,sha256=0O7ypL_OsEOxtvlQ2CZjnsv9637DJwAKprZsf9Vo2_s,769
|
|
10
|
-
texttools/prompts/is_question.yaml,sha256=d0-vKRbXWkxvO64ikvxRjEmpAXGpCYIPGhgexvPPjws,471
|
|
11
|
-
texttools/prompts/merge_questions.yaml,sha256=0J85GvTirZB4ELwH3sk8ub_WcqqpYf6PrMKr3djlZeo,1792
|
|
12
|
-
texttools/prompts/rewrite.yaml,sha256=LO7He_IA3MZKz8a-LxH9DHJpOjpYwaYN1pbjp1Y0tFo,5392
|
|
13
|
-
texttools/prompts/run_custom.yaml,sha256=38OkCoVITbuuS9c08UZSP1jZW4WjSmRIi8fR0RAiPu4,108
|
|
14
|
-
texttools/prompts/subject_to_question.yaml,sha256=C7x7rNNm6U_ZG9HOn6zuzYOtvJUZ2skuWbL1-aYdd3E,1147
|
|
15
|
-
texttools/prompts/summarize.yaml,sha256=o6rxGPfWtZd61Duvm8NVvCJqfq73b-wAuMSKR6UYUqY,459
|
|
16
|
-
texttools/prompts/text_to_question.yaml,sha256=UheKYpDn6iyKI8NxunHZtFpNyfCLZZe5cvkuXpurUJY,783
|
|
17
|
-
texttools/prompts/translate.yaml,sha256=mGT2uBCei6uucWqVbs4silk-UV060v3G0jnt0P6sr50,634
|
|
18
|
-
texttools/tools/__init__.py,sha256=3fPoeB-E5wGxWgv7axztHkeolR7ZDUJudd0xmpPFjao,113
|
|
19
|
-
texttools/tools/async_tools.py,sha256=2ZY7Lo6Jj9xoTF8bfdh_g8VOXZ7ljMMesd1_QHXyf4s,15395
|
|
20
|
-
texttools/tools/sync_tools.py,sha256=XKgZuzriFnk8B-YihJfs6BKivxjGCgOFfe7hnCpEiXs,15161
|
|
21
|
-
texttools/tools/internals/async_operator.py,sha256=egBsrcpGBmkDY5YzUvGHh1TjPmsH9IOVXDGmYMWjzMs,8960
|
|
22
|
-
texttools/tools/internals/base_operator.py,sha256=qV9LlVo_DzSCzQnjYTFi-6mlHN4gE0edPE2y_9WwQFw,3292
|
|
23
|
-
texttools/tools/internals/formatters.py,sha256=tACNLP6PeoqaRpNudVxBaHA25zyWqWYPZQuYysIu88g,941
|
|
24
|
-
texttools/tools/internals/operator.py,sha256=xgbt1Mm67SEC-KD9jwXjXGTCcaCsaVLhG6iCYOqLDcc,8709
|
|
25
|
-
texttools/tools/internals/output_models.py,sha256=ekpbyocmXj_dee7ieOT1zOkMo9cPHT7xcUFCZoUaXA0,1886
|
|
26
|
-
texttools/tools/internals/prompt_loader.py,sha256=8uD7JUatKXSLXhGwWs46iQpcjWdhF9p32SFDLMndy1o,1940
|
|
27
|
-
hamtaa_texttools-1.1.9.dist-info/METADATA,sha256=nQFuGr_7aVHlO7nRsTbubEtO0QVUofcdUKwMATzHhUU,9129
|
|
28
|
-
hamtaa_texttools-1.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
29
|
-
hamtaa_texttools-1.1.9.dist-info/top_level.txt,sha256=5Mh0jIxxZ5rOXHGJ6Mp-JPKviywwN0MYuH0xk5bEWqE,10
|
|
30
|
-
hamtaa_texttools-1.1.9.dist-info/RECORD,,
|
texttools/batch/__init__.py
DELETED
texttools/tools/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|