Files
workflows-py/examples/docker/app.py
Adrian Lyjak db90f89b74 Separate server/client, and move to llama_agents namespace (#277)
* prep packages

* wrong coverage detection I think

* add ts deps?

* extend path for namespaces

* the big move, import issues though

* llama_index.workflows

* llama_agents

* alias may be working

* add type checker ignores for workflows secondary namespace, update ty, and add re-exports

* Add descriptions to new client and server packages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Rather, commit the outputs

* keep the py files separate

* ignore examples deps

* Create afraid-books-own.md

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 18:16:02 -05:00

34 lines
875 B
Python

import asyncio
from llama_agents.server import WorkflowServer
from workflows import Workflow, step
from workflows.context import Context
from workflows.events import Event, StartEvent, StopEvent
class StreamEvent(Event):
sequence: int
class GreetingWorkflow(Workflow):
@step
async def greet(self, ctx: Context, ev: StartEvent) -> StopEvent:
for i in range(3):
ctx.write_event_to_stream(StreamEvent(sequence=i))
await asyncio.sleep(0.3)
name = getattr(ev, "name", "World")
return StopEvent(result=f"Hello, {name}!")
server = WorkflowServer()
server.add_workflow("greeting", GreetingWorkflow())
# This is to test the server locally, run with `uv run python app.py`
if __name__ == "__main__":
try:
asyncio.run(server.serve(host="localhost", port=8080))
except KeyboardInterrupt:
pass