hamtaa-texttools 2.0.0__py3-none-any.whl → 2.1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hamtaa-texttools
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Summary: A high-level NLP toolkit built on top of modern LLMs.
5
5
  Author-email: Tohidi <the.mohammad.tohidi@gmail.com>, Erfan Moosavi <erfanmoosavi84@gmail.com>, Montazer <montazerh82@gmail.com>, Givechi <mohamad.m.givechi@gmail.com>, Zareshahi <a.zareshahi1377@gmail.com>
6
6
  Maintainer-email: Erfan Moosavi <erfanmoosavi84@gmail.com>, Tohidi <the.mohammad.tohidi@gmail.com>
@@ -14,6 +14,7 @@ Classifier: Operating System :: OS Independent
14
14
  Requires-Python: >=3.11
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
+ Requires-Dist: dotenv>=0.9.9
17
18
  Requires-Dist: openai>=1.97.1
18
19
  Requires-Dist: pydantic>=2.0.0
19
20
  Requires-Dist: pyyaml>=6.0
@@ -68,13 +69,15 @@ pip install -U hamtaa-texttools
68
69
 
69
70
  | Status | Meaning | Tools | Safe for Production? |
70
71
  |--------|---------|----------|-------------------|
71
- | **✅ Production** | Evaluated and tested. | `categorize()` (list mode), `extract_keywords()`, `extract_entities()`, `is_question()`, `to_question()`, `merge_questions()`, `augment()`, `summarize()`, `run_custom()` | **Yes** - ready for reliable use. |
72
- | **🧪 Experimental** | Added to the package but **not fully evaluated**. | `categorize()` (tree mode), `translate()`, `propositionize()`, `is_fact()` | **Use with caution** |
72
+ | **✅ Production** | Evaluated and tested. | `categorize()`, `extract_keywords()`, `extract_entities()`, `is_question()`, `to_question()`, `merge_questions()`, `augment()`, `summarize()`, `run_custom()` | **Yes** - ready for reliable use. |
73
+ | **🧪 Experimental** | Added to the package but **not fully evaluated**. | `translate()`, `propositionize()`, `is_fact()` | **Use with caution** |
73
74
 
74
75
  ---
75
76
 
76
77
  ## ⚙️ Additional Parameters
77
78
 
79
+ - **`raise_on_error: bool`** → (`TheTool/AsyncTheTool` parameter) Raise errors (True) or return them in output (False). Default is True.
80
+
78
81
  - **`with_analysis: bool`** → Adds a reasoning step before generating the final output.
79
82
  **Note:** This doubles token usage per call.
80
83
 
@@ -174,10 +177,3 @@ Use **TextTools** when you need to:
174
177
  - 🔍 **Classify** large datasets quickly without model training
175
178
  - 🧩 **Integrate** LLMs into production pipelines (structured outputs)
176
179
  - 📊 **Analyze** large text collections using embeddings and categorization
177
-
178
- ---
179
-
180
- ## 🤝 Contributing
181
-
182
- Contributions are welcome!
183
- Feel free to **open issues, suggest new features, or submit pull requests**.
@@ -1,4 +1,4 @@
1
- hamtaa_texttools-2.0.0.dist-info/licenses/LICENSE,sha256=gqxbR8wqI3utd__l3Yn6_dQ3Pou1a17W4KmydbvZGok,1084
1
+ hamtaa_texttools-2.1.0.dist-info/licenses/LICENSE,sha256=gqxbR8wqI3utd__l3Yn6_dQ3Pou1a17W4KmydbvZGok,1084
2
2
  texttools/__init__.py,sha256=AHpTq1BbL3sWCaFiIjlSkqNfNqweq-qm2EIOSmUZRJ0,175
3
3
  texttools/models.py,sha256=CQnO1zkKHFyqeMWrYGA4IyXQ7YYLVc3Xz1WaXbXzDLw,4634
4
4
  texttools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -22,9 +22,9 @@ texttools/prompts/summarize.yaml,sha256=0aKYFRDxODqOOEhSexi-hn3twLwkMFVmi7rtAifn
