Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Repository files navigation

Negotiator

An app that helps you to practice negotiations with ChatGPT.

Challenge

  • 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.

Architecture

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.

Build and run

  1. Install dependencies

    brew install pyenv poetry nodejs postgresql@14
    poetry install
    npm install --prefix web-components
  2. Set up the database

    psql postgres < databases/drop_and_create_databases.sql
    make migrate migrate-test
  3. Build the frontend and watch for changes

    npm run build:watch --prefix web-components
  4. Run the app in a separate terminal

    cp .env.example .env
    vi .env
    source .env
    poetry run python -m negotiator

Running tests

poetry run mypy negotiator tests
poetry run python -m unittest
npm run test --prefix web-components

Running without poetry

  1. 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}
  2. 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages