An app that helps you to practice negotiations with ChatGPT.
- We’re building a simple app to help our users practice negotiating to buy a used car.
- Stack: Python Flask application, integrates with OpenAI’s LLM, and talks to a Postgres database.
- We would like to extend the application:
- First, we will do some simple prompt engineering to improve the bot.
- Then we will add a feature together: a way to "resolve" the negotiation and do the following:
- Persist the final price into the database.
- Return the following information:
- The final price
- A placement (3rd out of x total negotiations) in all stored negotiations
- Recommendations
- Start with the simplest working solution you can, we can refactor at the end.
- Write tests to help you work through the implementation.
- Please ask questions now and as you go.
Negotiator is a server side rendered app using Flask. It uses Lit to create web components to add dynamic capabilities to each page. Lit web components are developed and tested in the web components directory, and build Javascript and CSS artifacts are copied to the Flask app's static directory. This approach allows for the simplicity of server side rendered app with the dynamic features of a single page app.
-
Install dependencies
brew install pyenv poetry nodejs postgresql@14 poetry install npm install --prefix web-components
-
Set up the database
psql postgres < databases/drop_and_create_databases.sql make migrate migrate-test -
Build the frontend and watch for changes
npm run build:watch --prefix web-components
-
Run the app in a separate terminal
cp .env.example .env vi .env source .env poetry run python -m negotiator
poetry run mypy negotiator tests
poetry run python -m unittest
npm run test --prefix web-components-
Install dependencies and run via gunicorn
poetry export --without-hashes --format=requirements.txt > requirements.txt
pip install -r requirements.txt
gunicorn -w 4 'negotiator.app:create_app()' --bind=0.0.0.0:${PORT}
-
Pack and run via docker
poetry export --without-hashes --format=requirements.txt > requirements.txt
pack build negotiator --builder=gcr.io/buildpacks/builder:v1
docker run -p 8081:8081 --env-file .env.docker negotiator