22
22
  texttools/prompts/to_question.yaml,sha256=n8Bn28QjvSHwPHQLwRYpZ2IsaaBsq4pK9Dp_i0xk8eg,2210
23
23
  texttools/prompts/translate.yaml,sha256=omtC-TlFYMidy8WqRe7idUtKNiK4g3IhEl-iyufOwjk,649
24
24
  texttools/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- texttools/tools/async_tools.py,sha256=4-SwsjFqT_mGTK7reCqV-4VXxkyYkyuY3WYJcwkRMJs,44788
26
- texttools/tools/sync_tools.py,sha256=trmWBf4lvF9h_cB1DelOC4MFWDaQuQ0FDcdc-gCMVxo,40534
27
- hamtaa_texttools-2.0.0.dist-info/METADATA,sha256=NJYJ6K5HolttdX8_2rCq_w62N6k22mqu0hqO5Qhhy8I,6968
28
- hamtaa_texttools-2.0.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
29
- hamtaa_texttools-2.0.0.dist-info/top_level.txt,sha256=5Mh0jIxxZ5rOXHGJ6Mp-JPKviywwN0MYuH0xk5bEWqE,10
30
- hamtaa_texttools-2.0.0.dist-info/RECORD,,
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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.10.1)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  from collections.abc import Callable
2
3
  from time import perf_counter
3
4
  from typing import Any, Literal
@@ -23,8 +24,11 @@ class AsyncTheTool:
23
24
  self,
24
25
  client: AsyncOpenAI,
25
26
  model: str,
27
+ raise_on_error: bool = True,
26
28
  ):
27
29
  self._operator = AsyncOperator(client=client, model=model)
30
+ self.logger = logging.getLogger(self.__class__.__name__)
31
+ self.raise_on_error = raise_on_error
28
32
 
