Name | hamtaa-texttools JSON |
Version |
1.0.9
JSON |
| download |
home_page | None |
Summary | A high-level NLP toolkit built on top of modern LLMs. |
upload_time | 2025-10-22 09:25:59 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT License Copyright (c) 2025 Hamtaa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
nlp
llm
text-processing
openai
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# TextTools
## 📌 Overview
**TextTools** is a high-level **NLP toolkit** built on top of modern **LLMs**.
It provides both **sync (`TheTool`)** and **async (`AsyncTheTool`)** APIs for maximum flexibility.
It provides ready-to-use utilities for **translation, question detection, keyword extraction, categorization, NER extractor, and more** — designed to help you integrate AI-powered text processing into your applications with minimal effort.
---
## ✨ Features
TextTools provides a rich collection of high-level NLP utilities built on top of LLMs.
Each tool is designed to work out-of-the-box with structured outputs (JSON / Pydantic).
- **`categorize()`** - Classifies text into Islamic studies categories
- **`is_question()`** - Binary detection of whether input is a question
- **`extract_keywords()`** - Extracts keywords from text
- **`extract_entities()`** - Named Entity Recognition (NER) system
- **`summarize()`** - Text summarization
- **`text_to_question()`** - Generates questions from text
- **`merge_questions()`** - Merges multiple questions with different modes
- **`rewrite()`** - Rewrites text with different wording/meaning
- **`subject_to_question()`** - Generates questions about a specific subject
- **`translate()`** - Text translation between languages
- **`run_custom()`** - Allows users to define a custom tool with arbitrary BaseModel
---
## ⚙️ `with_analysis`, `logprobs`, `output_lang`, and `user_prompt` parameters
TextTools provides several optional flags to customize LLM behavior:
- **`with_analysis=True`** → Adds a reasoning step before generating the final output. Useful for debugging, improving prompts, or understanding model behavior.
Note: This doubles token usage per call because it triggers an additional LLM request.
- **`logprobs=True`** → Returns token-level probabilities for the generated output. You can also specify `top_logprobs=<N>` to get the top N alternative tokens and their probabilities.
- **`output_lang="en"`** → Forces the model to respond in a specific language. The model will ignore other instructions about language and respond strictly in the requested language.
- **`user_prompt="..."`** → Allows you to inject a custom instruction or prompt into the model alongside the main template. This gives you fine-grained control over how the model interprets or modifies the input text.
- **`temperature=0.0`** → Determines how creative the model should respond. Takes a float number from `0.0` to `1.0`.
All these parameters can be used individually or together to tailor the behavior of any tool in **TextTools**.
**Note:** There might be some tools that don't support some of the parameters above.
---
## 🚀 Installation
Install the latest release via PyPI:
```bash
pip install -U hamtaa-texttools
```
---
## Sync vs Async
| Tool | Style | Use case |
|--------------|---------|---------------------------------------------|
| `TheTool` | Sync | Simple scripts, sequential workflows |
| `AsyncTheTool` | Async | High-throughput apps, APIs, concurrent tasks |
---
## ⚡ Quick Start (Sync)
```python
from openai import OpenAI
from texttools import TheTool
# Create your OpenAI client
client = OpenAI(base_url = "your_url", API_KEY = "your_api_key")
# Specify the model
model = "gpt-4o-mini"
# Create an instance of TheTool
the_tool = TheTool(client=client, model=model)
# Example: Question Detection
detection = the_tool.is_question("Is this project open source?", logprobs=True, top_logprobs=2)
print(detection["result"])
print(detection["logprobs"])
# Output: True \n --logprobs
# Example: Translation
translation = the_tool.translate("سلام، حالت چطوره؟" target_language="English", with_analysis=True)
print(translation["result"])
print(translation["analysis"])
# Output: "Hi! How are you?" \n --analysis
```
---
## ⚡ Quick Start (Async)
```python
import asyncio
from openai import AsyncOpenAI
from texttools import AsyncTheTool
async def main():
# Create your AsyncOpenAI client
async_client = AsyncOpenAI(base_url="your_url", api_key="your_api_key")
# Specify the model
model = "gpt-4o-mini"
# Create an instance of AsyncTheTool
the_tool = AsyncTheTool(client=async_client, model=model)
# Example: Async Translation
result = await the_tool.translate("سلام، حالت چطوره؟", target_language="English")
print(result["result"])
# Output: "Hi! How are you?"
asyncio.run(main())
```
---
## 📚 Use Cases
Use **TextTools** when you need to:
- 🔍 **Classify** large datasets quickly without model training
- 🌍 **Translate** and process multilingual corpora with ease
- 🧩 **Integrate** LLMs into production pipelines (structured outputs)
- 📊 **Analyze** large text collections using embeddings and categorization
- 👍 **Automate** common text-processing tasks without reinventing the wheel
---
## 🤝 Contributing
Contributions are welcome!
Feel free to **open issues, suggest new features, or submit pull requests**.
---
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "hamtaa-texttools",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "nlp, llm, text-processing, openai",
"author": null,
"author_email": "Tohidi <the.mohammad.tohidi@gmail.com>, Montazer <montazerh82@gmail.com>, Givechi <mohamad.m.givechi@gmail.com>, MoosaviNejad <erfanmoosavi84@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/20/83/aa03e0113a1799ba0e8d0925a2f52a5910ff5ff88fb8f4ec1a98ba02fca4/hamtaa_texttools-1.0.9.tar.gz",
"platform": null,
"description": "# TextTools\r\n\r\n## \ud83d\udccc Overview\r\n\r\n**TextTools** is a high-level **NLP toolkit** built on top of modern **LLMs**. \r\n\r\nIt provides both **sync (`TheTool`)** and **async (`AsyncTheTool`)** APIs for maximum flexibility.\r\n\r\nIt provides ready-to-use utilities for **translation, question detection, keyword extraction, categorization, NER extractor, and more** \u2014 designed to help you integrate AI-powered text processing into your applications with minimal effort.\r\n\r\n---\r\n\r\n## \u2728 Features\r\n\r\nTextTools provides a rich collection of high-level NLP utilities built on top of LLMs. \r\nEach tool is designed to work out-of-the-box with structured outputs (JSON / Pydantic).\r\n\r\n- **`categorize()`** - Classifies text into Islamic studies categories \r\n- **`is_question()`** - Binary detection of whether input is a question\r\n- **`extract_keywords()`** - Extracts keywords from text\r\n- **`extract_entities()`** - Named Entity Recognition (NER) system\r\n- **`summarize()`** - Text summarization\r\n- **`text_to_question()`** - Generates questions from text\r\n- **`merge_questions()`** - Merges multiple questions with different modes\r\n- **`rewrite()`** - Rewrites text with different wording/meaning\r\n- **`subject_to_question()`** - Generates questions about a specific subject\r\n- **`translate()`** - Text translation between languages\r\n- **`run_custom()`** - Allows users to define a custom tool with arbitrary BaseModel\r\n\r\n---\r\n\r\n## \u2699\ufe0f `with_analysis`, `logprobs`, `output_lang`, and `user_prompt` parameters\r\n\r\nTextTools provides several optional flags to customize LLM behavior:\r\n\r\n- **`with_analysis=True`** \u2192 Adds a reasoning step before generating the final output. Useful for debugging, improving prompts, or understanding model behavior. \r\nNote: This doubles token usage per call because it triggers an additional LLM request.\r\n\r\n- **`logprobs=True`** \u2192 Returns token-level probabilities for the generated output. You can also specify `top_logprobs=<N>` to get the top N alternative tokens and their probabilities. \r\n\r\n- **`output_lang=\"en\"`** \u2192 Forces the model to respond in a specific language. The model will ignore other instructions about language and respond strictly in the requested language.\r\n\r\n- **`user_prompt=\"...\"`** \u2192 Allows you to inject a custom instruction or prompt into the model alongside the main template. This gives you fine-grained control over how the model interprets or modifies the input text.\r\n\r\n- **`temperature=0.0`** \u2192 Determines how creative the model should respond. Takes a float number from `0.0` to `1.0`.\r\n\r\nAll these parameters can be used individually or together to tailor the behavior of any tool in **TextTools**.\r\n\r\n**Note:** There might be some tools that don't support some of the parameters above.\r\n\r\n---\r\n\r\n## \ud83d\ude80 Installation\r\n\r\nInstall the latest release via PyPI:\r\n\r\n```bash\r\npip install -U hamtaa-texttools\r\n```\r\n\r\n---\r\n\r\n## Sync vs Async\r\n| Tool | Style | Use case |\r\n|--------------|---------|---------------------------------------------|\r\n| `TheTool` | Sync | Simple scripts, sequential workflows |\r\n| `AsyncTheTool` | Async | High-throughput apps, APIs, concurrent tasks |\r\n\r\n---\r\n\r\n## \u26a1 Quick Start (Sync)\r\n\r\n```python\r\nfrom openai import OpenAI\r\nfrom texttools import TheTool\r\n\r\n# Create your OpenAI client\r\nclient = OpenAI(base_url = \"your_url\", API_KEY = \"your_api_key\")\r\n\r\n# Specify the model\r\nmodel = \"gpt-4o-mini\"\r\n\r\n# Create an instance of TheTool\r\nthe_tool = TheTool(client=client, model=model)\r\n\r\n# Example: Question Detection\r\ndetection = the_tool.is_question(\"Is this project open source?\", logprobs=True, top_logprobs=2)\r\nprint(detection[\"result\"])\r\nprint(detection[\"logprobs\"])\r\n# Output: True \\n --logprobs\r\n\r\n# Example: Translation\r\ntranslation = the_tool.translate(\"\u0633\u0644\u0627\u0645\u060c \u062d\u0627\u0644\u062a \u0686\u0637\u0648\u0631\u0647\u061f\" target_language=\"English\", with_analysis=True)\r\nprint(translation[\"result\"])\r\nprint(translation[\"analysis\"])\r\n# Output: \"Hi! How are you?\" \\n --analysis\r\n```\r\n\r\n---\r\n\r\n## \u26a1 Quick Start (Async)\r\n\r\n```python\r\nimport asyncio\r\nfrom openai import AsyncOpenAI\r\nfrom texttools import AsyncTheTool\r\n\r\nasync def main():\r\n # Create your AsyncOpenAI client\r\n async_client = AsyncOpenAI(base_url=\"your_url\", api_key=\"your_api_key\")\r\n\r\n # Specify the model\r\n model = \"gpt-4o-mini\"\r\n\r\n # Create an instance of AsyncTheTool\r\n the_tool = AsyncTheTool(client=async_client, model=model)\r\n\r\n # Example: Async Translation\r\n result = await the_tool.translate(\"\u0633\u0644\u0627\u0645\u060c \u062d\u0627\u0644\u062a \u0686\u0637\u0648\u0631\u0647\u061f\", target_language=\"English\")\r\n print(result[\"result\"])\r\n # Output: \"Hi! How are you?\"\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udcda Use Cases\r\n\r\nUse **TextTools** when you need to:\r\n\r\n- \ud83d\udd0d **Classify** large datasets quickly without model training \r\n- \ud83c\udf0d **Translate** and process multilingual corpora with ease \r\n- \ud83e\udde9 **Integrate** LLMs into production pipelines (structured outputs) \r\n- \ud83d\udcca **Analyze** large text collections using embeddings and categorization \r\n- \ud83d\udc4d **Automate** common text-processing tasks without reinventing the wheel \r\n\r\n---\r\n\r\n## \ud83e\udd1d Contributing\r\n\r\nContributions are welcome! \r\nFeel free to **open issues, suggest new features, or submit pull requests**. \r\n\r\n---\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2025 Hamtaa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A high-level NLP toolkit built on top of modern LLMs.",
"version": "1.0.9",
"project_urls": null,
"split_keywords": [
"nlp",
" llm",
" text-processing",
" openai"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "df2b9763b74659492476fe39d2921473d36aea61f8d990ee391e04fca8208ef3",
"md5": "9bce71e0b67b5b98544b34eae827bb1f",
"sha256": "fd832f0d5acf2521463ec3572e930c71d3fc0ecfe3cb673df92347a283933284"
},
"downloads": -1,
"filename": "hamtaa_texttools-1.0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9bce71e0b67b5b98544b34eae827bb1f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 31103,
"upload_time": "2025-10-22T09:25:58",
"upload_time_iso_8601": "2025-10-22T09:25:58.350842Z",
"url": "https://files.pythonhosted.org/packages/df/2b/9763b74659492476fe39d2921473d36aea61f8d990ee391e04fca8208ef3/hamtaa_texttools-1.0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "2083aa03e0113a1799ba0e8d0925a2f52a5910ff5ff88fb8f4ec1a98ba02fca4",
"md5": "2ccb0db9cf6a6e9ecd5b6bd34132f6d1",
"sha256": "6085c93dcb68ab4a0f46ab4142bcdfcf6fe4fbfb9add2b3eddc6e6daa7f8b643"
},
"downloads": -1,
"filename": "hamtaa_texttools-1.0.9.tar.gz",
"has_sig": false,
"md5_digest": "2ccb0db9cf6a6e9ecd5b6bd34132f6d1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 22229,
"upload_time": "2025-10-22T09:25:59",
"upload_time_iso_8601": "2025-10-22T09:25:59.730347Z",
"url": "https://files.pythonhosted.org/packages/20/83/aa03e0113a1799ba0e8d0925a2f52a5910ff5ff88fb8f4ec1a98ba02fca4/hamtaa_texttools-1.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-22 09:25:59",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "hamtaa-texttools"
}