mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-01 06:11:02 -06:00
* feat: add stream sub on top level * feat: clean up examples * chore: gen * feat: move stream onto the runs client in ts * fix: examples * chore: gen * fix: circular import issues * chore: lint * feat: first pass at Next app * fix: pull next out to top level * fix: all the things * fix: get it all wired up * fix: imports * fix: lint rule * fix: just use js * fix: revert tsconfig changes * fix: check in pages * fix: hangup event in streaming impl * chore: gen * chore: generate again, remove lots of nextjs stuff * fix: one more ignore * fix: gen * fix: ignore * fix: ugh * fix: simplify a bunch * fix: lint * fix: rm gen cruft * fix: changelog * feat: implement list with pagination * feat: add some tests * feat: add warnings * fix: update workflow / task methods * chore: version * feat: retries
28 lines
580 B
Python
28 lines
580 B
Python
from typing import AsyncGenerator
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.responses import StreamingResponse
|
|
|
|
from examples.streaming.worker import stream_task
|
|
from hatchet_sdk import Hatchet
|
|
|
|
# > FastAPI Proxy
|
|
hatchet = Hatchet()
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/stream")
|
|
async def stream() -> StreamingResponse:
|
|
ref = await stream_task.aio_run_no_wait()
|
|
|
|
return StreamingResponse(
|
|
hatchet.runs.subscribe_to_stream(ref.workflow_run_id), media_type="text/plain"
|
|
)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|