2.6 Unstreamify Operator
The UnstreamifyAbsOperator
is the opposite of the StreamifyAbsOperator
. It converts
a stream of data into a single data.
There are one way to use the UnstreamifyAbsOperator
:
Implement A Custom UnstreamifyAbsOperator
Just override the unstreamify
method to return a single data.
from typing import AsyncIterator
from dbgpt.core.awel import DAG, UnstreamifyAbsOperator
class SumOperator(UnstreamifyAbsOperator[int, int]):
"""Unstreamify the stream of numbers"""
async def unstreamify(self, it: AsyncIterator[int]) -> int:
return sum([i async for i in it])
with DAG("sum_dag") as dag:
task = SumOperator()