29
33
  async def categorize(
30
34
  self,
@@ -43,8 +47,6 @@ class AsyncTheTool:
43
47
  """
44
48
  Classify text into given categories
45
49
 
46
- Important Note: category_tree mode is EXPERIMENTAL, you can use it but it isn't reliable.
47
-
48
50
  Arguments:
49
51
  text: The input text
50
52
  categories: The category list / category tree
@@ -160,6 +162,11 @@ class AsyncTheTool:
160
162
  )
161
163
 
162
164
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
165
+ self.logger.error(str(e))
166
+
167
+ if self.raise_on_error:
168
+ raise
169
+
163
170
  metadata = ToolOutputMetadata(tool_name=tool_name)
164
171
  tool_output = ToolOutput(
165
172
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -241,6 +248,11 @@ class AsyncTheTool:
241
248
  )
242
249
 
243
250
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
251
+ self.logger.error(str(e))
252
+
253
+ if self.raise_on_error:
254
+ raise
255
+
244
256
  metadata = ToolOutputMetadata(tool_name=tool_name)
245
257
  tool_output = ToolOutput(
246
258
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -320,6 +332,11 @@ class AsyncTheTool:
320
332
  )
321
333
 
322
334
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
335
+ self.logger.error(str(e))
336
+
337
+ if self.raise_on_error:
338
+ raise
339
+
323
340
  metadata = ToolOutputMetadata(tool_name=tool_name)
324
341
  tool_output = ToolOutput(
325
342
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -394,6 +411,11 @@ class AsyncTheTool:
394
411
  )
395
412
 
396
413
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
414
+ self.logger.error(str(e))
415
+
416
+ if self.raise_on_error:
417
+ raise
418
+
397
419
  metadata = ToolOutputMetadata(tool_name=tool_name)
398
420
  tool_output = ToolOutput(
399
421
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -475,6 +497,11 @@ class AsyncTheTool:
475
497
  )
476
498
 
477
499
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
500
+ self.logger.error(str(e))
501
+
502
+ if self.raise_on_error:
503
+ raise
504
+
478
505
  metadata = ToolOutputMetadata(tool_name=tool_name)
479
506
  tool_output = ToolOutput(
480
507
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -554,6 +581,11 @@ class AsyncTheTool:
554
581
  )
555
582
 
556
583
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
584
+ self.logger.error(str(e))
585
+
586
+ if self.raise_on_error:
587
+ raise
588
+
557
589
  metadata = ToolOutputMetadata(tool_name=tool_name)
558
590
  tool_output = ToolOutput(
559
591
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -632,6 +664,11 @@ class AsyncTheTool:
632
664
  )
633
665
 
634
666
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
667
+ self.logger.error(str(e))
668
+
669
+ if self.raise_on_error:
670
+ raise
671
+
635
672
  metadata = ToolOutputMetadata(tool_name=tool_name)
636
673
  tool_output = ToolOutput(
637
674
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -708,6 +745,11 @@ class AsyncTheTool:
708
745
  )
709
746
 
710
747
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
748
+ self.logger.error(str(e))
749
+
750
+ if self.raise_on_error:
751
+ raise
752
+
711
753
  metadata = ToolOutputMetadata(tool_name=tool_name)
712
754
  tool_output = ToolOutput(
713
755
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -836,6 +878,11 @@ class AsyncTheTool:
836
878
  )
837
879
 
838
880
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
881
+ self.logger.error(str(e))
882
+
883
+ if self.raise_on_error:
884
+ raise
885
+
839
886
  metadata = ToolOutputMetadata(tool_name=tool_name)
840
887
  tool_output = ToolOutput(
841
888
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -914,6 +961,11 @@ class AsyncTheTool:
914
961
  )
915
962
 
916
963
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
964
+ self.logger.error(str(e))
965
+
966
+ if self.raise_on_error:
967
+ raise
968
+
917
969
  metadata = ToolOutputMetadata(tool_name=tool_name)
918
970
  tool_output = ToolOutput(
919
971
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -995,6 +1047,11 @@ class AsyncTheTool:
995
1047
  )
996
1048
 
997
1049
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
1050
+ self.logger.error(str(e))
1051
+
1052
+ if self.raise_on_error:
1053
+ raise
1054
+
998
1055
  metadata = ToolOutputMetadata(tool_name=tool_name)
999
1056
  tool_output = ToolOutput(
1000
1057
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -1075,6 +1132,11 @@ class AsyncTheTool:
1075
1132
  )
1076
1133
 
1077
1134
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
1135
+ self.logger.error(str(e))
1136
+
1137
+ if self.raise_on_error:
1138
+ raise
1139
+
1078
1140
  metadata = ToolOutputMetadata(tool_name=tool_name)
1079
1141
  tool_output = ToolOutput(
1080
1142
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  from collections.abc import Callable
2
3
  from time import perf_counter
3
4
  from typing import Any, Literal
@@ -23,8 +24,11 @@ class TheTool:
23
24
  self,
24
25
  client: OpenAI,
25
26
  model: str,
27
+ raise_on_error: bool = True,
26
28
  ):
27
29
  self._operator = Operator(client=client, model=model)
30
+ self.logger = logging.getLogger(self.__class__.__name__)
31
+ self.raise_on_error = raise_on_error
28
32
 
29
33
  def categorize(
30
34
  self,
@@ -42,8 +46,6 @@ class TheTool:
42
46
  """
43
47
  Classify text into given categories
44
48
 
45
- Important Note: category_tree mode is EXPERIMENTAL, you can use it but it isn't reliable.
46
-
47
49
  Arguments:
48
50
  text: The input text
49
51
  categories: The category list / category tree
@@ -152,6 +154,11 @@ class TheTool:
152
154
  )
153
155
 
154
156
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
157
+ self.logger.error(str(e))
158
+
159
+ if self.raise_on_error:
160
+ raise
161
+
155
162
  metadata = ToolOutputMetadata(tool_name=tool_name)
156
163
  tool_output = ToolOutput(
157
164
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -228,6 +235,11 @@ class TheTool:
228
235
  )
