mirror of
https://github.com/microsoft/autogen.git
synced 2025-07-19 06:53:17 +00:00

* Python host runtime impl * update * ignore proto generated files * move worker runtime to application * Move example to samples * Fix import * fix * update * server client * better shutdown * fix doc conf * add type
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import asyncio
|
|
import logging
|
|
|
|
from agnext.application import WorkerAgentRuntime
|
|
from agnext.core._serialization import MESSAGE_TYPE_REGISTRY
|
|
from app import build_app
|
|
from dotenv import load_dotenv
|
|
from messages import ArticleCreated, AuditorAlert, AuditText, GraphicDesignCreated
|
|
|
|
agnext_logger = logging.getLogger("agnext")
|
|
|
|
|
|
async def main() -> None:
|
|
load_dotenv()
|
|
runtime = WorkerAgentRuntime()
|
|
MESSAGE_TYPE_REGISTRY.add_type(ArticleCreated)
|
|
MESSAGE_TYPE_REGISTRY.add_type(GraphicDesignCreated)
|
|
MESSAGE_TYPE_REGISTRY.add_type(AuditText)
|
|
MESSAGE_TYPE_REGISTRY.add_type(AuditorAlert)
|
|
agnext_logger.info("1")
|
|
await runtime.start("localhost:5145")
|
|
|
|
agnext_logger.info("2")
|
|
|
|
await build_app(runtime)
|
|
agnext_logger.info("3")
|
|
|
|
# just to keep the runtime running
|
|
try:
|
|
await asyncio.sleep(1000000)
|
|
except KeyboardInterrupt:
|
|
pass
|
|
await runtime.stop()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
agnext_logger.setLevel(logging.DEBUG)
|
|
agnext_logger.log(logging.DEBUG, "Starting worker")
|
|
asyncio.run(main())
|