Files
Rajan 1c5baf020f [CAP] Abstraction of actor_connector to go along with runtime factory and runtime abstraction (#3296)
* Added Runtime Factory to support multiple implementations

* Rename to ComponentEnsemble to ZMQRuntime

* rename zmq_runtime

* rename zmq_runtime

* pre-commit fixes

* pre-commit fix

* pre-commit fixes and default runtime

* pre-commit fixes

* Rename constants

* Rename Constants

* Create interfaces for connectors

* pre-commit fixes

* pre-commit fixes

* pre-commit fixes

* lower case file names

* rename files to lower _case

* rename files to _lowercase

* removed _

* Refactored to make Actor zmq agnostic

* fix for refactor

* fix refactor, circular dependency

* pre-commit fixes

* document classes

* pre-commit ruff

* fix ruff issues

* ruff fixes

* ruff fixes

* actor connector documentation

* better docs

---------

Co-authored-by: Li Jiang <bnujli@gmail.com>
Co-authored-by: Chi Wang <wang.chi@microsoft.com>
Co-authored-by: Ryan Sweet <rysweet@microsoft.com>
Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
2024-10-22 16:52:06 +08:00
..

Composable Actor Platform (CAP) for AutoGen

I just want to run the remote AutoGen agents!

Python Instructions (Windows, Linux, MacOS):

pip install autogencap

  1. AutoGen require OAI_CONFIG_LIST. AutoGen python requirements: 3.8 <= python <= 3.11

## What is Composable Actor Platform (CAP)?
AutoGen is about Agents and Agent Orchestration.  CAP extends AutoGen to allows Agents to communicate via a message bus.  CAP, therefore, deals with the space between these components.  CAP is a message based, actor platform that allows actors to be composed into arbitrary graphs.

Actors can register themselves with CAP, find other agents, construct arbitrary graphs, send and receive messages independently and many, many, many other things.

```python
# CAP Library
from autogencap.ComponentEnsemble import ComponentEnsemble
from autogencap.Actor import Actor

# A simple Agent
class GreeterAgent(Actor):
    def __init__(self):
        super().__init__(
            agent_name="Greeter",
            description="This is the greeter agent, who knows how to greet people.")

    # Prints out the message it receives
    def on_txt_msg(self, msg):
        print(f"Greeter received: {msg}")
        return True

ensemble = ComponentEnsemble()
# Create an agent
agent = GreeterAgent()
# Register an agent
ensemble.register(agent) # start message processing
# call on_connect() on all Agents
ensemble.connect()
# Get a channel to the agent
greeter_link = ensemble.find_by_name("Greeter")
#Send a message to the agent
greeter_link.send_txt_msg("Hello World!")
# Cleanup
greeter_link.close()
ensemble.disconnect()

Check out other demos in the py/demo directory. We show the following:

  1. Hello World shown above
  2. Many CAP Actors interacting with each other
  3. A pair of interacting AutoGen Agents wrapped in CAP Actors
  4. CAP wrapped AutoGen Agents in a group chat
  5. Two AutoGen Agents running in different processes and communicating through CAP
  6. List all registered agents in CAP
  7. Run Agent in user supplied message loop