mirror of
https://github.com/microsoft/autogen.git
synced 2025-10-04 20:46:11 +00:00

* 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 --------- Co-authored-by: Li Jiang <bnujli@gmail.com>
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import time
|
|
|
|
import _paths
|
|
from autogencap.ag_adapter.CAP2AG import CAP2AG
|
|
from autogencap.DebugLog import Info
|
|
from autogencap.runtime_factory import RuntimeFactory
|
|
|
|
from autogen import AssistantAgent, config_list_from_json
|
|
|
|
|
|
# Starts the Broker and the Assistant. The UserProxy is started separately.
|
|
class StandaloneAssistant:
|
|
def __init__(self):
|
|
pass
|
|
|
|
def run(self):
|
|
print("Running the StandaloneAssistant")
|
|
config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")
|
|
assistant = AssistantAgent("assistant", llm_config={"config_list": config_list})
|
|
# Composable Agent Network adapter
|
|
ensemble = RuntimeFactory.get_runtime("ZMQ")
|
|
assistant_adptr = CAP2AG(ag_agent=assistant, the_other_name="user_proxy", init_chat=False, self_recursive=True)
|
|
ensemble.register(assistant_adptr)
|
|
ensemble.connect()
|
|
|
|
# Hang around for a while
|
|
try:
|
|
while assistant_adptr.run:
|
|
time.sleep(0.5)
|
|
except KeyboardInterrupt:
|
|
print("Interrupted by user, shutting down.")
|
|
ensemble.disconnect()
|
|
Info("StandaloneAssistant", "App Exit")
|
|
|
|
|
|
def main():
|
|
assistant = StandaloneAssistant()
|
|
assistant.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|