2024-03-13 00:48:52 -04:00
|
|
|
import time
|
2024-04-05 10:26:06 +08:00
|
|
|
|
2024-03-13 00:48:52 -04:00
|
|
|
import _paths
|
2024-04-05 10:26:06 +08:00
|
|
|
from autogencap.ag_adapter.CAP2AG import CAP2AG
|
2024-05-21 15:46:10 -04:00
|
|
|
from autogencap.ComponentEnsemble import ComponentEnsemble
|
2024-03-13 00:48:52 -04:00
|
|
|
from autogencap.DebugLog import Info
|
2024-04-05 10:26:06 +08:00
|
|
|
|
|
|
|
from autogen import AssistantAgent, config_list_from_json
|
2024-03-13 00:48:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
# 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
|
2024-05-21 15:46:10 -04:00
|
|
|
ensemble = ComponentEnsemble()
|
2024-03-13 00:48:52 -04:00
|
|
|
assistant_adptr = CAP2AG(ag_agent=assistant, the_other_name="user_proxy", init_chat=False, self_recursive=True)
|
2024-05-21 15:46:10 -04:00
|
|
|
ensemble.register(assistant_adptr)
|
|
|
|
ensemble.connect()
|
2024-03-13 00:48:52 -04:00
|
|
|
|
|
|
|
# Hang around for a while
|
|
|
|
try:
|
|
|
|
while assistant_adptr.run:
|
|
|
|
time.sleep(0.5)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print("Interrupted by user, shutting down.")
|
2024-05-21 15:46:10 -04:00
|
|
|
ensemble.disconnect()
|
2024-03-13 00:48:52 -04:00
|
|
|
Info("StandaloneAssistant", "App Exit")
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
assistant = StandaloneAssistant()
|
|
|
|
assistant.run()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|