Skip to main content

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:

  • SwarmTask
  • SwarmTaskType
  • EvaluationStatus
  • EvaluationContext
  • EvaluationResult
  • TaskResult
  • BaseEvaluator
  • CustomEvaluator
  • PassthroughEvaluator
  • SchemaValidator

Notes

  • SwarmTask is 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarm_task-0.0.2.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarm_task-0.0.2-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file swarm_task-0.0.2.tar.gz.

File metadata

  • Download URL: swarm_task-0.0.2.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for swarm_task-0.0.2.tar.gz
Algorithm Hash digest
SHA256 065c26646f95a302823e09fd85be666dc5bb796059579b4056c0508cd4d6db5d
MD5 c68a8354702efc5e8ac3d0ddc674f06e
BLAKE2b-256 b08857cf67dda7b69237dfa5711231dcc6c2e6ab8b8ed0dfeb75aac7b0f3a1a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarm_task-0.0.2.tar.gz:

Publisher: publish-pypi.yml on logarith-ms/swarm-task

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file swarm_task-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: swarm_task-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for swarm_task-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe962428b4145fea59aec65e1d5607be09e39acfb3126ffa2cea3e454ec7e9a3
MD5 54d338e7679879c2683f82e71f3fe0ba
BLAKE2b-256 680002714c13cc271f6379a5db533ec2505efbbed1bf51b33ca3ab658f3b0c5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarm_task-0.0.2-py3-none-any.whl:

Publisher: publish-pypi.yml on logarith-ms/swarm-task

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page