swarmauri_tool_textlength 0.8.0.dev4__tar.gz → 0.8.0.dev21__tar.gz

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.
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarmauri_tool_textlength
3
+ Version: 0.8.0.dev21
4
+ Summary: Text Length Tool for Swarmauri
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: swarmauri,tool,textlength,text,length
8
+ Author: Jacob Stewart
9
+ Author-email: jacob@swarmauri.com
10
+ Requires-Python: >=3.10,<3.13
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Natural Language :: English
16
+ Classifier: Development Status :: 3 - Alpha
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
19
+ Requires-Dist: nltk (>=3.9.1)
20
+ Requires-Dist: swarmauri_base
21
+ Requires-Dist: swarmauri_core
22
+ Requires-Dist: swarmauri_standard
23
+ Description-Content-Type: text/markdown
24
+
25
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
26
+
27
+ <p align="center">
28
+ <a href="https://pypi.org/project/swarmauri_tool_textlength/">
29
+ <img src="https://img.shields.io/pypi/dm/swarmauri_tool_textlength" alt="PyPI - Downloads"/></a>
30
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_textlength/">
31
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_textlength.svg"/></a>
32
+ <a href="https://pypi.org/project/swarmauri_tool_textlength/">
33
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_tool_textlength" alt="PyPI - Python Version"/></a>
34
+ <a href="https://pypi.org/project/swarmauri_tool_textlength/">
35
+ <img src="https://img.shields.io/pypi/l/swarmauri_tool_textlength" alt="PyPI - License"/></a>
36
+ <a href="https://pypi.org/project/swarmauri_tool_textlength/">
37
+ <img src="https://img.shields.io/pypi/v/swarmauri_tool_textlength?label=swarmauri_tool_textlength&color=green" alt="PyPI - swarmauri_tool_textlength"/></a>
38
+ </p>
39
+
40
+ ---
41
+
42
+ # Swarmauri Tool · Text Length
43
+
44
+ A Swarmauri-ready helper that measures text length in characters, words, and sentences using NLTK tokenization. Drop it into content pipelines, moderation bots, or editorial agents to monitor message size and cadence.
45
+
46
+ - Counts characters (excluding spaces) for quick size checks.
47
+ - Uses NLTK tokenizers to calculate word and sentence totals accurately.
48
+ - Returns a structured dictionary suitable for logging, analytics, or conversational outputs.
49
+
50
+ ## Requirements
51
+
52
+ - Python 3.10 – 3.13.
53
+ - `nltk` with the `punkt_tab` resource available (downloaded automatically on import).
54
+ - Core Swarmauri dependencies (`swarmauri_base`, `swarmauri_standard`, `pydantic`).
55
+
56
+ ## Installation
57
+
58
+ Pick the packaging tool that fits your workflow; each command installs dependencies.
59
+
60
+ **pip**
61
+
62
+ ```bash
63
+ pip install swarmauri_tool_textlength
64
+ ```
65
+
66
+ **Poetry**
67
+
68
+ ```bash
69
+ poetry add swarmauri_tool_textlength
70
+ ```
71
+
72
+ **uv**
73
+
74
+ ```bash
75
+ # Add to the current project and update uv.lock
76
+ uv add swarmauri_tool_textlength
77
+
78
+ # or install into the active environment without editing pyproject.toml
79
+ uv pip install swarmauri_tool_textlength
80
+ ```
81
+
82
+ > Tip: When building containers or offline environments, pre-fetch NLTK data with `python -m nltk.downloader punkt_tab` to avoid runtime downloads.
83
+
84
+ ## Quick Start
85
+
86
+ ```python
87
+ from swarmauri_tool_textlength import TextLengthTool
88
+
89
+ text = "This is a simple test sentence."
90
+
91
+ length_tool = TextLengthTool()
92
+ result = length_tool(text)
93
+
94
+ print(result)
95
+ # {
96
+ # 'num_characters': 26,
97
+ # 'num_words': 7,
98
+ # 'num_sentences': 1
99
+ # }
100
+ ```
101
+
102
+ ## Usage Scenarios
103
+
104
+ ### Enforce Message Length in Moderation Bots
105
+
106
+ ```python
107
+ from swarmauri_tool_textlength import TextLengthTool
108
+
109
+ length_checker = TextLengthTool()
110
+ message = """Please keep replies under 50 words so the queue stays manageable."""
111
+
112
+ metrics = length_checker(message)
113
+ if metrics["num_words"] > 50:
114
+ raise ValueError("Message too long for moderation queue")
115
+ ```
116
+
117
+ ### Provide Real-Time Feedback in a Swarmauri Agent
118
+
119
+ ```python
120
+ from swarmauri_core.agent.Agent import Agent
121
+ from swarmauri_core.messages.HumanMessage import HumanMessage
122
+ from swarmauri_standard.tools.registry import ToolRegistry
123
+ from swarmauri_tool_textlength import TextLengthTool
124
+
125
+ registry = ToolRegistry()
126
+ registry.register(TextLengthTool())
127
+ agent = Agent(tool_registry=registry)
128
+
129
+ message = HumanMessage(content="Analyze how long this paragraph is compared to our guideline.")
130
+ response = agent.run(message)
131
+ print(response)
132
+ ```
133
+
134
+ ### Batch Audit Documentation for Sentence Length
135
+
136
+ ```python
137
+ from pathlib import Path
138
+ from swarmauri_tool_textlength import TextLengthTool
139
+
140
+ length_tool = TextLengthTool()
141
+
142
+ for doc in Path("docs").rglob("*.md"):
143
+ metrics = length_tool(doc.read_text(encoding="utf-8"))
144
+ print(f"{doc}: {metrics['num_sentences']} sentences, {metrics['num_words']} words")
145
+ ```
146
+
147
+ Scan an entire documentation set to identify sprawling sections or under-documented topics.
148
+
149
+ ## Troubleshooting
150
+
151
+ - **`LookupError: Resource punkt_tab not found`** – Run `python -m nltk.downloader punkt_tab` ahead of time, especially in air-gapped deployments.
152
+ - **Unexpected character counts** – The tool excludes spaces; adjust the implementation if you need raw length including whitespace.
153
+ - **Non-English text** – NLTK’s default tokenizers target English. Swap in language-specific tokenizers if needed.
154
+
155
+ ## License
156
+
157
+ `swarmauri_tool_textlength` is released under the Apache 2.0 License. See `LICENSE` for full details.
158
+
@@ -0,0 +1,133 @@
1
+ ![Swarmauri Logo](https://github.com/swarmauri/swarmauri-sdk/blob/3d4d1cfa949399d7019ae9d8f296afba773dfb7f/assets/swarmauri.brand.theme.svg)
2
+
3
+ <p align="center">
4
+ <a href="https://pypi.org/project/swarmauri_tool_textlength/">
5
+ <img src="https://img.shields.io/pypi/dm/swarmauri_tool_textlength" alt="PyPI - Downloads"/></a>
6
+ <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_textlength/">
7
+ <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_textlength.svg"/></a>
8
+ <a href="https://pypi.org/project/swarmauri_tool_textlength/">
9
+ <img src="https://img.shields.io/pypi/pyversions/swarmauri_tool_textlength" alt="PyPI - Python Version"/></a>
10
+ <a href="https://pypi.org/project/swarmauri_tool_textlength/">
11
+ <img src="https://img.shields.io/pypi/l/swarmauri_tool_textlength" alt="PyPI - License"/></a>
12
+ <a href="https://pypi.org/project/swarmauri_tool_textlength/">
13
+ <img src="https://img.shields.io/pypi/v/swarmauri_tool_textlength?label=swarmauri_tool_textlength&color=green" alt="PyPI - swarmauri_tool_textlength"/></a>
14
+ </p>
15
+
16
+ ---
17
+
18
+ # Swarmauri Tool · Text Length
19
+
20
+ A Swarmauri-ready helper that measures text length in characters, words, and sentences using NLTK tokenization. Drop it into content pipelines, moderation bots, or editorial agents to monitor message size and cadence.
21
+
22
+ - Counts characters (excluding spaces) for quick size checks.
23
+ - Uses NLTK tokenizers to calculate word and sentence totals accurately.
24
+ - Returns a structured dictionary suitable for logging, analytics, or conversational outputs.
25
+
26
+ ## Requirements
27
+
28
+ - Python 3.10 – 3.13.
29
+ - `nltk` with the `punkt_tab` resource available (downloaded automatically on import).
30
+ - Core Swarmauri dependencies (`swarmauri_base`, `swarmauri_standard`, `pydantic`).
31
+
32
+ ## Installation
33
+
34
+ Pick the packaging tool that fits your workflow; each command installs dependencies.
35
+
36
+ **pip**
37
+
38
+ ```bash
39
+ pip install swarmauri_tool_textlength
40
+ ```
41
+
42
+ **Poetry**
43
+
44
+ ```bash
45
+ poetry add swarmauri_tool_textlength
46
+ ```
47
+
48
+ **uv**
49
+
50
+ ```bash
51
+ # Add to the current project and update uv.lock
52
+ uv add swarmauri_tool_textlength
53
+
54
+ # or install into the active environment without editing pyproject.toml
55
+ uv pip install swarmauri_tool_textlength
56
+ ```
57
+
58
+ > Tip: When building containers or offline environments, pre-fetch NLTK data with `python -m nltk.downloader punkt_tab` to avoid runtime downloads.
59
+
60
+ ## Quick Start
61
+
62
+ ```python
63
+ from swarmauri_tool_textlength import TextLengthTool
64
+
65
+ text = "This is a simple test sentence."
66
+
67
+ length_tool = TextLengthTool()
68
+ result = length_tool(text)
69
+
70
+ print(result)
71
+ # {
72
+ # 'num_characters': 26,
73
+ # 'num_words': 7,
74
+ # 'num_sentences': 1
75
+ # }
76
+ ```
77
+
78
+ ## Usage Scenarios
79
+
80
+ ### Enforce Message Length in Moderation Bots
81
+
82
+ ```python
83
+ from swarmauri_tool_textlength import TextLengthTool
84
+
85
+ length_checker = TextLengthTool()
86
+ message = """Please keep replies under 50 words so the queue stays manageable."""
87
+
88
+ metrics = length_checker(message)
89
+ if metrics["num_words"] > 50:
90
+ raise ValueError("Message too long for moderation queue")
91
+ ```
92
+
93
+ ### Provide Real-Time Feedback in a Swarmauri Agent
94
+
95
+ ```python
96
+ from swarmauri_core.agent.Agent import Agent
97
+ from swarmauri_core.messages.HumanMessage import HumanMessage
98
+ from swarmauri_standard.tools.registry import ToolRegistry
99
+ from swarmauri_tool_textlength import TextLengthTool
100
+
101
+ registry = ToolRegistry()
102
+ registry.register(TextLengthTool())
103
+ agent = Agent(tool_registry=registry)
104
+
105
+ message = HumanMessage(content="Analyze how long this paragraph is compared to our guideline.")
106
+ response = agent.run(message)
107
+ print(response)
108
+ ```
109
+
110
+ ### Batch Audit Documentation for Sentence Length
111
+
112
+ ```python
113
+ from pathlib import Path
114
+ from swarmauri_tool_textlength import TextLengthTool
115
+
116
+ length_tool = TextLengthTool()
117
+
118
+ for doc in Path("docs").rglob("*.md"):
119
+ metrics = length_tool(doc.read_text(encoding="utf-8"))
120
+ print(f"{doc}: {metrics['num_sentences']} sentences, {metrics['num_words']} words")
121
+ ```
122
+
123
+ Scan an entire documentation set to identify sprawling sections or under-documented topics.
124
+
125
+ ## Troubleshooting
126
+
127
+ - **`LookupError: Resource punkt_tab not found`** – Run `python -m nltk.downloader punkt_tab` ahead of time, especially in air-gapped deployments.
128
+ - **Unexpected character counts** – The tool excludes spaces; adjust the implementation if you need raw length including whitespace.
129
+ - **Non-English text** – NLTK’s default tokenizers target English. Swap in language-specific tokenizers if needed.
130
+
131
+ ## License
132
+
133
+ `swarmauri_tool_textlength` is released under the Apache 2.0 License. See `LICENSE` for full details.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "swarmauri_tool_textlength"
3
- version = "0.8.0.dev4"
3
+ version = "0.8.0.dev21"
4
4
  description = "Text Length Tool for Swarmauri"
5
5
  license = "Apache-2.0"
6
6
  readme = "README.md"
@@ -11,6 +11,10 @@ classifiers = [
11
11
  "Programming Language :: Python :: 3.10",
12
12
  "Programming Language :: Python :: 3.11",
13
13
  "Programming Language :: Python :: 3.12",
14
+ "Natural Language :: English",
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
14
18
  ]
15
19
  authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
16
20
  dependencies = [
@@ -19,6 +23,13 @@ dependencies = [
19
23
  "swarmauri_base",
20
24
  "swarmauri_standard",
21
25
  ]
26
+ keywords = [
27
+ "swarmauri",
28
+ "tool",
29
+ "textlength",
30
+ "text",
31
+ "length",
32
+ ]
22
33
 
23
34
  [tool.uv.sources]
24
35
  swarmauri_core = { workspace = true }
@@ -1,70 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: swarmauri_tool_textlength
3
- Version: 0.8.0.dev4
4
- Summary: Text Length Tool for Swarmauri
5
- License: Apache-2.0
6
- Author: Jacob Stewart
7
- Author-email: jacob@swarmauri.com
8
- Requires-Python: >=3.10,<3.13
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Programming Language :: Python :: 3.10
11
- Classifier: Programming Language :: Python :: 3.11
12
- Classifier: Programming Language :: Python :: 3.12
13
- Requires-Dist: nltk (>=3.9.1)
14
- Requires-Dist: swarmauri_base
15
- Requires-Dist: swarmauri_core
16
- Requires-Dist: swarmauri_standard
17
- Description-Content-Type: text/markdown
18
-
19
-
20
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
21
-
22
- <p align="center">
23
- <a href="https://pypi.org/project/swarmauri_tool_textlength/">
24
- <img src="https://img.shields.io/pypi/dm/swarmauri_tool_textlength" alt="PyPI - Downloads"/></a>
25
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_textlength/">
26
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_textlength.svg"/></a>
27
- <a href="https://pypi.org/project/swarmauri_tool_textlength/">
28
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_tool_textlength" alt="PyPI - Python Version"/></a>
29
- <a href="https://pypi.org/project/swarmauri_tool_textlength/">
30
- <img src="https://img.shields.io/pypi/l/swarmauri_tool_textlength" alt="PyPI - License"/></a>
31
- <a href="https://pypi.org/project/swarmauri_tool_textlength/">
32
- <img src="https://img.shields.io/pypi/v/swarmauri_tool_textlength?label=swarmauri_tool_textlength&color=green" alt="PyPI - swarmauri_tool_textlength"/></a>
33
- </p>
34
-
35
- ---
36
-
37
- # Swarmauri Tool Text Length
38
-
39
- A Swarmauri tool that calculates the length of text in terms of characters, words, and sentences using NLTK tokenization.
40
-
41
- ## Installation
42
-
43
- ```bash
44
- pip install swarmauri_tool_textlength
45
- ```
46
-
47
- ## Usage
48
- Here's a simple example of how to use the TextLengthTool:
49
-
50
- ```python
51
- from swarmauri.tools.TextLengthTool import TextLengthTool
52
-
53
- # Initialize the tool
54
- tool = TextLengthTool()
55
-
56
- # Analyze text
57
- text = "This is a simple test sentence."
58
- result = tool(text)
59
-
60
- # Access the results
61
- print(f"Characters: {result['num_characters']}") # 26
62
- print(f"Words: {result['num_words']}") # 7
63
- print(f"Sentences: {result['num_sentences']}") # 1
64
- ```
65
-
66
- ## Want to help?
67
-
68
- If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
69
-
70
-
@@ -1,51 +0,0 @@
1
-
2
- ![Swamauri Logo](https://res.cloudinary.com/dbjmpekvl/image/upload/v1730099724/Swarmauri-logo-lockup-2048x757_hww01w.png)
3
-
4
- <p align="center">
5
- <a href="https://pypi.org/project/swarmauri_tool_textlength/">
6
- <img src="https://img.shields.io/pypi/dm/swarmauri_tool_textlength" alt="PyPI - Downloads"/></a>
7
- <a href="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_textlength/">
8
- <img alt="Hits" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/tree/master/pkgs/community/swarmauri_tool_textlength.svg"/></a>
9
- <a href="https://pypi.org/project/swarmauri_tool_textlength/">
10
- <img src="https://img.shields.io/pypi/pyversions/swarmauri_tool_textlength" alt="PyPI - Python Version"/></a>
11
- <a href="https://pypi.org/project/swarmauri_tool_textlength/">
12
- <img src="https://img.shields.io/pypi/l/swarmauri_tool_textlength" alt="PyPI - License"/></a>
13
- <a href="https://pypi.org/project/swarmauri_tool_textlength/">
14
- <img src="https://img.shields.io/pypi/v/swarmauri_tool_textlength?label=swarmauri_tool_textlength&color=green" alt="PyPI - swarmauri_tool_textlength"/></a>
15
- </p>
16
-
17
- ---
18
-
19
- # Swarmauri Tool Text Length
20
-
21
- A Swarmauri tool that calculates the length of text in terms of characters, words, and sentences using NLTK tokenization.
22
-
23
- ## Installation
24
-
25
- ```bash
26
- pip install swarmauri_tool_textlength
27
- ```
28
-
29
- ## Usage
30
- Here's a simple example of how to use the TextLengthTool:
31
-
32
- ```python
33
- from swarmauri.tools.TextLengthTool import TextLengthTool
34
-
35
- # Initialize the tool
36
- tool = TextLengthTool()
37
-
38
- # Analyze text
39
- text = "This is a simple test sentence."
40
- result = tool(text)
41
-
42
- # Access the results
43
- print(f"Characters: {result['num_characters']}") # 26
44
- print(f"Words: {result['num_words']}") # 7
45
- print(f"Sentences: {result['num_sentences']}") # 1
46
- ```
47
-
48
- ## Want to help?
49
-
50
- If you want to contribute to swarmauri-sdk, read up on our [guidelines for contributing](https://github.com/swarmauri/swarmauri-sdk/blob/master/contributing.md) that will help you get started.
51
-