hamtaa-texttools 1.0.9__py3-none-any.whl → 1.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.

Potentially problematic release.


This version of hamtaa-texttools might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hamtaa-texttools
3
- Version: 1.0.9
3
+ Version: 1.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>, Montazer <montazerh82@gmail.com>, Givechi <mohamad.m.givechi@gmail.com>, MoosaviNejad <erfanmoosavi84@gmail.com>
6
6
  License: MIT License
@@ -63,7 +63,7 @@ Each tool is designed to work out-of-the-box with structured outputs (JSON / Pyd
63
63
 
64
64
  ---
65
65
 
66
- ## ⚙️ `with_analysis`, `logprobs`, `output_lang`, and `user_prompt` parameters
66
+ ## ⚙️ `with_analysis`, `logprobs`, `output_lang`, `user_prompt` and `temperature` parameters
67
67
 
68
68
  TextTools provides several optional flags to customize LLM behavior:
69
69
 
@@ -119,14 +119,14 @@ the_tool = TheTool(client=client, model=model)
119
119
 
120
120
  # Example: Question Detection
121
121
  detection = the_tool.is_question("Is this project open source?", logprobs=True, top_logprobs=2)
122
- print(detection["result"])
123
- print(detection["logprobs"])
122
+ print(detection.result)
123
+ print(detection.logprobs)
124
124
  # Output: True \n --logprobs
125
125
 
126
126
  # Example: Translation
127
127
  translation = the_tool.translate("سلام، حالت چطوره؟" target_language="English", with_analysis=True)
128
- print(translation["result"])
129
- print(translation["analysis"])
128
+ print(translation.result)
129
+ print(translation.analysis)
130
130
  # Output: "Hi! How are you?" \n --analysis
131
131
  ```
132
132
 
@@ -150,8 +150,8 @@ async def main():
150
150
  the_tool = AsyncTheTool(client=async_client, model=model)
151
151
 
152
152
  # Example: Async Translation
153
- result = await the_tool.translate("سلام، حالت چطوره؟", target_language="English")
154
- print(result["result"])
153
+ translation = await the_tool.translate("سلام، حالت چطوره؟", target_language="English")
154
+ print(translation.result)
155
155
  # Output: "Hi! How are you?"
156
156
 
157
157
  asyncio.run(main())
@@ -1,4 +1,4 @@
1
- hamtaa_texttools-1.0.9.dist-info/licenses/LICENSE,sha256=Hb2YOBKy2MJQLnyLrX37B4ZVuac8eaIcE71SvVIMOLg,1082
1
+ hamtaa_texttools-1.1.0.dist-info/licenses/LICENSE,sha256=Hb2YOBKy2MJQLnyLrX37B4ZVuac8eaIcE71SvVIMOLg,1082
2
2
  texttools/__init__.py,sha256=v3tQCH_Cjj47fCpuhK6sKSVAqEjNkc-cZbY4OJa4IZw,202
3
3
  texttools/batch/__init__.py,sha256=q50JsQsmQGp_8RW0KNasYeYWVV0R4FUNZ-ujXwEJemY,143
4
4
  texttools/batch/batch_manager.py,sha256=leVIFkR-3HpDkQi_MK3TgFNnHYsCN-wbS4mTWoPmO3c,8828
@@ -18,13 +18,13 @@ texttools/prompts/translate.yaml,sha256=mGT2uBCei6uucWqVbs4silk-UV060v3G0jnt0P6s
18
18
  texttools/tools/__init__.py,sha256=hG1I28Q7BJ1Dbs95x6QMKXdsAlC5Eh_tqC-EbAibwiU,114
19
19
  texttools/tools/async_the_tool.py,sha256=9VY6ym7SvQqlokt0mwAwnytmu1CUIehDmnAvx74Z78o,12480
20
20
  texttools/tools/the_tool.py,sha256=JtQolr6i_6xogtuhX6IhyudFyAsitQy5NfSxUJAS-iA,12246
21
- texttools/tools/internals/async_operator.py,sha256=GPTHsjldQlmNYXkGCyypc9ENIxjeHUIHWWJ_ltUyNfs,6006
21
+ texttools/tools/internals/async_operator.py,sha256=Kj-DLBKcKbZPCJYn4lVo4Iiei11M04pwgWpIl8L69aM,6169
22
22
  texttools/tools/internals/base_operator.py,sha256=OWJe8ybA6qmmoc7ysYeB8ccHPneDlEtmFGH1jLWQCeY,3135
23
23
  texttools/tools/internals/formatters.py,sha256=tACNLP6PeoqaRpNudVxBaHA25zyWqWYPZQuYysIu88g,941
24
- texttools/tools/internals/operator.py,sha256=gl_vzcLueYi6cbxjIHhOCBtyhM6UXwJJ9Mstj8bA-Mg,5896
25
- texttools/tools/internals/output_models.py,sha256=Rf2x-UuGlmQHrvYIqnD11YuzMH_mPuir62HoMJQa2uk,1528
24
+ texttools/tools/internals/operator.py,sha256=g1E1WkgnKRDgOs6fEFu0-gPCw1Bniwb4VI9Er3Op_gk,6063
25
+ texttools/tools/internals/output_models.py,sha256=gbVbzBWeyHUVNsCBuawdgz9ZEzsC7wfygGgZJsAaexY,1662
26
26
  texttools/tools/internals/prompt_loader.py,sha256=rbitJD3e8vAdcooP1Yx6KnSI83g28ho-FegfZ1cJ4j4,1979
27
- hamtaa_texttools-1.0.9.dist-info/METADATA,sha256=mehOxCOj3f4MHTMwNEEHlSVMYVXgUuKZBysR0jcG2OU,7135
28
- hamtaa_texttools-1.0.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- hamtaa_texttools-1.0.9.dist-info/top_level.txt,sha256=5Mh0jIxxZ5rOXHGJ6Mp-JPKviywwN0MYuH0xk5bEWqE,10
30
- hamtaa_texttools-1.0.9.dist-info/RECORD,,
27
+ hamtaa_texttools-1.1.0.dist-info/METADATA,sha256=2IllcLt4gku7lqVQ-hueY1ccV2l0xaSE001aOizzvcg,7144
28
+ hamtaa_texttools-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
+ hamtaa_texttools-1.1.0.dist-info/top_level.txt,sha256=5Mh0jIxxZ5rOXHGJ6Mp-JPKviywwN0MYuH0xk5bEWqE,10
30
+ hamtaa_texttools-1.1.0.dist-info/RECORD,,
@@ -4,6 +4,7 @@ import logging
4
4
  from openai import AsyncOpenAI
5
5
  from pydantic import BaseModel
6
6
 
7
+ from texttools.tools.internals.output_models import ToolOutput
7
8
  from texttools.tools.internals.base_operator import BaseOperator
8
9
  from texttools.tools.internals.formatters import Formatter
9
10
  from texttools.tools.internals.prompt_loader import PromptLoader
@@ -152,7 +153,7 @@ class AsyncOperator(BaseOperator):
152
153
  messages, output_model, temperature, logprobs, top_logprobs
153
154
  )
154
155
  elif resp_format == "parse":
155
- parsed, completion = await self._vllm_completion(
156
+ parsed, completion = await self._parse_completion(
156
157
  messages, output_model, temperature, logprobs, top_logprobs
157
158
  )
158
159
 
@@ -162,16 +163,17 @@ class AsyncOperator(BaseOperator):
162
163
  "The provided output_model must define a field named 'result'"
163
164
  )
164
165
 
165
- results = {"result": parsed.result}
166
+ output = ToolOutput(result="", analysis="", logprobs=[], errors=[])
167
+
168
+ output.result = parsed.result
166
169
 
167
170
  if logprobs:
168
- results["logprobs"] = self._extract_logprobs(completion)
171
+ output.logprobs = self._extract_logprobs(completion)
169
172
 
170
173
  if with_analysis:
171
- results["analysis"] = analysis
172
-
173
- return results
174
+ output.analysis = analysis
174
175
 
176
+ return output
175
177
  except Exception as e:
176
- logger.error(f"Async TheTool failed: {e}")
177
- return {"error": str(e), "result": ""}
178
+ logger.error(f"AsyncTheTool failed: {e}")
179
+ return ToolOutput(result="", analysis="", logprobs=[], errors=[str(e)])
@@ -4,6 +4,7 @@ import logging
4
4
  from openai import OpenAI
5
5
  from pydantic import BaseModel
6
6
 
7
+ from texttools.tools.internals.output_models import ToolOutput
7
8
  from texttools.tools.internals.base_operator import BaseOperator
8
9
  from texttools.tools.internals.formatters import Formatter
9
10
  from texttools.tools.internals.prompt_loader import PromptLoader
@@ -162,16 +163,17 @@ class Operator(BaseOperator):
162
163
  "The provided output_model must define a field named 'result'"
163
164
  )
164
165
 
165
- result = {"result": parsed.result}
166
+ output = ToolOutput(result="", analysis="", logprobs=[], errors=[])
167
+
168
+ output.result = parsed.result
166
169
 
167
170
  if logprobs:
168
- result["logprobs"] = self._extract_logprobs(completion)
171
+ output.logprobs = self._extract_logprobs(completion)
169
172
 
170
173
  if with_analysis:
171
- result["analysis"] = analysis
172
-
173
- return result
174
+ output.analysis = analysis
174
175
 
176
+ return output
175
177
  except Exception as e:
176
178
  logger.error(f"TheTool failed: {e}")
177
- return {"error": str(e), "result": ""}
179
+ return ToolOutput(result="", analysis="", logprobs=[], errors=[str(e)])
@@ -1,8 +1,15 @@
1
- from typing import Literal
1
+ from typing import Literal, Any
2
2
 
3
3
  from pydantic import BaseModel, Field
4
4
 
5
5
 
6
+ class ToolOutput(BaseModel):
7
+ result: str
8
+ analysis: str
9
+ logprobs: list[dict[str, Any]]
10
+ errors: list[str]
11
+
12
+
6
13
  class StrOutput(BaseModel):
7
14
  result: str = Field(..., description="The output string")
8
15