hamtaa-texttools 2.1.0__py3-none-any.whl → 2.3.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.
- {hamtaa_texttools-2.1.0.dist-info → hamtaa_texttools-2.3.0.dist-info}/METADATA +75 -11
- hamtaa_texttools-2.3.0.dist-info/RECORD +31 -0
- texttools/__init__.py +2 -3
- texttools/core/__init__.py +34 -0
- texttools/core/internal_models.py +52 -0
- texttools/core/operators/__init__.py +4 -0
- texttools/core/operators/async_operator.py +11 -3
- texttools/core/operators/sync_operator.py +9 -3
- texttools/core/utils.py +33 -0
- texttools/models.py +4 -0
- texttools/prompts/augment.yaml +15 -15
- texttools/prompts/to_question.yaml +0 -2
- texttools/prompts/translate.yaml +2 -2
- texttools/tools/__init__.py +5 -0
- texttools/tools/async_tools.py +69 -19
- texttools/tools/batch_tools.py +688 -0
- texttools/tools/sync_tools.py +69 -19
- hamtaa_texttools-2.1.0.dist-info/RECORD +0 -30
- {hamtaa_texttools-2.1.0.dist-info → hamtaa_texttools-2.3.0.dist-info}/WHEEL +0 -0
- {hamtaa_texttools-2.1.0.dist-info → hamtaa_texttools-2.3.0.dist-info}/licenses/LICENSE +0 -0
- {hamtaa_texttools-2.1.0.dist-info → hamtaa_texttools-2.3.0.dist-info}/top_level.txt +0 -0
texttools/tools/sync_tools.py
CHANGED
|
@@ -5,17 +5,21 @@ from typing import Any, Literal
|
|
|
5
5
|
|
|
6
6
|
from openai import OpenAI
|
|
7
7
|
|
|
8
|
-
from ..core
|
|
9
|
-
from ..core.internal_models import (
|
|
8
|
+
from ..core import (
|
|
10
9
|
Bool,
|
|
11
10
|
ListDictStrStr,
|
|
12
11
|
ListStr,
|
|
12
|
+
LLMError,
|
|
13
|
+
Operator,
|
|
14
|
+
PromptError,
|
|
13
15
|
ReasonListStr,
|
|
14
16
|
Str,
|
|
17
|
+
TextToolsError,
|
|
18
|
+
TheToolUtils,
|
|
19
|
+
TokenUsage,
|
|
20
|
+
ValidationError,
|
|
15
21
|
create_dynamic_model,
|
|
16
22
|
)
|
|
17
|
-
from ..core.operators.sync_operator import Operator
|
|
18
|
-
from ..core.utils import TheToolUtils
|
|
19
23
|
from ..models import CategoryTree, ToolOutput, ToolOutputMetadata
|
|
20
24
|
|
|
21
25
|
|
|
@@ -29,6 +33,7 @@ class TheTool:
|
|
|
29
33
|
self._operator = Operator(client=client, model=model)
|
|
30
34
|
self.logger = logging.getLogger(self.__class__.__name__)
|
|
31
35
|
self.raise_on_error = raise_on_error
|
|
36
|
+
self.model = model
|
|
32
37
|
|
|
33
38
|
def categorize(
|
|
34
39
|
self,
|
|
@@ -60,7 +65,6 @@ class TheTool:
|
|
|
60
65
|
|
|
61
66
|
Returns:
|
|
62
67
|
ToolOutput
|
|
63
|
-
|
|
64
68
|
"""
|
|
65
69
|
tool_name = "categorize"
|
|
66
70
|
start = perf_counter()
|
|
@@ -87,7 +91,10 @@ class TheTool:
|
|
|
87
91
|
)
|
|
88
92
|
|
|
89
93
|
metadata = ToolOutputMetadata(
|
|
90
|
-
tool_name=tool_name,
|
|
94
|
+
tool_name=tool_name,
|
|
95
|
+
execution_time=perf_counter() - start,
|
|
96
|
+
processed_by=self.model,
|
|
97
|
+
token_usage=operator_output.token_usage,
|
|
91
98
|
)
|
|
92
99
|
tool_output = ToolOutput(
|
|
93
100
|
result=operator_output.result,
|
|
@@ -102,6 +109,7 @@ class TheTool:
|
|
|
102
109
|
final_categories = []
|
|
103
110
|
analysis = ""
|
|
104
111
|
logprobs_list = []
|
|
112
|
+
token_usage = TokenUsage()
|
|
105
113
|
|
|
106
114
|
for _ in range(levels):
|
|
107
115
|
if not parent_node.children:
|
|
@@ -142,9 +150,13 @@ class TheTool:
|
|
|
142
150
|
analysis += level_operator_output.analysis
|
|
143
151
|
if logprobs:
|
|
144
152
|
logprobs_list.extend(level_operator_output.logprobs)
|
|
153
|
+
token_usage += level_operator_output.token_usage
|
|
145
154
|
|
|
146
155
|
metadata = ToolOutputMetadata(
|
|
147
|
-
tool_name=tool_name,
|
|
156
|
+
tool_name=tool_name,
|
|
157
|
+
execution_time=perf_counter() - start,
|
|
158
|
+
processed_by=self.model,
|
|
159
|
+
token_usage=token_usage,
|
|
148
160
|
)
|
|
149
161
|
tool_output = ToolOutput(
|
|
150
162
|
result=final_categories,
|
|
@@ -225,7 +237,10 @@ class TheTool:
|
|
|
225
237
|
)
|
|
226
238
|
|
|
227
239
|
metadata = ToolOutputMetadata(
|
|
228
|
-
tool_name=tool_name,
|
|
240
|
+
tool_name=tool_name,
|
|
241
|
+
execution_time=perf_counter() - start,
|
|
242
|
+
processed_by=self.model,
|
|
243
|
+
token_usage=operator_output.token_usage,
|
|
229
244
|
)
|
|
230
245
|
tool_output = ToolOutput(
|
|
231
246
|
result=operator_output.result,
|
|
@@ -304,7 +319,10 @@ class TheTool:
|
|
|
304
319
|
)
|
|
305
320
|
|
|
306
321
|
metadata = ToolOutputMetadata(
|
|
307
|
-
tool_name=tool_name,
|
|
322
|
+
tool_name=tool_name,
|
|
323
|
+
execution_time=perf_counter() - start,
|
|
324
|
+
processed_by=self.model,
|
|
325
|
+
token_usage=operator_output.token_usage,
|
|
308
326
|
)
|
|
309
327
|
tool_output = ToolOutput(
|
|
310
328
|
result=operator_output.result,
|
|
@@ -378,7 +396,10 @@ class TheTool:
|
|
|
378
396
|
)
|
|
379
397
|
|
|
380
398
|
metadata = ToolOutputMetadata(
|
|
381
|
-
tool_name=tool_name,
|
|
399
|
+
tool_name=tool_name,
|
|
400
|
+
execution_time=perf_counter() - start,
|
|
401
|
+
processed_by=self.model,
|
|
402
|
+
token_usage=operator_output.token_usage,
|
|
382
403
|
)
|
|
383
404
|
tool_output = ToolOutput(
|
|
384
405
|
result=operator_output.result,
|
|
@@ -459,7 +480,10 @@ class TheTool:
|
|
|
459
480
|
)
|
|
460
481
|
|
|
461
482
|
metadata = ToolOutputMetadata(
|
|
462
|
-
tool_name=tool_name,
|
|
483
|
+
tool_name=tool_name,
|
|
484
|
+
execution_time=perf_counter() - start,
|
|
485
|
+
processed_by=self.model,
|
|
486
|
+
token_usage=operator_output.token_usage,
|
|
463
487
|
)
|
|
464
488
|
tool_output = ToolOutput(
|
|
465
489
|
result=operator_output.result,
|
|
@@ -538,7 +562,10 @@ class TheTool:
|
|
|
538
562
|
)
|
|
539
563
|
|
|
540
564
|
metadata = ToolOutputMetadata(
|
|
541
|
-
tool_name=tool_name,
|
|
565
|
+
tool_name=tool_name,
|
|
566
|
+
execution_time=perf_counter() - start,
|
|
567
|
+
processed_by=self.model,
|
|
568
|
+
token_usage=operator_output.token_usage,
|
|
542
569
|
)
|
|
543
570
|
tool_output = ToolOutput(
|
|
544
571
|
result=operator_output.result,
|
|
@@ -616,7 +643,10 @@ class TheTool:
|
|
|
616
643
|
)
|
|
617
644
|
|
|
618
645
|
metadata = ToolOutputMetadata(
|
|
619
|
-
tool_name=tool_name,
|
|
646
|
+
tool_name=tool_name,
|
|
647
|
+
execution_time=perf_counter() - start,
|
|
648
|
+
processed_by=self.model,
|
|
649
|
+
token_usage=operator_output.token_usage,
|
|
620
650
|
)
|
|
621
651
|
tool_output = ToolOutput(
|
|
622
652
|
result=operator_output.result,
|
|
@@ -692,7 +722,10 @@ class TheTool:
|
|
|
692
722
|
)
|
|
693
723
|
|
|
694
724
|
metadata = ToolOutputMetadata(
|
|
695
|
-
tool_name=tool_name,
|
|
725
|
+
tool_name=tool_name,
|
|
726
|
+
execution_time=perf_counter() - start,
|
|
727
|
+
processed_by=self.model,
|
|
728
|
+
token_usage=operator_output.token_usage,
|
|
696
729
|
)
|
|
697
730
|
tool_output = ToolOutput(
|
|
698
731
|
result=operator_output.result,
|
|
@@ -758,6 +791,7 @@ class TheTool:
|
|
|
758
791
|
translation = ""
|
|
759
792
|
analysis = ""
|
|
760
793
|
logprobs_list = []
|
|
794
|
+
token_usage = TokenUsage()
|
|
761
795
|
|
|
762
796
|
for chunk in chunks:
|
|
763
797
|
chunk_operator_output = self._operator.run(
|
|
@@ -785,9 +819,13 @@ class TheTool:
|
|
|
785
819
|
analysis += chunk_operator_output.analysis
|
|
786
820
|
if logprobs:
|
|
787
821
|
logprobs_list.extend(chunk_operator_output.logprobs)
|
|
822
|
+
token_usage += chunk_operator_output.token_usage
|
|
788
823
|
|
|
789
824
|
metadata = ToolOutputMetadata(
|
|
790
|
-
tool_name=tool_name,
|
|
825
|
+
tool_name=tool_name,
|
|
826
|
+
execution_time=perf_counter() - start,
|
|
827
|
+
processed_by=self.model,
|
|
828
|
+
token_usage=token_usage,
|
|
791
829
|
)
|
|
792
830
|
tool_output = ToolOutput(
|
|
793
831
|
result=translation,
|
|
@@ -817,7 +855,10 @@ class TheTool:
|
|
|
817
855
|
)
|
|
818
856
|
|
|
819
857
|
metadata = ToolOutputMetadata(
|
|
820
|
-
tool_name=tool_name,
|
|
858
|
+
tool_name=tool_name,
|
|
859
|
+
execution_time=perf_counter() - start,
|
|
860
|
+
processed_by=self.model,
|
|
861
|
+
token_usage=operator_output.token_usage,
|
|
821
862
|
)
|
|
822
863
|
tool_output = ToolOutput(
|
|
823
864
|
result=operator_output.result,
|
|
@@ -895,7 +936,10 @@ class TheTool:
|
|
|
895
936
|
)
|
|
896
937
|
|
|
897
938
|
metadata = ToolOutputMetadata(
|
|
898
|
-
tool_name=tool_name,
|
|
939
|
+
tool_name=tool_name,
|
|
940
|
+
execution_time=perf_counter() - start,
|
|
941
|
+
processed_by=self.model,
|
|
942
|
+
token_usage=operator_output.token_usage,
|
|
899
943
|
)
|
|
900
944
|
tool_output = ToolOutput(
|
|
901
945
|
result=operator_output.result,
|
|
@@ -976,7 +1020,10 @@ class TheTool:
|
|
|
976
1020
|
)
|
|
977
1021
|
|
|
978
1022
|
metadata = ToolOutputMetadata(
|
|
979
|
-
tool_name=tool_name,
|
|
1023
|
+
tool_name=tool_name,
|
|
1024
|
+
execution_time=perf_counter() - start,
|
|
1025
|
+
processed_by=self.model,
|
|
1026
|
+
token_usage=operator_output.token_usage,
|
|
980
1027
|
)
|
|
981
1028
|
tool_output = ToolOutput(
|
|
982
1029
|
result=operator_output.result,
|
|
@@ -1056,7 +1103,10 @@ class TheTool:
|
|
|
1056
1103
|
)
|
|
1057
1104
|
|
|
1058
1105
|
metadata = ToolOutputMetadata(
|
|
1059
|
-
tool_name=tool_name,
|
|
1106
|
+
tool_name=tool_name,
|
|
1107
|
+
execution_time=perf_counter() - start,
|
|
1108
|
+
processed_by=self.model,
|
|
1109
|
+
token_usage=operator_output.token_usage,
|
|
1060
1110
|
)
|
|
1061
1111
|
tool_output = ToolOutput(
|
|
1062
1112
|
result=operator_output.result,
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
hamtaa_texttools-2.1.0.dist-info/licenses/LICENSE,sha256=gqxbR8wqI3utd__l3Yn6_dQ3Pou1a17W4KmydbvZGok,1084
|
|
2
|
-
texttools/__init__.py,sha256=AHpTq1BbL3sWCaFiIjlSkqNfNqweq-qm2EIOSmUZRJ0,175
|
|
3
|
-
texttools/models.py,sha256=CQnO1zkKHFyqeMWrYGA4IyXQ7YYLVc3Xz1WaXbXzDLw,4634
|
|
4
|
-
texttools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
texttools/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
texttools/core/exceptions.py,sha256=6SDjUL1rmd3ngzD3ytF4LyTRj3bQMSFR9ECrLoqXXHw,395
|
|
7
|
-
texttools/core/internal_models.py,sha256=CmRtXGZRn5fZ18lVb42N8LrZXvJb6WwdjIhgiotWJdA,1952
|
|
8
|
-
texttools/core/utils.py,sha256=jqXHXU1DWDKWhK0HHSjnjq4_TLg3FMcnRzrwTF1eqqc,9744
|
|
9
|
-
texttools/core/operators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
texttools/core/operators/async_operator.py,sha256=HOi9gUwIffJUtyp8WLNbMpxI8jnafNDrbtLl6vyPcUs,6221
|
|
11
|
-
texttools/core/operators/sync_operator.py,sha256=yM14fsku-4Nf60lPUVePaB9Lu8HbGKb4ubwoizVWuYQ,6126
|
|
12
|
-
texttools/prompts/augment.yaml,sha256=O-LMVyrihr0GQ8hp2Lx6uIR8Jh83bUDS9UZ-dvYOP7k,5453
|
|
13
|
-
texttools/prompts/categorize.yaml,sha256=kN4uRPOC7q6A13bdCIox60vZZ8sgRiTtquv-kqIvTsk,1133
|
|
14
|
-
texttools/prompts/extract_entities.yaml,sha256=-qe1eEvN-8nJ2_GLjeoFAPVORCPYUzsIt7UGXD485bE,648
|
|
15
|
-
texttools/prompts/extract_keywords.yaml,sha256=jP74HFa4Dka01d1COStEBbdzW5onqwocwyyVsmNpECs,3276
|
|
16
|
-
texttools/prompts/is_fact.yaml,sha256=kqF527DEdnlL3MG5tF1Z3ci_sRxmGv7dgNR2SuElq4Y,719
|
|
17
|
-
texttools/prompts/is_question.yaml,sha256=C-ynlt0qHpUM4BAIh0oI7UJ5BxCNU9-GR9T5864jeto,496
|
|
18
|
-
texttools/prompts/merge_questions.yaml,sha256=zgZs8BcwseZy1GsD_DvVGtw0yuCCc6xsK8VDmuHI2V0,1844
|
|
19
|
-
texttools/prompts/propositionize.yaml,sha256=xTw3HQrxtxoMpkf8a9is0uZZ0AG4IDNfh7XE0aVlNso,1441
|
|
20
|
-
texttools/prompts/run_custom.yaml,sha256=hSfR4BMJNUo9nP_AodPU7YTnhR-X_G-W7Pz0ROQzoI0,133
|
|
21
|
-
texttools/prompts/summarize.yaml,sha256=0aKYFRDxODqOOEhSexi-hn3twLwkMFVmi7rtAifnCuA,464
|
|
22
|
-
texttools/prompts/to_question.yaml,sha256=n8Bn28QjvSHwPHQLwRYpZ2IsaaBsq4pK9Dp_i0xk8eg,2210
|
|
23
|
-
texttools/prompts/translate.yaml,sha256=omtC-TlFYMidy8WqRe7idUtKNiK4g3IhEl-iyufOwjk,649
|
|
24
|
-
texttools/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
-
texttools/tools/async_tools.py,sha256=2ZJ8K1-SSRSyyQ5VfDBZof0HDeRjEuakZJyHAlswrLw,46089
|
|
26
|
-
texttools/tools/sync_tools.py,sha256=WqHaUQscOd6RbMCGjhFbC4muw1VZxu-W5qCOA9JIwVc,41835
|
|
27
|
-
hamtaa_texttools-2.1.0.dist-info/METADATA,sha256=Sq4pywPSrBvHxp6sundpF2LFblcJqYgkhONx8V3XNyU,6958
|
|
28
|
-
hamtaa_texttools-2.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
29
|
-
hamtaa_texttools-2.1.0.dist-info/top_level.txt,sha256=5Mh0jIxxZ5rOXHGJ6Mp-JPKviywwN0MYuH0xk5bEWqE,10
|
|
30
|
-
hamtaa_texttools-2.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|