229
236
 
230
237
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
238
+ self.logger.error(str(e))
239
+
240
+ if self.raise_on_error:
241
+ raise
242
+
231
243
  metadata = ToolOutputMetadata(tool_name=tool_name)
232
244
  tool_output = ToolOutput(
233
245
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -302,6 +314,11 @@ class TheTool:
302
314
  )
303
315
 
304
316
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
317
+ self.logger.error(str(e))
318
+
319
+ if self.raise_on_error:
320
+ raise
321
+
305
322
  metadata = ToolOutputMetadata(tool_name=tool_name)
306
323
  tool_output = ToolOutput(
307
324
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -371,6 +388,11 @@ class TheTool:
371
388
  )
372
389
 
373
390
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
391
+ self.logger.error(str(e))
392
+
393
+ if self.raise_on_error:
394
+ raise
395
+
374
396
  metadata = ToolOutputMetadata(tool_name=tool_name)
375
397
  tool_output = ToolOutput(
376
398
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -447,6 +469,11 @@ class TheTool:
447
469
  )
448
470
 
449
471
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
472
+ self.logger.error(str(e))
473
+
474
+ if self.raise_on_error:
475
+ raise
476
+
450
477
  metadata = ToolOutputMetadata(tool_name=tool_name)
451
478
  tool_output = ToolOutput(
452
479
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -521,6 +548,11 @@ class TheTool:
521
548
  )
522
549
 
523
550
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
551
+ self.logger.error(str(e))
552
+
553
+ if self.raise_on_error:
554
+ raise
555
+
524
556
  metadata = ToolOutputMetadata(tool_name=tool_name)
525
557
  tool_output = ToolOutput(
526
558
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -594,6 +626,11 @@ class TheTool:
594
626
  )
595
627
 
596
628
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
629
+ self.logger.error(str(e))
630
+
631
+ if self.raise_on_error:
632
+ raise
633
+
597
634
  metadata = ToolOutputMetadata(tool_name=tool_name)
598
635
  tool_output = ToolOutput(
599
636
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -665,6 +702,11 @@ class TheTool:
665
702
  )
666
703
 
667
704
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
705
+ self.logger.error(str(e))
706
+
707
+ if self.raise_on_error:
708
+ raise
709
+
668
710
  metadata = ToolOutputMetadata(tool_name=tool_name)
669
711
  tool_output = ToolOutput(
670
712
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -785,6 +827,11 @@ class TheTool:
785
827
  )
786
828
 
787
829
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
830
+ self.logger.error(str(e))
831
+
832
+ if self.raise_on_error:
833
+ raise
834
+
788
835
  metadata = ToolOutputMetadata(tool_name=tool_name)
789
836
  tool_output = ToolOutput(
790
837
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -858,6 +905,11 @@ class TheTool:
858
905
  )
859
906
 
860
907
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
908
+ self.logger.error(str(e))
909
+
910
+ if self.raise_on_error:
911
+ raise
912
+
861
913
  metadata = ToolOutputMetadata(tool_name=tool_name)
862
914
  tool_output = ToolOutput(
863
915
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -934,6 +986,11 @@ class TheTool:
934
986
  )
935
987
 
936
988
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
989
+ self.logger.error(str(e))
990
+
991
+ if self.raise_on_error:
992
+ raise
993
+
937
994
  metadata = ToolOutputMetadata(tool_name=tool_name)
938
995
  tool_output = ToolOutput(
939
996
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata
@@ -1009,6 +1066,11 @@ class TheTool:
1009
1066
  )
1010
1067
 
1011
1068
  except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
1069
+ self.logger.error(str(e))
1070
+
1071
+ if self.raise_on_error:
1072
+ raise
1073
+
1012
1074
  metadata = ToolOutputMetadata(tool_name=tool_name)
1013
1075
  tool_output = ToolOutput(
1014
1076
  errors=[f"{type(e).__name__}: {e}"], metadata=metadata