hamtaa-texttools 1.3.1__py3-none-any.whl → 2.0.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.
Files changed (30) hide show
  1. {hamtaa_texttools-1.3.1.dist-info → hamtaa_texttools-2.0.0.dist-info}/METADATA +42 -48
  2. hamtaa_texttools-2.0.0.dist-info/RECORD +30 -0
  3. {hamtaa_texttools-1.3.1.dist-info → hamtaa_texttools-2.0.0.dist-info}/WHEEL +1 -1
  4. {hamtaa_texttools-1.3.1.dist-info → hamtaa_texttools-2.0.0.dist-info}/licenses/LICENSE +1 -1
  5. texttools/__init__.py +1 -1
  6. texttools/core/internal_models.py +21 -8
  7. texttools/core/operators/__init__.py +0 -0
  8. texttools/core/operators/async_operator.py +11 -19
  9. texttools/core/operators/sync_operator.py +11 -19
  10. texttools/core/utils.py +260 -0
  11. texttools/models.py +77 -22
  12. texttools/prompts/{rewrite.yaml → augment.yaml} +3 -3
  13. texttools/prompts/categorize.yaml +7 -8
  14. texttools/prompts/extract_entities.yaml +2 -2
  15. texttools/prompts/extract_keywords.yaml +4 -2
  16. texttools/prompts/{check_fact.yaml → is_fact.yaml} +5 -4
  17. texttools/prompts/is_question.yaml +1 -1
  18. texttools/prompts/merge_questions.yaml +8 -6
  19. texttools/prompts/propositionize.yaml +11 -7
  20. texttools/prompts/run_custom.yaml +3 -1
  21. texttools/prompts/summarize.yaml +3 -3
  22. texttools/prompts/to_question.yaml +60 -0
  23. texttools/prompts/translate.yaml +4 -4
  24. texttools/tools/async_tools.py +90 -169
  25. texttools/tools/sync_tools.py +76 -150
  26. hamtaa_texttools-1.3.1.dist-info/RECORD +0 -30
  27. texttools/core/engine.py +0 -264
  28. texttools/prompts/subject_to_question.yaml +0 -26
  29. texttools/prompts/text_to_question.yaml +0 -26
  30. {hamtaa_texttools-1.3.1.dist-info → hamtaa_texttools-2.0.0.dist-info}/top_level.txt +0 -0
@@ -4,7 +4,6 @@ from typing import Any, Literal
4
4
 
5
5
  from openai import AsyncOpenAI
6
6
 
7
- from ..core.engine import text_to_chunks, run_with_timeout
8
7
  from ..core.exceptions import LLMError, PromptError, TextToolsError, ValidationError
