This directory contains examples of using Mellea with asynchronous Python patterns, including streaming responses and concurrent operations.
These examples use async/await and require Python 3.11+. Most examples also need a running Ollama instance:
ollama serveuv run async-simple.pyDemonstrates:
- Async session initialization
- Using
ainstruct()for asynchronous instruction execution - Streaming responses with
ModelOption.STREAM - Lazy compute evaluation
uv run async-with-lazy-compute.pyDemonstrates:
- Combining async operations with lazy evaluation
- Creating ModelOutputThunk objects
- Deferred computation patterns
Async Backend Operations: Mellea backends support async methods (ainstruct, aact, achat) that allow concurrent execution without blocking.
Streaming: Set ModelOption.STREAM: True in model options to receive responses as they're generated, useful for real-time feedback or long-running operations.
Lazy Compute: Defer execution to later in your program using lazy evaluation patterns.
- ../streaming/ — Real-time token streaming
- ../sessions/ — Session configuration
- ../telemetry/ — Monitoring async operations