Rajan 8f6590e231
Feature: Composable Actor Platform for AutoGen (#1655)
* Core CAP components + Autogen adapter + Demo

* Cleanup Readme

* C# folder

* Cleanup readme

* summary_method bug fix

* CAN -> CAP

* pre-commit fixes

* pre-commit fixes

* modification of sys path should ignore E402

* fix pre-commit check issues

* Updated docs

* Clean up docs

* more refactoring

* better packaging refactor

* Refactoring for package changes

* Run demo app without autogencap installed or in the path

* Remove debug related sleep()

* removed CAP in some class names

* Investigate a logging framework that supports color in windows

* added type hints

* remove circular dependency

* fixed pre-commit issues

* pre-commit ruff issues

* removed circular definition

* pre-commit fixes

* Fix pre-commit issues

* pre-commit fixes

* updated for _prepare_chat signature changes

* Better instructions for demo and some minor refactoring

* Added details that explain CAP

* Reformat Readme

* More ReadMe Formatting

* Readme edits

* Agent -> Actor

* Broker can startup on it's own

* Remote AutoGen Agents

* Updated docs

* 1) StandaloneBroker in demo
2) Removed Autogen only demo options

* 1) Agent -> Actor refactor
2) init broker as early

* rename user_proxy -> user_proxy_conn

* Add DirectorySvc

* Standalone demo refactor

* Get ActorInfo from DirectorySvc when searching for Actor

* Broker cleanup

* Proper cleanup and remove debug sleep()

* Run one directory service only.

* fix paths to run demo apps from command line

* Handle keyboard interrupt

* Wait for Broker and Directory to start up

* Move Terminate AGActor

* Accept input from the user in UserProxy

* Move sleeps close to operations that bind or connect

* Comments

* Created an encapsulated CAP Pair for AutoGen pair communication

* pre-commit checks

* fix pre-commit

* Pair should not make assumptions about who is first and who is second

* Use task passed into InitiateChat

* Standalone directory svc

* Fix broken LFS files

* Long running DirectorySvc

* DirectorySvc does not have a status

* Exit DirectorySvc Loop

* Debugging Remoting

* Reduce frequency of status messages

* Debugging remote Actor

* roll back git-lfs updates

* rollback git-lfs changes

* Debug network connectivity

* pre-commit fixes

* Create a group chat interface familiar to AutoGen GroupChat users

* pre-commit fixes
2024-03-13 04:48:52 +00:00

57 lines
1.8 KiB
Python

import time
import _paths
from autogen import UserProxyAgent, config_list_from_json
from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork
from autogencap.ag_adapter.CAP2AG import CAP2AG
from autogencap.Config import IGNORED_LOG_CONTEXTS
# Starts the Broker and the Assistant. The UserProxy is started separately.
class StandaloneUserProxy:
def __init__(self):
pass
def run(self):
print("Running the StandaloneUserProxy")
user_proxy = UserProxyAgent(
"user_proxy",
code_execution_config={"work_dir": "coding"},
is_termination_msg=lambda x: "TERMINATE" in x.get("content"),
)
# Composable Agent Network adapter
network = LocalActorNetwork()
user_proxy_adptr = CAP2AG(ag_agent=user_proxy, the_other_name="assistant", init_chat=True, self_recursive=True)
network.register(user_proxy_adptr)
network.connect()
# Send a message to the user_proxy
user_proxy_conn = network.lookup_actor("user_proxy")
example = "Plot a chart of MSFT daily closing prices for last 1 Month."
print(f"Example: {example}")
try:
user_input = input("Please enter your command: ")
if user_input == "":
user_input = example
print(f"Sending: {user_input}")
user_proxy_conn.send_txt_msg(user_input)
# Hang around for a while
while user_proxy_adptr.run:
time.sleep(0.5)
except KeyboardInterrupt:
print("Interrupted by user, shutting down.")
network.disconnect()
Info("StandaloneUserProxy", "App Exit")
def main():
IGNORED_LOG_CONTEXTS.extend(["BROKER", "DirectorySvc"])
assistant = StandaloneUserProxy()
assistant.run()
if __name__ == "__main__":
main()