- python version 3.11
- Steps:
following tutorials in https://gist.github.com/ryumada/c22133988fd1c22a66e4ed1b23eca233
pip install -r requirement_venv.txt
Tool : Visual Studio Code Extension: Remote Development
pre-commit run --all-files
This project aims to build an AI chatbot that can interact effectively in a collaborative environment, contributing to research on human-like AI behavior. It provides both a Slack integration and a web interface for team collaboration with AI.
- Multi-room chat support with persistent history
- Customizable AI teammate personality traits
- Long-term memory and context awareness
- Real-time collaboration with multiple users
- Shareable room links
- Secure experiment setup interface with authentication
- Git clone this repo
- Create a
.env
file in theBolt
directory with the following variables:# Required for Slack integration SLACK_APP_TOKEN=<your-slack-app-token> SLACK_BOT_TOKEN=<your-slack-bot-token> # Required for both Slack and Web interface OPENAI_API_KEY=<your-openai-api-key> # Required for experiment setup authentication SETUP_USERNAME=<your-desired-username> SETUP_PASSWORD=<your-desired-password> # Optional configurations OPEN_AI_MODEL=gpt-4 SQLITE_DB_NAME=chat_history.db
- Follow the instructions to generate Slack API keys and add corresponding Scopes: https://www.youtube.com/watch?v=oDoFvpDftBA&ab_channel=PyBites
- Add the Slack tokens to your
.env
file - Run
python3 app.py
to start the Slack bot
- Ensure you have all required environment variables in your
.env
file - Navigate to the
Bolt
directory - Run
python3 web_app.py
- Access the web interface at
http://localhost:5000
- Default landing page directs to participant join interface
- Secure experiment setup page with username/password authentication
- Create and join chat rooms
- Real-time chat with AI teammate
- Customize AI personality traits and communication style
- Share room links with other users
- Persistent chat history
- Multiple active rooms support
- Participants: Access the join page directly at the root URL
- Experimenters:
- Access
/experiment/setup_login
for setup authentication - Enter credentials from
.env
file - Once authenticated, access the experiment setup interface
- Access
The application uses SQLite3 for data persistence with the following tables:
users
: Stores user information and session datapersonas
: Stores AI personality configurations per roomnew_msg_queue
: Manages message queue for processinghistory
: Stores chat historycontext_history
: Maintains context for AI responseslong_term_memories
: Stores summarized conversation insights
- Uses OpenAI's GPT-4 model for natural language processing
- Maintains conversation context and long-term memory
- Adapts responses based on configured personality traits
- Supports real-time updates to AI behavior through personality adjustments
- Python 3.11
- AWS CLI configured with appropriate credentials
- Docker
- Node.js and npm (for AWS CDK)
The AWS Command Line Interface (CLI) allows you to interact with AWS services using commands in your terminal.
-
Install via
pip
:pip install awscli
Alternatively, install the latest version of AWS CLI v2 by following instructions from the official AWS CLI installation guide.
-
Verify the installation:
aws --version
This should display the AWS CLI version.
-
Download the AWS CLI installer for Windows:
AWS CLI Version 2 for Windows -
Run the installer by following on-screen instructions.
-
Verify the installation:
Open CMD or PowerShell and run:
aws --version
AWS CDK allows you to define AWS infrastructure using code. You can install it globally with npm.
Visit Node.js website and install the LTS version for your OS. Verify installation:
node -v
npm -v
Run the following command to install AWS CDK globally:
npm install -g aws-cdk
After installing AWS CDK, verify by running:
cdk --version
This should output the installed AWS CDK version.
Bootstrap CDK (first time only):
cdk bootstrap
Before using AWS CLI or AWS CDK, configure your AWS credentials.
-
Run the configuration command:
aws configure
-
Enter your credentials:
You'll be prompted to enter your AWS Access Key, Secret Access Key, default region, and output format.
Example:
AWS Access Key ID [None]: AWS Secret Access Key [None]: Default region name [None]: us-west-2 Default output format [None]: json
- Create and activate a virtual environment within infrastructure folder:
cd infrastructure
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
Run these command in the project root folder. The application uses AWS Systems Manager Parameter Store for environment variables. To manage them:
- Upload environment variables to Parameter Store:
python infrastructure/manage_env.py upload .env
- Download environment variables from Parameter Store:
python infrastructure/manage_env.py download .env
- Build the Docker image:
docker build -t trail-chat .
- Run locally:
docker run -p 3000:3000 trail-chat
- Create an ECR repository (if not exists):
aws ecr create-repository --repository-name trail-chat-repository --region us-west-2
- Login to ECR:
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin {account_id}.dkr.ecr.us-west-2.amazonaws.com
- Tag and push the image:
docker tag trail-chat:latest {account_id}.dkr.ecr.us-west-2.amazonaws.com/trail-chat-repository:latest
docker push {account_id}.dkr.ecr.us-west-2.amazonaws.com/trail-chat-repository:latest
Deploy the infrastructure:
cdk deploy --app "python app.py"
The CDK stack creates:
- VPC with public and private subnets
- EC2 instance with appropriate security groups
- IAM roles with necessary permissions
- SSM Parameter Store parameters
- ECR repository access
- Environment variables are stored in AWS Parameter Store
- EC2 instance uses IAM roles for AWS service access
- Security groups restrict access to necessary ports
- All sensitive data is encrypted at rest
To destroy the infrastructure:
cd infrastructure
cdk destroy --app "python app.py"
All package versions are listed in requirements.txt current chromadb version: 0.4.15
- When you create a new github Codespaces, you should install the packages manually.
run
"pip install --no-cache-dir -r .devcontainer/requirements.txt"
NOTE: It is not recommended to upload your API token to the codebase because the GIT and Slack will lock the privilege.
The AI Collaborator: Bridging Human-AI Interaction in Educational and Professional Settings
Mohammad Amin Samadi, Spencer JaQuay, Jing Gu, Nia Nixon, link
@article{samadi2024ai, title={The AI Collaborator: Bridging Human-AI Interaction in Educational and Professional Settings}, author={Samadi, Mohammad Amin and JaQuay, Spencer and Gu, Jing and Nixon, Nia}, journal={arXiv preprint arXiv:2405.10460}, year={2024} }