A Chrome extension that uses AI agents to help users negotiate the best deals.
generated with DocToc
- Table of Contents
- Overview
- Key Features
- Technologies Used
- Project Structure
- Setup
- Usage
- Development
- Package Management
- Customizing AI Agents
- Modifying Prompts
- Contributing
- Troubleshooting
A Chrome extension that uses AI agents to help the user negotiate the best deals:
-
Context & Goal Setting:
- From the chrome extention, ask users about their goals of the deal.
- Use Pydantic to define the schema via models
-
Negotiation Starts:
- Employ Llama 3.1 (running on Together AI) and call
/browse
API endpoint via FastAPI - Record the log on the negotiation.log to track the conversation
- Employ Llama 3.1 (running on Together AI) and call
-
User Interaction:
- Presents the seller's response and ask for a counter response.
- Allows the buyer to choose whether to accept or renegotiate.
-
Response Generation:
- Collect user input.
- Passes the information back to Llama 3.1 on Together AI.
- Generates response to the end user.
- Collect user inputs via Chrome extention
- Use Pydantic to build a schema and validate the inputs
- AI-driven context analysis & negotiation converation using Llama 3.1 on Together AI
- Call API via FastAPI and render response on the user-friendly interface
- Automated generation of response drafts using Llama 3.1
[data-doc-management]
- Upstage: Converts natural language queries into SQL Doc
- Chroma DB: Vector database for storing and querying standard contract clauses
- SQLite: Database for storing application data
[ai-model-curation]
- Together AI: Hosting Llama 3.1 for text processing, clause segmentation, and response generation
[deployment-framework]
- Python: Primary programming language
- Poetry: Backend build system and package installer/resolver doc
- Pydantic: Data validation library for Python
- Fast API: Web framework for building APIs based on standard Python type hints
- Replit: Deploy Fast API on Replit server (See the
.replit
andreplit.nix
for its configuration.) - Koyeb: Deploy the backend repo and access in the production env
.
└── frontend - react app
|
└── src
└── __init__.py
└── api.py = connect with database
└── main.py = build fastAPI connection
└── Prompts
└── Browse.py
└── Negotiate.py
└── Validate.py
└── tests
└── __init__.py
└── test_endpoint.py: test connection to the browser endpoint
└── test_negotiation.py: test and log the negotiation process and outcome
├── pyproject.toml
└── poetry.lock
< Koyeb deployment>
└── requirements.txt
└── Procfile
└── runtime.txt
-
Install the
poetry
package manager:curl -sSL https://install.python-poetry.org | python - poetry --version
-
Install dependencies on pyproject.toml:
poetry install
-
Set up environment variables: Create a
.env
file in the project root and add the following:TOGETHER_API_KEY=your_together_api_key DATABASE_URL=your_database_url API_ROUTE=your_public_api_route
-
Test the negotiation process and outcome on terminal:
poetry run neg
The outcome will be recorded in the negotiation.log file.
-
In a separate terminal, test the connection to the client interface:
poetry run client
The results will be printed on your terminal. When you update the
main.py
, run this command to see if the update is working properly.The backend will be available at
http://localhost:8000
. -
Deploy the API via Koyab
koyeb deploy . <amazing_app_name_of_your_choice>/src --instance-type=free
*See the doc for the Koyeb CLI installation and more.
Now you can access the API endpoint from the public URL
...koyab.app
. -
Run the frontend. (Open another terminal and set the root to
frontend
. For now, frontend contains test connection to the public API)npm i npm start
The frontend will be available at
http://localhost:3000
.
- Add a package:
poetry add <package>
- Remove a package:
poetry remove <package>
- Run a command in the virtual environment: add a script to pyproject.toml, then
poetry run <command>
- To reinstall all the package: after deleting poetry.lock file, run
poetry install
To modify or add new AI agents, edit the test_negotiation.py
file to test on the terminal, and/or edit the main.py
file to apply the modification to the API.
Necessary prompts are stored in the Prompts
folder. Add or modify the prompt accordingly.
(To avoid errors, we recommend adding a new prompt file to the Prompt folder.)
- Fork the repository
- Create your feature branch (
git checkout -b feature/your-amazing-feature
) - Commit your changes (
git commit -m 'Add your-amazing-feature'
) - Push to the branch (
git push origin feature/your-amazing-feature
) - Open a pull request
Common issues and solutions:
- API key errors: Ensure all API keys in the
.env
file are correct and up to date. - Database connection issues: Check if the Chroma DB is properly initialized and accessible.
- Memory errors: If processing large contracts, you may need to increase the available memory for the Python process.
- Issues related to the AI agents: Check the
negotiation.log
file for detailed error messages and stack traces.