LLM Tasker
LLM Tasker is a small Python library designed to simplify working with language models and prompts. It provides a structure for defining tasks, configuring LLM clients, and managing responses in a type-safe manner.
Features
- Supports various LLM clients (e.g., OpenAI) with easy configuration.
- Define structured prompt-based tasks as Python classes.
- Type-safe implementation using Pydantic models.
- Asynchronous support for efficient interaction with LLM services.
- Reusable task configuration and logic.
Installation
pip install llm_tasker
Example Usage
from openai import AsyncOpenAI
from pydantic import BaseModel
from llm_tasker.task import LLMTask, TaskConfig
LLM_API_KEY = "your-openai-api-key"
LLM_MODEL_ID = "gpt-4o
client = AsyncOpenAI(api_key=LLM_API_KEY)
class AnalysisResult(BaseModel):
subject: str
verb: str
object: str
class NestedOutputTask(LLMTask):
"""
Analyze the following sentence and return a structured nested output with the main subject, verb, and object.
Sentence: `{sentence}`
Output format:
```json
{{
"subject": "subject of the sentence",
"verb": "main verb",
"object": "object of the sentence"
}}
```
"""
sentence: str
result: AnalysisResult | None = None
config = TaskConfig(client=client, model=LLM_MODEL_ID)
if __name__ == "__main__":
import asyncio
async def main():
task = NestedOutputTask(
sentence="The cat chased the mouse."
)
await task()
print(task.result)
asyncio.run(main())
License
This project is licensed under the MIT License.
Metadata
Release files for llm-tasker 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llm_tasker-0.1.2.tar.gz | 4.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_tasker-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / llm_tasker-0.1.2.tar.gz
| Download URL | llm_tasker-0.1.2.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13e468e89712ef16261ab267aa9d1f0b08b8fd776c288016cadaa355badb99e7
|
|
BLAKE2b-256 checksum How to use checksums |
a38bbdef70111a0509e5d9a7064a0f3a9a052d9cab7dd6ed13d46d1b9cb0d755
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.6 Linux/5.15.153.1-microsoft-standard-WSL2
|
Release files / llm_tasker-0.1.2-py3-none-any.whl
| Download URL | llm_tasker-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c5ced0112ff9879864eeb4fb304f3fb6fef6d2884e20c39a1c12b8c2653bddf
|
|
BLAKE2b-256 checksum How to use checksums |
73f82b5a986ddb8bf702d59817f358317578a25e5f6c9c75deec5f1e9421a2fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.10.6 Linux/5.15.153.1-microsoft-standard-WSL2
|
Security for llm-tasker 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.