mirror of
https://github.com/microsoft/autogen.git
synced 2025-09-27 00:58:52 +00:00

* 1) Removed most framework sleeps 2) refactored connection code * pre-commit fixes * pre-commit * ignore protobuf files in pre-commit checks * Fix duplicate actor registration * refactor change * Nicer printing of Actors * 1) Report recv_multipart errors 4) Always send 4 parts * AutoGen generate_reply expects to wait indefinitely for an answer. CAP can wait a certain amount and give up. In order to reconcile the two, AutoGenConnector is set to wait indefinitely. * pre-commit formatting fixes * pre-commit format changes * don't check autogenerated proto py files
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import time
|
|
from typing import List
|
|
from AppAgents import GreeterAgent, FidelityAgent
|
|
from autogencap.LocalActorNetwork import LocalActorNetwork
|
|
from autogencap.proto.CAP_pb2 import ActorInfo
|
|
from autogencap.DebugLog import Info
|
|
|
|
|
|
def list_agents():
|
|
"""
|
|
Demonstrates the usage of the CAP platform by registering an actor, connecting to the actor,
|
|
sending a message, and performing cleanup operations.
|
|
"""
|
|
# CAP Platform
|
|
|
|
network = LocalActorNetwork()
|
|
# Register an actor
|
|
network.register(GreeterAgent())
|
|
# Register an actor
|
|
network.register(FidelityAgent())
|
|
# Tell actor to connect to other actors
|
|
network.connect()
|
|
# Get a list of actors
|
|
actor_infos: List[ActorInfo] = network.lookup_actor_info(name_regex=".*")
|
|
# Print out all actors found
|
|
Info("list_agents", f"{len(actor_infos)} actors found:")
|
|
for actor_info in actor_infos:
|
|
Info(
|
|
"list_agents",
|
|
f"Name: {actor_info.name}, Namespace: {actor_info.namespace}, Description: {actor_info.description}",
|
|
)
|
|
# Cleanup
|
|
network.disconnect()
|