pipeline.py 686 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import asyncio

import uvloop
from triton_distributed_rs import DistributedRuntime, triton_worker

uvloop.install()


@triton_worker()
async def worker(runtime: DistributedRuntime):
    """
    # Pipeline Example

    This example demonstrates how to create a pipeline of components:
    - `frontend` call `middle` which calls `backend`
    - each component transforms the request before passing it to the backend
    """
    pipeline = (
        await runtime.namespace("examples/pipeline")
        .component("frontend")
        .endpoint("generate")
        .client()
    )

    async for char in await pipeline.round_robin("hello from"):
        print(char)


asyncio.run(worker())