Update send_message to be a single async operation. Add start helper to runtime to manage this (#165)

This commit is contained in:
Jack Gerrits
2024-07-01 11:53:45 -04:00
committed by GitHub
parent 28f11c726d
commit 766635394a
29 changed files with 170 additions and 124 deletions

View File

@@ -24,12 +24,14 @@ async def main() -> None:
task = input("Enter a task: ")
run_context = runtime.start()
await runtime.publish_message(
BroadcastMessage(content=UserMessage(content=task, source="human")), namespace="default"
)
# Run the runtime until the task is completed.
await runtime.process_until_idle()
await run_context.stop_when_idle()
if __name__ == "__main__":

View File

@@ -18,12 +18,14 @@ async def main() -> None:
task = input(f"Enter a task for {file_surfer.name}: ")
msg = BroadcastMessage(content=UserMessage(content=task, source="human"))
run_context = runtime.start()
# Send a task to the tool user.
await runtime.publish_message(msg, namespace="default")
await runtime.publish_message(RequestReplyMessage(), namespace="default")
# Run the runtime until the task is completed.
await runtime.process_until_idle()
await run_context.stop_when_idle()
if __name__ == "__main__":

View File

@@ -16,9 +16,10 @@ async def main() -> None:
runtime.register_and_get("orchestrator", lambda: RoundRobinOrchestrator([fake1, fake2, fake3]))
task_message = UserMessage(content="Test Message", source="User")
run_context = runtime.start()
await runtime.publish_message(BroadcastMessage(task_message), namespace="default")
await runtime.process_until_idle()
await run_context.stop_when_idle()
if __name__ == "__main__":