You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComplexActorDemo.py 1.9 kB

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
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import time
  2. from termcolor import colored
  3. from autogencap.LocalActorNetwork import LocalActorNetwork
  4. from AppAgents import FidelityAgent, FinancialPlannerAgent, PersonalAssistant, QuantAgent, RiskManager
  5. def complex_actor_demo():
  6. """
  7. This function demonstrates the usage of a complex actor system.
  8. It creates a local actor graph, registers various agents,
  9. connects them, and interacts with a personal assistant agent.
  10. The function continuously prompts the user for input messages,
  11. sends them to the personal assistant agent, and terminates
  12. when the user enters "quit".
  13. """
  14. network = LocalActorNetwork()
  15. # Register agents
  16. network.register(PersonalAssistant())
  17. network.register(FidelityAgent())
  18. network.register(FinancialPlannerAgent())
  19. network.register(RiskManager())
  20. network.register(QuantAgent())
  21. # Tell agents to connect to other agents
  22. network.connect()
  23. # Get a channel to the personal assistant agent
  24. pa = network.lookup_actor(PersonalAssistant.cls_agent_name)
  25. info_msg = """
  26. This is an imaginary personal assistant agent scenario.
  27. Five actors are connected in a self-determined graph. The user
  28. can interact with the personal assistant agent by entering
  29. their name. The personal assistant agent will then enlist
  30. the other four agents to create a financial plan.
  31. Start by entering your name.
  32. """
  33. print(colored(info_msg, "blue"))
  34. while True:
  35. # For aesthetic reasons, better to let network messages complete
  36. time.sleep(0.1)
  37. # Get a message from the user
  38. msg = input(colored("Enter your name (or quit): ", "light_red"))
  39. # Send the message to the personal assistant agent
  40. pa.send_txt_msg(msg)
  41. if msg.lower() == "quit":
  42. break
  43. # Cleanup
  44. pa.close()
  45. network.disconnect()