Orchestrated RAG components: Postgres lexical, Qdrant vectors, Ollama LLM/embeddings, chat services & examples.
Project description
How to Create an Event in convo_orchestrator
This guide explains step by step how to create, configure, and run an event
using the in-memory adapters of convo_orchestrator. Events can be triggered
manually, by time-based triggers, or by external adapters.
1. Import the required components
from datetime import timedelta
from convo_orchestrator import (
InMemoryEventRepository,
InMemoryMetrics,
SystemClock,
EventManager,
HandlerRegistry,
Event,
EventId,
Trigger,
TriggerId,
TriggerKind,
Policy,
)
2. Create the repository, metrics, clock, and handler registry
repo = InMemoryEventRepository()
metrics = InMemoryMetrics()
clock = SystemClock()
registry = HandlerRegistry()
3. Define and register a handler
Handlers are just functions (sync or async) that receive an EventContext.
def my_handler(ctx):
print(f"Running handler for event={ctx.event_id.value}, payload={ctx.payload}")
return "done"
registry.register("my-handler", my_handler)
4. Create an Event
An event defines the what and how to execute.
ev = Event(
id=EventId("ev-hello"),
name="hello-event",
handler_name="my-handler",
policy=Policy(timeout_sec=2.0, max_retries=0, max_concurrency=1),
active=True,
)
repo.save_event(ev)
5. (Optional) Attach a Trigger
Triggers define when to execute the event.
Interval trigger example:
trig = Trigger(
id=TriggerId("tr-hello"),
kind=TriggerKind.INTERVAL,
interval=timedelta(seconds=10),
active=True,
)
repo.attach_trigger(ev.id, trig)
This means the event will run every 10 seconds.
6. Create and start the EventManager
mgr = EventManager(repo=repo, handler_registry=registry, clock=clock, metrics=metrics, scheduler_tick_ms=100)
mgr.start()
7. Manually emit an event (alternative to triggers)
import asyncio
async def run():
await mgr.emit(ev.id, payload={"msg": "manual trigger"})
await asyncio.sleep(0.5)
await mgr.stop()
asyncio.run(run())
8. Check event status and metrics
status = mgr.status(ev.id).unwrap()
print("Last outcome:", status.last_outcome)
print("Metrics snapshot:", metrics.snapshot())
Summary
- Create infra (
repo,metrics,clock,registry). - Define and register a handler.
- Create an
Eventand save it. - Optionally attach a
Trigger(e.g., INTERVAL, AT). - Start the
EventManager. - Use
.emit()for manual runs, or let triggers schedule runs. - Inspect
.status()and metrics to monitor executions.
This workflow lets you compose flexible event-driven behaviors in
convo_orchestrator.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file convo_orchestrator-0.1.0.tar.gz.
File metadata
- Download URL: convo_orchestrator-0.1.0.tar.gz
- Upload date:
- Size: 136.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab70df4589a1f1e038489f505c4edba9e30e324b1758f641ecff169fee81c247
|
|
| MD5 |
31b9f09839f0eb4ca720a5bf59ae192c
|
|
| BLAKE2b-256 |
c961de2fe23c6b91e572e0ac80e20cd40bcdd4c3b1a21b708ed79dab6fd278bb
|
File details
Details for the file convo_orchestrator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: convo_orchestrator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 58.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
071b6a6f56be76a342a75a6838687c61e3fd36d04bb2c227eb53a9ca9efdf748
|
|
| MD5 |
78977364167d87ad716427b31f7fd02c
|
|
| BLAKE2b-256 |
5308b9d0f4fe0bf0d3012a025a94cae4b42021616403ad8a2d4b1ff857832cf7
|