mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
Update send_message to be a single async operation. Add start helper to runtime to manage this (#165)
This commit is contained in:
@@ -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__":
|
||||
|
||||
@@ -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__":
|
||||
|
||||
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user