2024-06-25 14:27:45 -07:00
|
|
|
import asyncio
|
2024-07-09 13:51:05 -07:00
|
|
|
import logging
|
2024-06-25 14:27:45 -07:00
|
|
|
|
|
|
|
from agnext.application import SingleThreadedAgentRuntime
|
2024-07-09 13:51:05 -07:00
|
|
|
from agnext.application.logging import EVENT_LOGGER_NAME
|
2024-08-28 12:14:35 -04:00
|
|
|
from agnext.base import AgentId, AgentProxy
|
2024-08-27 12:03:21 -07:00
|
|
|
from agnext.components import DefaultSubscription
|
2024-06-27 16:39:16 -07:00
|
|
|
from team_one.agents.file_surfer import FileSurfer
|
2024-07-09 13:51:05 -07:00
|
|
|
from team_one.agents.orchestrator import RoundRobinOrchestrator
|
|
|
|
from team_one.agents.user_proxy import UserProxy
|
|
|
|
from team_one.messages import RequestReplyMessage
|
|
|
|
from team_one.utils import LogHandler, create_completion_client_from_env
|
2024-06-25 14:27:45 -07:00
|
|
|
|
|
|
|
|
|
|
|
async def main() -> None:
|
|
|
|
# Create the runtime.
|
|
|
|
runtime = SingleThreadedAgentRuntime()
|
|
|
|
|
2024-07-09 13:51:05 -07:00
|
|
|
# Get an appropriate client
|
|
|
|
client = create_completion_client_from_env()
|
|
|
|
|
2024-06-25 14:27:45 -07:00
|
|
|
# Register agents.
|
2024-08-27 12:03:21 -07:00
|
|
|
await runtime.register("file_surfer", lambda: FileSurfer(model_client=client), lambda: [DefaultSubscription()])
|
2024-08-20 14:41:24 -04:00
|
|
|
file_surfer = AgentProxy(AgentId("file_surfer", "default"), runtime)
|
|
|
|
|
2024-08-27 12:03:21 -07:00
|
|
|
await runtime.register("UserProxy", lambda: UserProxy(), lambda: [DefaultSubscription()])
|
2024-08-20 14:41:24 -04:00
|
|
|
user_proxy = AgentProxy(AgentId("UserProxy", "default"), runtime)
|
2024-07-01 11:53:45 -04:00
|
|
|
|
2024-08-27 12:03:21 -07:00
|
|
|
await runtime.register(
|
|
|
|
"orchestrator", lambda: RoundRobinOrchestrator([file_surfer, user_proxy]), lambda: [DefaultSubscription()]
|
|
|
|
)
|
2024-06-25 14:27:45 -07:00
|
|
|
|
2024-08-21 13:59:59 -07:00
|
|
|
runtime.start()
|
2024-07-09 13:51:05 -07:00
|
|
|
await runtime.send_message(RequestReplyMessage(), user_proxy.id)
|
2024-08-21 13:59:59 -07:00
|
|
|
await runtime.stop_when_idle()
|
2024-06-25 14:27:45 -07:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-07-09 13:51:05 -07:00
|
|
|
logger = logging.getLogger(EVENT_LOGGER_NAME)
|
|
|
|
logger.setLevel(logging.INFO)
|
|
|
|
log_handler = LogHandler()
|
|
|
|
logger.handlers = [log_handler]
|
2024-06-25 14:27:45 -07:00
|
|
|
asyncio.run(main())
|