Skip to main content

Streaming-first Python framework for serving LLM agents over HTTP

Project description

Yomai

Streaming-first Python framework for serving LLM agents over HTTP.

from yomai import Yomai, tool
from yomai.config import LLMConfig

app = Yomai(llm=LLMConfig(provider="anthropic"))

@tool
async def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"72°F and sunny in {city}"

@app.agent("/chat", tools=[get_weather])
async def chat(message: str, session_id: str, tone: str = "plain") -> None:
    # Runs before the LLM loop; extra JSON body fields are passed by name.
    pass

Run:

yomai run

Open the playground at http://localhost:8000/__yomai__.

Production notes

  • Set YOMAI_ENV=production to disable the playground.
  • Set YOMAI_API_KEY to protect agent/workflow routes and production metadata endpoints.
  • Routes can override auth with @app.agent(..., api_key="...") or @app.workflow(..., api_key="...").
  • Session IDs are bearer identifiers; use SignedSessionMiddleware or your own auth for public apps.

Real HTTP/SSE smoke test

# Reads standard provider env vars.
./scripts/http_sse_smoke.sh

Expected SSE events include tool_start, tool_end, chunk, usage, and done.

V2 preview: production runtime

Yomai V2 work adds durable async workflow infrastructure while keeping V1 routes compatible.

from yomai import Yomai
from yomai.config import LLMConfig, MemoryConfig, QueueConfig, RateLimitConfig

app = Yomai(
    llm=LLMConfig(provider="anthropic"),
    memory=MemoryConfig(backend="redis", url="redis://localhost:6379/0"),
    queue=QueueConfig(backend="swiftq", url="redis://localhost:6379/0"),
    rate_limits=RateLimitConfig(requests_per_minute=60, max_concurrent_per_session=3),
)

@app.workflow("/research", mode="async")
async def research(topic: str, runner):
    return {"topic": topic}

Async workflow requests return 202 Accepted with job_id, status_url, and stream_url. Job streams are reconnectable via Last-Event-ID.

Useful endpoints:

  • GET /__yomai__/jobs/{job_id}
  • GET /__yomai__/jobs/{job_id}/stream
  • POST /__yomai__/jobs/{job_id}/cancel
  • GET /__yomai__/metrics

Run a worker for swiftQ-backed workflows:

yomai worker main:app --concurrency 4

Hooks:

@app.on("job.succeeded")
async def on_job_done(event):
    print(event.payload)

Manual Redis/swiftQ smoke script:

uv run python scripts/swiftq_redis_smoke.py worker
uv run python scripts/swiftq_redis_smoke.py web

Testing

from yomai.testing import YomaiTestClient, mock_llm

with mock_llm(["Hello"]):
    client = YomaiTestClient(app)
    text = await client.call("/chat", "Say hello", extra_body={"tone": "friendly"})

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

yomai-0.3.0.tar.gz (526.8 kB view details)

Uploaded Source

Built Distribution

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

yomai-0.3.0-py3-none-any.whl (197.2 kB view details)

Uploaded Python 3

File details

Details for the file yomai-0.3.0.tar.gz.

File metadata

  • Download URL: yomai-0.3.0.tar.gz
  • Upload date:
  • Size: 526.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yomai-0.3.0.tar.gz
Algorithm Hash digest
SHA256 45a1d26defcfbe04694e19bd27cbf7ce09d8d13857422763d30b90b26e057bc9
MD5 4a2fa0b651f6c56cda0371e590a1407a
BLAKE2b-256 c4cf8690f88c88490aad9932bec71b54849dcb9d543dbf45a9cb37aee60edcdc

See more details on using hashes here.

Provenance

The following attestation bundles were made for yomai-0.3.0.tar.gz:

Publisher: release.yml on Niceiyke/yomai

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

File details

Details for the file yomai-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: yomai-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 197.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yomai-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4be85666df8d392c68ead7aabd100504db8181d423ce215b7bd1d48b572d6eb
MD5 23ce5a0f09ff20f9a9337200fd5b2d37
BLAKE2b-256 79e2bf2ca6c0cdb3a1977392288dc1f49866a5cba5a593177e2687cfc44f2c64

See more details on using hashes here.

Provenance

The following attestation bundles were made for yomai-0.3.0-py3-none-any.whl:

Publisher: release.yml on Niceiyke/yomai

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