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=productionto disable the playground. - Set
YOMAI_API_KEYto 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
SignedSessionMiddlewareor 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}/streamPOST /__yomai__/jobs/{job_id}/cancelGET /__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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45a1d26defcfbe04694e19bd27cbf7ce09d8d13857422763d30b90b26e057bc9
|
|
| MD5 |
4a2fa0b651f6c56cda0371e590a1407a
|
|
| BLAKE2b-256 |
c4cf8690f88c88490aad9932bec71b54849dcb9d543dbf45a9cb37aee60edcdc
|
Provenance
The following attestation bundles were made for yomai-0.3.0.tar.gz:
Publisher:
release.yml on Niceiyke/yomai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yomai-0.3.0.tar.gz -
Subject digest:
45a1d26defcfbe04694e19bd27cbf7ce09d8d13857422763d30b90b26e057bc9 - Sigstore transparency entry: 1539329701
- Sigstore integration time:
-
Permalink:
Niceiyke/yomai@55d0230f4f9fc3869b5e8ffe93f7048d7874a21b -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Niceiyke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55d0230f4f9fc3869b5e8ffe93f7048d7874a21b -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4be85666df8d392c68ead7aabd100504db8181d423ce215b7bd1d48b572d6eb
|
|
| MD5 |
23ce5a0f09ff20f9a9337200fd5b2d37
|
|
| BLAKE2b-256 |
79e2bf2ca6c0cdb3a1977392288dc1f49866a5cba5a593177e2687cfc44f2c64
|
Provenance
The following attestation bundles were made for yomai-0.3.0-py3-none-any.whl:
Publisher:
release.yml on Niceiyke/yomai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yomai-0.3.0-py3-none-any.whl -
Subject digest:
d4be85666df8d392c68ead7aabd100504db8181d423ce215b7bd1d48b572d6eb - Sigstore transparency entry: 1539329879
- Sigstore integration time:
-
Permalink:
Niceiyke/yomai@55d0230f4f9fc3869b5e8ffe93f7048d7874a21b -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Niceiyke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55d0230f4f9fc3869b5e8ffe93f7048d7874a21b -
Trigger Event:
push
-
Statement type: