-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirect_edge.py
More file actions
38 lines (27 loc) · 883 Bytes
/
Copy pathdirect_edge.py
File metadata and controls
38 lines (27 loc) · 883 Bytes
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
30
31
32
33
34
35
36
37
38
from agent_framework import (
Executor,
WorkflowContext,
WorkflowBuilder,
handler,
executor
)
import asyncio
class UpperCase(Executor):
def __init__(self, id: str):
super().__init__(id=id)
@handler
async def to_upper_case(self, text: str, ctx: WorkflowContext[str]) -> None:
await ctx.send_message(text.upper())
@executor(id='remove_vowels')
async def remove_vowels(text: str, ctx:WorkflowContext[str, str]) -> None:
await ctx.yield_output(''.join([c for c in text if c not in 'AEIOU']))
async def main():
upper = UpperCase(id='uppercase')
builder = WorkflowBuilder()
builder.add_edge(upper, remove_vowels)
builder.set_start_executor(upper)
workflow = builder.build()
events = await workflow.run('hola mundo')
print(events.get_outputs())
if __name__ == "__main__":
asyncio.run(main())