- It is recommended to create a virtual environment using
python -m venv {newenv}
- Run
pip install -r requirements.txt
- Set
export PYTHONPATH=$(pwd)
(and if needed,export PATH={which_python_path}
) - Set the OPENAI_API_KEY environment variable using
export OPENAI_API_KEY="your_api_key"
, then reload usingsource ~/.bashrc
- Change configurations in the
src/web/config.json
file as needed - Ensure that Docker is installed
- In one terminal, run
python src/__main__.py
- In another terminal, make post requests with test Python scripts in
src/web/testing/
, for example:python src/web/testing/{test_name}.py
-
class AutoGenChatManager
- Handles the automated generation and management of chat interactions.
- An
AutoGenChatManager
instance is initialized with a message queue that organizes the messages to be sent between assistant agents and the user proxy agent. - Initializes workflow managers based on incoming workflow configuration.
- Outputs a summary of the conversation, including the user's and assistant agents' messages, token cost and usage, as well as the start and end time.
Provides the foundational data structures to be used by workflow managers and the chat manager.
- Dataclasses: used for storing data, such as the
Message
,Session
,Gallery
, andAgentWorkFlowConfig
classes. - Pydantic Model Structures: handle data in APIs, applications, and configurations (e.g.
Agent
,Workflow
). - Enum classes: define categories or options a variable can take, like
AgentType
,CodeExecutionConfigTypes
(locally or via Docker container), andWorkFlowType
. - Additional Functionality:
__post_init__
for additional initialization after the automatic__init__
method and classes to convert between class instances, JSON, and dictionaries.
autonomous
: agents operate independently and simultaneously without waiting for other agents to complete their tasks.sequential
: agents operate in a specific pre-determined order, where each agent waits for the previous one to complete its task.
assistant
: acts as a helper or advisor to answer queries and perform tasks input by the user.userproxy
: acts as a proxy for a human user, responsible for asking questions.
In the groupchat
setting, multiple agents can commmunicate with each other aside from the user. The order in which agents answer the query is self-determined.
Autobots supports user message and session addition, retrieval, and deletion (including database clearing). When app.py
(the file with API GET and POST endpoints) is run, a database.sqlite
SQLite database is created with 3 tables: messages
, sessions
, and gallery
. The messages
table stores one entry for each user query and one entry for each combined assistant(s) response, and each message item is uniquely identified by its msg_id
. Each message item belongs to a session uniquely identified in the sessions
table by the session_id
. A session can be published to the gallery
table where each gallery item is uniquely identified by its gallery_id
.
-
load_messages(user_id: str, session_id: str, dbmanager: DBManager) -> List[Message]:
- Load messages from the database for a given user and session specified by their IDs.
- Used when retrieving user history or publishing a session to the gallery database.
-
save_message(message: Message, dbmanager: DBManager) -> None:
- Save a message to the database.
- Used when adding a message to the database.
-
delete_message(user_id: str, msg_id: Optional[str], session_id: Optional[str], dbmanager: DBManager, delete_all: bool) -> []:
- Delete a message from the database.
delete_all
is set to True when clearing all messages belonging to a session. - Used when deleting an individual message or clearing the database.
- Delete a message from the database.
-
get_sessions(user_id: str, dbmanager: DBManager) -> List[Session]:
- Retrieve all sessions for a given user from the database.
- Used when creating a session, retrieving a session, or clearing the database.
-
create_session(user_id: str, session: Session, dbmanager: DBManager) -> List[Session]:
- Create a new user session in the database.
-
delete_user_sessions(user_id: str, session_id: str, dbmanager: DBManager) -> List[Session]:
- Delete a specific session from the database.
- Used when clearing the database.
-
publish_session(session: Session, tags: Optional[List[str]], dbmanager: DBManager) -> Gallery:
- Publish a user's session to the gallery.
-
get_gallery(gallery_id: Optional[str], dbmanager: DBManager) -> List[Gallery]:
- Retrieve gallery items from the database.
See the src/web/testing/
folder to run API endpoint tests. Workflow configurations are outlined in the test files.
One area to explore is adding skills to agents in order to enable external tool usage. More database functions, such as more gallery operations, can be added to existing utilities.
Many thanks to AutoGen for providing the framework.