Lightweight task orchestration for iterative AI evaluation loops
Project description
swarm-task
Lightweight task orchestration for iterative AI evaluation loops.
swarm_task provides a small runtime for running a callable, evaluating the result through one or more evaluators, and retrying until either evaluation succeeds or retry limits are exhausted.
Install
pip install swarm-task
Quick Start
from pydantic import BaseModel
from swarm_task import (
CustomEvaluator,
EvaluationContext,
EvaluationResult,
EvaluationStatus,
SchemaValidator,
SwarmTask,
SwarmTaskType,
)
class ResultSchema(BaseModel):
name: str
values: list[int]
async def custom_check(result: dict[str, object], context: EvaluationContext[dict[str, object]]) -> EvaluationResult:
if len(result["values"]) < 2:
return EvaluationResult(
status=EvaluationStatus.FAILED,
success=False,
message="Need at least two values",
)
return EvaluationResult(status=EvaluationStatus.SUCCESS, success=True)
async def task_fn() -> dict[str, object]:
return {"name": "example", "values": [1, 2, 3]}
task = SwarmTask(
type=SwarmTaskType.EVALUATOR_OPTIMIZER,
evaluators=[
SchemaValidator(schema=ResultSchema),
CustomEvaluator(evaluator_fn=custom_check),
],
)
result = await task.run(task_fn)
assert result.success is True
Public API
Top-level exports:
SwarmTaskSwarmTaskTypeEvaluationStatusEvaluationContextEvaluationResultTaskResultBaseEvaluatorCustomEvaluatorPassthroughEvaluatorSchemaValidator
Notes
SwarmTaskis async-first and accepts both sync and async callables.- Evaluators manage their own retry counts.
- The package intentionally ships only the active runtime; archived experimental code is excluded.
Project details
Release history Release notifications | RSS feed
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 swarm_task-0.0.1.tar.gz.
File metadata
- Download URL: swarm_task-0.0.1.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bd8c4897bcab5aeabecfd019e62d96a65f25a0c72a803c38568eadad40f6c38
|
|
| MD5 |
61cb92d3fcc404f3b037ea07a151e28b
|
|
| BLAKE2b-256 |
0e76d97fa6285d5243384bee372e5c4e9e3fc4da64291cbd1c89dc38652d7ae8
|
Provenance
The following attestation bundles were made for swarm_task-0.0.1.tar.gz:
Publisher:
publish-pypi.yml on logarith-ms/swarm-task
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swarm_task-0.0.1.tar.gz -
Subject digest:
8bd8c4897bcab5aeabecfd019e62d96a65f25a0c72a803c38568eadad40f6c38 - Sigstore transparency entry: 1078477792
- Sigstore integration time:
-
Permalink:
logarith-ms/swarm-task@7d6461b2ff82f6a37a029a56737b8af4f4ce03ff -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/logarith-ms
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7d6461b2ff82f6a37a029a56737b8af4f4ce03ff -
Trigger Event:
push
-
Statement type:
File details
Details for the file swarm_task-0.0.1-py3-none-any.whl.
File metadata
- Download URL: swarm_task-0.0.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
371f34d4022efc86804487e33dd31808555a8fb252f2e7090c69945e164b6cba
|
|
| MD5 |
186a0746681f2aa06d6ee36bcd56afde
|
|
| BLAKE2b-256 |
be803ebc787c57d9b73ee29143dca44718e3e0d15b7b9808a2a5b2ffb30767a8
|
Provenance
The following attestation bundles were made for swarm_task-0.0.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on logarith-ms/swarm-task
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
swarm_task-0.0.1-py3-none-any.whl -
Subject digest:
371f34d4022efc86804487e33dd31808555a8fb252f2e7090c69945e164b6cba - Sigstore transparency entry: 1078477803
- Sigstore integration time:
-
Permalink:
logarith-ms/swarm-task@7d6461b2ff82f6a37a029a56737b8af4f4ce03ff -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/logarith-ms
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7d6461b2ff82f6a37a029a56737b8af4f4ce03ff -
Trigger Event:
push
-
Statement type: