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.3.tar.gz (13.9 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.3-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: swarm_task-0.0.3.tar.gz
  • Upload date:
  • Size: 13.9 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.3.tar.gz
Algorithm Hash digest
SHA256 aed826ec2733e2164ae8c1c16c5ed47e87ad9abdcf9e2074356969b7a6044e85
MD5 2e96e279debb7c7d96e6b9cda85730f3
BLAKE2b-256 695789e79bd4360b68538369fb1d0697f42680441877af8685dbbb4eaec62255

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarm_task-0.0.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: swarm_task-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f2dfcf51f0f42629fd4a5462c7048058b292c87352c00a5372c86ae7d5242cfb
MD5 44569c0d3202775ee26d40189839f8e6
BLAKE2b-256 157dca8514bdddc97c686fdeec19066de084e18309459eab7538428976a7ad5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for swarm_task-0.0.3-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