9
8
  from ..core.internal_models import (
10
9
  Bool,
@@ -15,15 +14,11 @@ from ..core.internal_models import (
15
14
  create_dynamic_model,
16
15
  )
17
16
  from ..core.operators.async_operator import AsyncOperator
17
+ from ..core.utils import TheToolUtils
18
18
  from ..models import CategoryTree, ToolOutput, ToolOutputMetadata
19
19
 
20
20
 
21
21
  class AsyncTheTool:
22
- """
23
- Each method configures the operator with a specific YAML prompt,
24
- output schema, and flags, then delegates execution to `operator.run()`.
25
- """
26
-
27
22
  def __init__(
28
23
  self,
29
24
  client: AsyncOpenAI,
@@ -46,16 +41,16 @@ class AsyncTheTool:
46
41
  timeout: float | None = None,
47
42
  ) -> ToolOutput:
48
43
  """
49
- Categorize a text into a category / category tree.
44
+ Classify text into given categories
50
45
 
51
46
  Important Note: category_tree mode is EXPERIMENTAL, you can use it but it isn't reliable.
52
47
 
53
48
  Arguments:
54
49
  text: The input text
55
50
  categories: The category list / category tree
56
- with_analysis: Whether to include detailed reasoning analysis
51
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
57
52
  user_prompt: Additional instructions
58
- temperature: Controls randomness (0.0 - 2.0)
53
+ temperature: Controls randomness
59
54
  logprobs: Whether to return token probability information
60
55
  top_logprobs: Number of top token alternatives to return if logprobs enabled
61
56
  validator: Custom validation function to validate the output
@@ -72,7 +67,7 @@ class AsyncTheTool:
72
67
 
73
68
  try:
74
69
  if isinstance(categories, list):
75
- operator_output = await run_with_timeout(
70
+ operator_output = await TheToolUtils.run_with_timeout(
76
71
  self._operator.run(
77
72
  # User parameters
78
73
  text=text,
@@ -121,7 +116,7 @@ class AsyncTheTool:
121
116
  ]
122
117
  category_names = list(parent_node.children.keys())
123
118
 
124
- level_operator_output = await run_with_timeout(
119
+ level_operator_output = await TheToolUtils.run_with_timeout(
125
120
  self._operator.run(
126
121
  # User parameters
127
122
  text=text,
@@ -175,28 +170,30 @@ class AsyncTheTool:
175
170
  async def extract_keywords(
176
171
  self,
177
172
  text: str,
173
+ mode: Literal["auto", "threshold", "count"],
174
+ number_of_keywords: int | None = None,
178
175
  with_analysis: bool = False,
179
176
  output_lang: str | None = None,
180
177
  user_prompt: str | None = None,
181
178
  temperature: float | None = 0.0,
182
179
  logprobs: bool = False,
183
180
  top_logprobs: int = 3,
184
- mode: Literal["auto", "threshold", "count"] = "auto",
185
- number_of_keywords: int | None = None,
186
181
  validator: Callable[[Any], bool] | None = None,
187
182
  max_validation_retries: int | None = None,
188
183
  priority: int | None = None,
189
184
  timeout: float | None = None,
190
185
  ) -> ToolOutput:
191
186
  """
192
- Extract salient keywords from text.
187
+ Extract keywords from the text
193
188
 
194
189
  Arguments:
195
190
  text: The input text
196
- with_analysis: Whether to include detailed reasoning analysis
197
- output_lang: Language for the output
191
+ mode: auto -> decide n of keywords automatically, threshold -> decide n of keywords by a threshold, count -> takes number of keywords as the parameter
192
+ number_of_keywords: Must be set only when using "count" mode
193
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
194
+ output_lang: Forces the model to respond in a specific language
198
195
  user_prompt: Additional instructions
199
- temperature: Controls randomness (0.0 - 2.0)
196
+ temperature: Controls randomness
200
197
  logprobs: Whether to return token probability information
201
198
  top_logprobs: Number of top token alternatives to return if logprobs enabled
202
199
  validator: Custom validation function to validate the output
@@ -211,24 +208,24 @@ class AsyncTheTool:
211
208
  start = perf_counter()
212
209
 
213
210
  try:
214
- operator_output = await run_with_timeout(
211
+ operator_output = await TheToolUtils.run_with_timeout(
215
212
  self._operator.run(
216
213
  # User parameters
217
214
  text=text,
218
215
  with_analysis=with_analysis,
216
+ number_of_keywords=number_of_keywords,
217
+ mode=mode,
219
218
  output_lang=output_lang,
220
219
  user_prompt=user_prompt,
221
220
  temperature=temperature,
222
221
  logprobs=logprobs,
223
222
  top_logprobs=top_logprobs,
224
- number_of_keywords=number_of_keywords,
225
223
  validator=validator,
226
224
  max_validation_retries=max_validation_retries,
227
225
  priority=priority,
228
226
  # Internal parameters
229
227
  tool_name=tool_name,
230
228
  output_model=ListStr,
231
- mode=mode,
232
229
  ),
233
230
  timeout=timeout,
234
231
  )
@@ -254,7 +251,7 @@ class AsyncTheTool:
254
251
  async def extract_entities(
255
252
  self,
256
253
  text: str,
257
- entities: list[str] | None = None,
254
+ entities: list[str] = ["all named entities"],
258
255
  with_analysis: bool = False,
259
256
  output_lang: str | None = None,
260
257
  user_prompt: str | None = None,
@@ -267,15 +264,15 @@ class AsyncTheTool:
267
264
  timeout: float | None = None,
268
265
  ) -> ToolOutput:
269
266
  """
270
- Perform Named Entity Recognition (NER) over the input text.
267
+ Perform Named Entity Recognition (NER)
271
268
 
272
269
  Arguments:
273
270
  text: The input text
274
- entities: List of entities provided by user (Optional)
275
- with_analysis: Whether to include detailed reasoning analysis
276
- output_lang: Language for the output
271
+ entities: List of entities
272
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
273
+ output_lang: Forces the model to respond in a specific language
277
274
  user_prompt: Additional instructions
278
- temperature: Controls randomness (0.0 - 2.0)
275
+ temperature: Controls randomness
279
276
  logprobs: Whether to return token probability information
280
277
  top_logprobs: Number of top token alternatives to return if logprobs enabled
281
278
  validator: Custom validation function to validate the output
@@ -290,12 +287,11 @@ class AsyncTheTool:
290
287
  start = perf_counter()
291
288
 
292
289
  try:
293
- operator_output = await run_with_timeout(
290
+ operator_output = await TheToolUtils.run_with_timeout(
294
291
  self._operator.run(
295
292
  # User parameters
296
293
  text=text,
297
- entities=entities
298
- or "all named entities (e.g., PER, ORG, LOC, DAT, etc.)",
294
+ entities=entities,
299
295
  with_analysis=with_analysis,
300
296
  output_lang=output_lang,
301
297
  user_prompt=user_prompt,
@@ -349,9 +345,9 @@ class AsyncTheTool:
349
345
 
350
346
  Arguments:
351
347
  text: The input text
352
- with_analysis: Whether to include detailed reasoning analysis
348
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
353
349
  user_prompt: Additional instructions
354
- temperature: Controls randomness (0.0 - 2.0)
350
+ temperature: Controls randomness
355
351
  logprobs: Whether to return token probability information
356
352
  top_logprobs: Number of top token alternatives to return if logprobs enabled
357
353
  validator: Custom validation function to validate the output
@@ -366,7 +362,7 @@ class AsyncTheTool:
366
362
  start = perf_counter()
367
363
 
368
364
  try:
369
- operator_output = await run_with_timeout(
365
+ operator_output = await TheToolUtils.run_with_timeout(
370
366
  self._operator.run(
371
367
  # User parameters
372
368
  text=text,
@@ -405,10 +401,11 @@ class AsyncTheTool:
405
401
 
406
402
  return tool_output
407
403
 
408
- async def text_to_question(
404
+ async def to_question(
409
405
  self,
410
406
  text: str,
411
407
  number_of_questions: int,
408
+ mode: Literal["from_text", "from_subject"],
412
409
  with_analysis: bool = False,
413
410
  output_lang: str | None = None,
414
411
  user_prompt: str | None = None,
@@ -421,15 +418,16 @@ class AsyncTheTool:
421
418
  timeout: float | None = None,
422
419
  ) -> ToolOutput:
423
420
  """
424
- Generate a single question from the given text.
421
+ Generate questions from the given text / subject
425
422
 
426
423
  Arguments:
427
424
  text: The input text
425
+ mode: from_text -> generate questions from an answer, from_subject -> generate questions from a subject
428
426
  number_of_questions: Number of questions to generate
429
- with_analysis: Whether to include detailed reasoning analysis
430
- output_lang: Language for the output
427
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
428
+ output_lang: Forces the model to respond in a specific language
431
429
  user_prompt: Additional instructions
432
- temperature: Controls randomness (0.0 - 2.0)
430
+ temperature: Controls randomness
433
431
  logprobs: Whether to return token probability information
434
432
  top_logprobs: Number of top token alternatives to return if logprobs enabled
435
433
  validator: Custom validation function to validate the output
@@ -440,15 +438,16 @@ class AsyncTheTool:
440
438
  Returns:
441
439
  ToolOutput
442
440
  """
443
- tool_name = "text_to_question"
441
+ tool_name = "to_question"
444
442
  start = perf_counter()
445
443
 
446
444
  try:
447
- operator_output = await run_with_timeout(
445
+ operator_output = await TheToolUtils.run_with_timeout(
448
446
  self._operator.run(
449
447
  # User parameters
450
448
  text=text,
451
449
  number_of_questions=number_of_questions,
450
+ mode=mode,
452
451
  with_analysis=with_analysis,
453
452
  output_lang=output_lang,
454
453
  user_prompt=user_prompt,
@@ -461,7 +460,6 @@ class AsyncTheTool:
461
460
  # Internal parameters
462
461
  tool_name=tool_name,
463
462
  output_model=ReasonListStr,
464
- mode=None,
465
463
  ),
466
464
  timeout=timeout,
467
465
  )
@@ -487,27 +485,28 @@ class AsyncTheTool:
487
485
  async def merge_questions(
488
486
  self,
489
487
  text: list[str],
488
+ mode: Literal["simple", "stepwise"],
490
489
  with_analysis: bool = False,
491
490
  output_lang: str | None = None,
492
491
  user_prompt: str | None = None,
493
492
  temperature: float | None = 0.0,
494
493
  logprobs: bool = False,
495
494
  top_logprobs: int = 3,
496
- mode: Literal["default", "reason"] = "default",
497
495
  validator: Callable[[Any], bool] | None = None,
498
496
  max_validation_retries: int | None = None,
499
497
  priority: int | None = None,
500
498
  timeout: float | None = None,
501
499
  ) -> ToolOutput:
502
500
  """
503
- Merge multiple questions into a single unified question.
501
+ Merge multiple questions into a single unified question
504
502
 
505
503
  Arguments:
506
504
  text: List of questions to merge
507
- with_analysis: Whether to include detailed reasoning analysis
508
- output_lang: Language for the output
505
+ mode: simple -> regular question merging, stepwise -> merge questions in two steps
506
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
507
+ output_lang: Forces the model to respond in a specific language
509
508
  user_prompt: Additional instructions
510
- temperature: Controls randomness (0.0 - 2.0)
509
+ temperature: Controls randomness
511
510
  logprobs: Whether to return token probability information
512
511
  top_logprobs: Number of top token alternatives to return if logprobs enabled
513
512
  validator: Custom validation function to validate the output
@@ -523,10 +522,11 @@ class AsyncTheTool:
523
522
 
524
523
  try:
525
524
  text = ", ".join(text)
526
- operator_output = await run_with_timeout(
525
+ operator_output = await TheToolUtils.run_with_timeout(
527
526
  self._operator.run(
528
527
  # User parameters
529
528
  text=text,
529
+ mode=mode,
530
530
  with_analysis=with_analysis,
531
531
  output_lang=output_lang,
532
532
  user_prompt=user_prompt,
@@ -539,7 +539,6 @@ class AsyncTheTool:
539
539
  # Internal parameters
540
540
  tool_name=tool_name,
541
541
  output_model=Str,
542
- mode=mode,
543
542
  ),
544
543
  timeout=timeout,
545
544
  )
@@ -562,30 +561,31 @@ class AsyncTheTool:
562
561
 
563
562
  return tool_output
564
563
 
565
- async def rewrite(
564
+ async def augment(
566
565
  self,
567
566
  text: str,
567
+ mode: Literal["positive", "negative", "hard_negative"],
568
568
  with_analysis: bool = False,
569
569
  output_lang: str | None = None,
570
570
  user_prompt: str | None = None,
571
571
  temperature: float | None = 0.0,
572
572
  logprobs: bool = False,
573
573
  top_logprobs: int = 3,
574
- mode: Literal["positive", "negative", "hard_negative"] = "positive",
575
574
  validator: Callable[[Any], bool] | None = None,
576
575
  max_validation_retries: int | None = None,
577
576
  priority: int | None = None,
578
577
  timeout: float | None = None,
579
578
  ) -> ToolOutput:
580
579
  """
581
- Rewrite a text with different modes.
580
+ Rewrite text in different augmentations
582
581
 
583
582
  Arguments:
584
583
  text: The input text
585
- with_analysis: Whether to include detailed reasoning analysis
586
- output_lang: Language for the output
584
+ mode: positive -> positive augmentation, negative -> negative augmentation, hard_negative -> hard negative augmentation
585
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
586
+ output_lang: Forces the model to respond in a specific language
587
587
  user_prompt: Additional instructions
588
- temperature: Controls randomness (0.0 - 2.0)
588
+ temperature: Controls randomness
589
589
  logprobs: Whether to return token probability information
590
590
  top_logprobs: Number of top token alternatives to return if logprobs enabled
591
591
  validator: Custom validation function to validate the output
@@ -596,93 +596,15 @@ class AsyncTheTool:
596
596
  Returns:
597
597
  ToolOutput
598
598
  """
599
- tool_name = "rewrite"
599
+ tool_name = "augment"
600
600
  start = perf_counter()
601
601
 
602
602
  try:
603
- operator_output = await run_with_timeout(
603
+ operator_output = await TheToolUtils.run_with_timeout(
604
604
  self._operator.run(
605
605
  # User parameters
606
606
  text=text,
607
- with_analysis=with_analysis,
608
- output_lang=output_lang,
609
- user_prompt=user_prompt,
610
- temperature=temperature,
611
- logprobs=logprobs,
612
- top_logprobs=top_logprobs,
613
- validator=validator,
614
- max_validation_retries=max_validation_retries,
615
- priority=priority,
616
- # Internal parameters
617
- tool_name=tool_name,
618
- output_model=Str,
619
607
  mode=mode,
620
- ),
621
- timeout=timeout,
622
- )
623
-
624
- metadata = ToolOutputMetadata(
625
- tool_name=tool_name, execution_time=perf_counter() - start
626
- )
627
- tool_output = ToolOutput(
628
- result=operator_output.result,
629
- logprobs=operator_output.logprobs,
630
- analysis=operator_output.analysis,
631
- metadata=metadata,
632
- )
633
-
634
- except (PromptError, LLMError, ValidationError, TextToolsError, Exception) as e:
635
- metadata = ToolOutputMetadata(tool_name=tool_name)
636
- tool_output = ToolOutput(
637
- errors=[f"{type(e).__name__}: {e}"], metadata=metadata
638
- )
639
-
640
- return tool_output
641
-
642
- async def subject_to_question(
643
- self,
644
- text: str,
645
- number_of_questions: int,
646
- with_analysis: bool = False,
647
- output_lang: str | None = None,
648
- user_prompt: str | None = None,
649
- temperature: float | None = 0.0,
650
- logprobs: bool = False,
651
- top_logprobs: int = 3,
652
- validator: Callable[[Any], bool] | None = None,
653
- max_validation_retries: int | None = None,
654
- priority: int | None = None,
655
- timeout: float | None = None,
656
- ) -> ToolOutput:
657
- """
658
- Generate a list of questions about a subject.
659
-
660
- Arguments:
661
- text: The subject text to generate questions about
662
- number_of_questions: Number of questions to generate
663
- with_analysis: Whether to include detailed reasoning analysis
664
- output_lang: Language for the output
665
- user_prompt: Additional instructions
666
- temperature: Controls randomness (0.0 - 2.0)
667
- logprobs: Whether to return token probability information
668
- top_logprobs: Number of top token alternatives to return if logprobs enabled
669
- validator: Custom validation function to validate the output
670
- max_validation_retries: Maximum number of retry attempts if validation fails
671
- priority: Task execution priority (if enabled by vLLM and the model)
672
- timeout: Maximum time in seconds to wait for the response before raising a timeout error
673
-
674
- Returns:
675
- ToolOutput
676
- """
677
- tool_name = "subject_to_question"
678
- start = perf_counter()
679
-
680
- try:
681
- operator_output = await run_with_timeout(
682
- self._operator.run(
683
- # User parameters
684
- text=text,
685
- number_of_questions=number_of_questions,
686
608
  with_analysis=with_analysis,
687
609
  output_lang=output_lang,
688
610
  user_prompt=user_prompt,
@@ -694,8 +616,7 @@ class AsyncTheTool:
694
616
  priority=priority,
695
617
  # Internal parameters
696
618
  tool_name=tool_name,
697
- output_model=ReasonListStr,
698
- mode=None,
619
+ output_model=Str,
699
620
  ),
700
621
  timeout=timeout,
701
622
  )
@@ -733,14 +654,14 @@ class AsyncTheTool:
733
654
  timeout: float | None = None,
734
655
  ) -> ToolOutput:
735
656
  """
736
- Summarize the given subject text.
657
+ Summarize the given text
737
658
 
738
659
  Arguments:
739
660
  text: The input text
740
- with_analysis: Whether to include detailed reasoning analysis
741
- output_lang: Language for the output
661
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
662
+ output_lang: Forces the model to respond in a specific language
742
663
  user_prompt: Additional instructions
743
- temperature: Controls randomness (0.0 - 2.0)
664
+ temperature: Controls randomness
744
665
  logprobs: Whether to return token probability information
745
666
  top_logprobs: Number of top token alternatives to return if logprobs enabled
746
667
  validator: Custom validation function to validate the output
@@ -755,7 +676,7 @@ class AsyncTheTool:
755
676
  start = perf_counter()
756
677
 
757
678
  try:
758
- operator_output = await run_with_timeout(
679
+ operator_output = await TheToolUtils.run_with_timeout(
759
680
  self._operator.run(
760
681
  # User parameters
761
682
  text=text,
@@ -797,7 +718,7 @@ class AsyncTheTool:
797
718
  async def translate(
798
719
  self,
799
720
  text: str,
800
- target_language: str,
721
+ target_lang: str,
801
722
  use_chunker: bool = True,
802
723
  with_analysis: bool = False,
803
724
  user_prompt: str | None = None,
@@ -810,17 +731,17 @@ class AsyncTheTool:
810
731
  timeout: float | None = None,
811
732
  ) -> ToolOutput:
812
733
  """
813
- Translate text between languages.
734
+ Translate text between languages
814
735
 
815
736
  Important Note: This tool is EXPERIMENTAL, you can use it but it isn't reliable.
816
737
 
817
738
  Arguments:
818
739
  text: The input text
819
- target_language: The target language for translation
820
- use_chunker: Whether to use text chunker for text length bigger than 1500
821
- with_analysis: Whether to include detailed reasoning analysis
740
+ target_lang: The target language for translation
741
+ use_chunker: Whether to use text chunker for large texts
742
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
822
743
  user_prompt: Additional instructions
823
- temperature: Controls randomness (0.0 - 2.0)
744
+ temperature: Controls randomness
824
745
  logprobs: Whether to return token probability information
825
746
  top_logprobs: Number of top token alternatives to return if logprobs enabled
826
747
  validator: Custom validation function to validate the output
@@ -836,17 +757,17 @@ class AsyncTheTool:
836
757
 
837
758
  try:
838
759
  if len(text.split(" ")) > 1500 and use_chunker:
839
- chunks = text_to_chunks(text, 1200, 0)
760
+ chunks = TheToolUtils.to_chunks(text, 1200, 0)
840
761
  translation = ""
841
762
  analysis = ""
842
763
  logprobs_list = []
843
764
 
844
765
  for chunk in chunks:
845
- chunk_operator_output = await run_with_timeout(
766
+ chunk_operator_output = await TheToolUtils.run_with_timeout(
846
767
  self._operator.run(
847
768
  # User parameters
848
769
  text=chunk,
849
- target_language=target_language,
770
+ target_lang=target_lang,
850
771
  with_analysis=with_analysis,
851
772
  user_prompt=user_prompt,
852
773
  temperature=temperature,
@@ -882,11 +803,11 @@ class AsyncTheTool:
882
803
  )
883
804
 
884
805
  else:
885
- operator_output = await run_with_timeout(
806
+ operator_output = await TheToolUtils.run_with_timeout(
886
807
  self._operator.run(
887
808
  # User parameters
888
809
  text=text,
889
- target_language=target_language,
810
+ target_lang=target_lang,
890
811
  with_analysis=with_analysis,
891
812
  user_prompt=user_prompt,
892
813
  temperature=temperature,
@@ -937,16 +858,16 @@ class AsyncTheTool:
937
858
  timeout: float | None = None,
938
859
  ) -> ToolOutput:
939
860
  """
940
- Proposition input text to meaningful sentences.
861
+ Convert a text into atomic, independent, meaningful sentences
941
862
 
942
863
  Important Note: This tool is EXPERIMENTAL, you can use it but it isn't reliable.
943
864
 
944
865
  Arguments:
945
866
  text: The input text
946
- with_analysis: Whether to include detailed reasoning analysis
947
- output_lang: Language for the output
867
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
868
+ output_lang: Forces the model to respond in a specific language
948
869
  user_prompt: Additional instructions
949
- temperature: Controls randomness (0.0 - 2.0)
870
+ temperature: Controls randomness
950
871
  logprobs: Whether to return token probability information
951
872
  top_logprobs: Number of top token alternatives to return if logprobs enabled
952
873
  validator: Custom validation function to validate the output
@@ -961,7 +882,7 @@ class AsyncTheTool:
961
882
  start = perf_counter()
962
883
 
963
884
  try:
964
- operator_output = await run_with_timeout(
885
+ operator_output = await TheToolUtils.run_with_timeout(
965
886
  self._operator.run(
966
887
  # User parameters
967
888
  text=text,
@@ -1000,7 +921,7 @@ class AsyncTheTool:
1000
921
 
1001
922
  return tool_output
1002
923
 
1003
- async def check_fact(
924
+ async def is_fact(
1004
925
  self,
1005
926
  text: str,
1006
927
  source_text: str,
@@ -1016,17 +937,17 @@ class AsyncTheTool:
1016
937
  timeout: float | None = None,
1017
938
  ) -> ToolOutput:
1018
939
  """
1019
- Checks wheather a statement is relevant to the source text or not.
940
+ Check whether a statement is a fact based on the source text
1020
941
 
1021
942
  Important Note: This tool is EXPERIMENTAL, you can use it but it isn't reliable.
1022
943
 
1023
944
  Arguments:
1024
945
  text: The input text
1025
- source_text: The source text that we want to check relation of text to it
1026
- with_analysis: Whether to include detailed reasoning analysis
1027
- output_lang: Language for the output
946
+ source_text: The source text
947
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
948
+ output_lang: Forces the model to respond in a specific language
1028
949
  user_prompt: Additional instructions
1029
- temperature: Controls randomness (0.0 - 2.0)
950
+ temperature: Controls randomness
1030
951
  logprobs: Whether to return token probability information
1031
952
  top_logprobs: Number of top token alternatives to return if logprobs enabled
1032
953
  validator: Custom validation function to validate the output
@@ -1037,11 +958,11 @@ class AsyncTheTool:
1037
958
  Returns:
1038
959
  ToolOutput
1039
960
  """
1040
- tool_name = "check_fact"
961
+ tool_name = "is_fact"
1041
962
  start = perf_counter()
1042
963
 
1043
964
  try:
1044
- operator_output = await run_with_timeout(
965
+ operator_output = await TheToolUtils.run_with_timeout(
1045
966
  self._operator.run(
1046
967
  # User parameters
1047
968
  text=text,
@@ -1097,15 +1018,15 @@ class AsyncTheTool:
1097
1018
  timeout: float | None = None,
1098
1019
  ) -> ToolOutput:
1099
1020
  """
1100
- Custom tool that can do almost anything!
1021
+ Custom tool that can do almost anything
1101
1022
 
1102
1023
  Arguments:
1103
1024
  prompt: The user prompt
1104
1025
  output_model: Pydantic BaseModel used for structured output
1105
- with_analysis: Whether to include detailed reasoning analysis
1026
+ with_analysis: Adds a reasoning step before generating the final output. Note: This doubles token usage per call
1106
1027
  analyze_template: The analyze template used for reasoning analysis
1107
- output_lang: Language for the output
1108
- temperature: Controls randomness (0.0 - 2.0)
1028
+ output_lang: Forces the model to respond in a specific language
1029
+ temperature: Controls randomness
1109
1030
  logprobs: Whether to return token probability information
1110
1031
  top_logprobs: Number of top token alternatives to return if logprobs enabled
1111
1032
  validator: Custom validation function to validate the output
@@ -1120,7 +1041,7 @@ class AsyncTheTool:
1120
1041
  start = perf_counter()
1121
1042
 
1122
1043
  try:
1123
- operator_output = await run_with_timeout(
1044
+ operator_output = await TheToolUtils.run_with_timeout(
1124
1045
  self._operator.run(
1125
1046
  # User paramaeters
1126
1047
  text=prompt,