INNER CODE UNIT · Python

stream_text

awslabs/awsome-distributed-ai · architectures/sagemaker-hyperpod-eks/nvidia-cloud-functions/nvcf/sample-function/server.py:57

        def stream_text():
            for _ in range(request.repeats):
                time.sleep(request.delay)
                yield f"data: {request.message}\n\n"

        return StreamingResponse(stream_text(), media_type="text/event-stream")
    else:
        time.sleep(request.delay)
        return {"echo": request.message * request.repeats}


# ---------------------------------------------------------------------------
# Root endpoint (informational)
# ---------------------------------------------------------------------------
@app.get("/", summary="Root endpoint")
def root():
    return {
        "service": "nvcf-echo-function",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…