Unit tests for plain text
Project description
unit-text
Unit tests for plain text
Don't let LLMs write blog posts for you. Do your research, bring your own voice, and use LLMs to criticise and iterate on your writing.
🤌 Why unit-text?
If you're a developer like us:
- You're probably aware you should write more (either because your leadership asks for it, or because you'd like to be invited as a conference speaker, or ...)
- You don't know what to write about.
- You have considered letting ChatGPT write blog posts for you.
If you tried the last option (or read anything on the Internet in the past 2 years) you would also know why it's not really that good of an idea.
Sure, you may get a perfectly good post, but it won't be your own.
unit-text applies the concept of unit tests to prose. You are the one writing, the LLM is just your critic.
First, you define a goal, the audience you have in mind,
and what you wanted them to do differently after they read your post.
Then, you start writing and iterating on your draft. unit-text gives you feedback: you run tests
to validate whether your draft is going in the right direction.
An AI copy editor, you could say.
⚙️ Installation
We recommend uv to run the CLI.
# to run the CLI straight away
uvx unit-text --help
# or if you prefer to install it
uv tool install unit-text
You may of course also use pip to install the CLI - or pipx if you prefer to install it in an isolated environment.
pipx install unit-text
# ...or if you like to live on the edge
pip install unit-text
🔨 Usage
Requirements
Either:
- Ollama must be running locally;
OLLAMA_HOSTshould point to an Ollama server.
# To generate a blog idea
unit-text ideate
# To validate the working draft
unit-text test <path-to-the-draft.md>
API
The package also provides a FastAPI server for programmatic access:
# Start the development server
uv run fastapi dev ./src/unit_text/api
# Start the production server
uv run fastapi run ./src/unit_text/api
# or for convenience
uv run unit-text-api
The server exposes a /test endpoint that accepts POST requests with two files:
file: Your draft text fileconfig: Your idea configuration JSON file
Example using curl:
curl -X POST http://localhost:8000/test \
-F "file=@draft.md" \
-F "config=@unit-text.json"
📝 Process
The ideation phase is where you define your blog idea. It looks something like this:
Your idea is now stored in a unit-text.json file, in the current directory.
You may run unit-text ideate again at any time to finetune it.
Now you can start writing, let's say you're writing in a file called draft.md.
At any time, you can run unit-text test draft.md to validate it.
Initially, it may look something like this:
Keep iterating on your draft, based on feedback from unit-text, until it passes all tests:
💻 Contributing
If you want to contribute to the project, please read the CONTRIBUTING.md file.
It contains information on how to set up your development environment, submit issues, and create pull requests.
📜 License
This project is licensed under the AGPLv3 License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unit_text-0.3.0.tar.gz.
File metadata
- Download URL: unit_text-0.3.0.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84677b2fa67998ec31fb03e62c51062e2d412b8bfba3039ef602273c4feba850
|
|
| MD5 |
023cb41fd58dadc066858e09cd26e3da
|
|
| BLAKE2b-256 |
09e1efd110fe14598eee69234a3e52d50c81b8073900654c4cda08ad68deaf6c
|
Provenance
The following attestation bundles were made for unit_text-0.3.0.tar.gz:
Publisher:
publish.yaml on sealambda/unit-text
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unit_text-0.3.0.tar.gz -
Subject digest:
84677b2fa67998ec31fb03e62c51062e2d412b8bfba3039ef602273c4feba850 - Sigstore transparency entry: 188477073
- Sigstore integration time:
-
Permalink:
sealambda/unit-text@f7a83d09293044665147eb0e2a59567861c25f2a -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sealambda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f7a83d09293044665147eb0e2a59567861c25f2a -
Trigger Event:
push
-
Statement type:
File details
Details for the file unit_text-0.3.0-py3-none-any.whl.
File metadata
- Download URL: unit_text-0.3.0-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d081a00a2b2949f7f3d44b78b8eb0ffbb96cf42dc532f2b8ad362dd0d4ee17c
|
|
| MD5 |
2835ae714a4f8df8b060929997d675cf
|
|
| BLAKE2b-256 |
3d343e7cf10e31e5d6b01d38ed69a79df9b057e94fff9c92837a9d8ca3c633a9
|
Provenance
The following attestation bundles were made for unit_text-0.3.0-py3-none-any.whl:
Publisher:
publish.yaml on sealambda/unit-text
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unit_text-0.3.0-py3-none-any.whl -
Subject digest:
6d081a00a2b2949f7f3d44b78b8eb0ffbb96cf42dc532f2b8ad362dd0d4ee17c - Sigstore transparency entry: 188477074
- Sigstore integration time:
-
Permalink:
sealambda/unit-text@f7a83d09293044665147eb0e2a59567861c25f2a -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sealambda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@f7a83d09293044665147eb0e2a59567861c25f2a -
Trigger Event:
push
-
Statement type: