2024-06-25 14:27:45 -07:00
|
|
|
import asyncio
|
|
|
|
|
|
|
|
from agnext.application import SingleThreadedAgentRuntime
|
2024-07-09 10:46:55 -07:00
|
|
|
from agnext.components.models import UserMessage
|
2024-06-27 16:39:16 -07:00
|
|
|
from team_one.agents.file_surfer import FileSurfer
|
2024-06-28 15:50:10 -07:00
|
|
|
from team_one.messages import BroadcastMessage, RequestReplyMessage
|
2024-07-09 10:46:55 -07:00
|
|
|
from team_one.utils import create_completion_client_from_env
|
2024-06-25 14:27:45 -07:00
|
|
|
|
|
|
|
|
|
|
|
async def main() -> None:
|
|
|
|
# Create the runtime.
|
|
|
|
runtime = SingleThreadedAgentRuntime()
|
|
|
|
|
|
|
|
# Register agents.
|
|
|
|
file_surfer = runtime.register_and_get(
|
|
|
|
"file_surfer",
|
2024-07-09 10:46:55 -07:00
|
|
|
lambda: FileSurfer(model_client=create_completion_client_from_env()),
|
2024-06-25 14:27:45 -07:00
|
|
|
)
|
2024-06-28 15:50:10 -07:00
|
|
|
task = input(f"Enter a task for {file_surfer.name}: ")
|
|
|
|
msg = BroadcastMessage(content=UserMessage(content=task, source="human"))
|
2024-06-25 14:27:45 -07:00
|
|
|
|
2024-07-01 11:53:45 -04:00
|
|
|
run_context = runtime.start()
|
|
|
|
|
2024-06-25 14:27:45 -07:00
|
|
|
# Send a task to the tool user.
|
2024-06-28 15:50:10 -07:00
|
|
|
await runtime.publish_message(msg, namespace="default")
|
|
|
|
await runtime.publish_message(RequestReplyMessage(), namespace="default")
|
2024-06-25 14:27:45 -07:00
|
|
|
|
|
|
|
# Run the runtime until the task is completed.
|
2024-07-01 11:53:45 -04:00
|
|
|
await run_context.stop_when_idle()
|
2024-06-25 14:27:45 -07:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
import logging
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.WARNING)
|
|
|
|
logging.getLogger("agnext").setLevel(logging.DEBUG)
|
|
|
|
asyncio.run(main())
|