GithubHelp home page GithubHelp logo

iulianav / chatbot-api Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 29 KB

The project represents an API used by data scientists to further improve an existing chatbot. Requests are sent by a background job which pushes the customer data and consent via HTTP.

License: Apache License 2.0

Shell 0.43% Dockerfile 0.89% Makefile 0.22% Python 98.46%

chatbot-api's Introduction

chatbot-api

The project represents a Data API used by data scientists to further improve an existing chatbot. Requests are sent by a background job which pushes the customer data and consent via HTTP.

How to run

To run this project, you need to have Docker and Compose installed.

The docker-compose commands are already abstracted through Makefile rules for simplicity. Run the following commands to:

  1. Build the app: make build-app
  2. Run the app: make run-app
  3. Shut down the app: make kill-app

Now the Data API app should be running by default at http://0.0.0.0:80, together with a PostgreSQL database that it is connected to. The app and the database each run in their own container.

The default database's settings can be found in .env. Feel free to change those according to your needs by having your own .env file locally.

To remove the persistent volume created by the database container, and hence delete the database contents, run:

  1. Find db volume name: docker volume ls
  2. Delete db volume: docker volume rm <volume_name>

Development

To further develop the project, you should create a virtual environment with virtualenv or anaconda, and then install both the project requirements and the development requirements inside of it:

  1. Create environment: conda create <env_name> python=3.9
  2. Activate environment: conda activate <env_name>
  3. Install requirements : pip install -r requirements.txt
  4. Install development requirements: pip install -r requirements-dev.txt

You can find additional Makefile rules to help with checking the code quality in makefiles/Makefile.python:

  1. Sort imports: make isort
  2. Format code: make black
  3. Lint code: make lint
  4. Type checking: make analyze

Manual testing

To manually test the API, you can go to http://0.0.0.0:80/docs while the app is running. It will display a default UI to manually test each endpoint by inputting valid data. The UI also displays the status codes and responses.

To check the content of the database after each request, you should:

  1. Enter the db container: docker exec -it postgres-db bash.
  2. Connect to PostgreSQL as user postgres: psql -U postgres
  3. Get access to the chatbotapi db: \c chatbotapi
  4. Retrieve the records of interest after each request: e.g. SELECT * from user_inputs;

Sometimes, especially after deleting the database persistent volume, there might be an error stating that the relation user_inputs does not exist. In this case: kill, re-build and re-start the app.

Unit testing

To run the unit tests in the development virtual environment, run the command: python -m pytest tests

TODO

  • Add docstrings & comments

chatbot-api's People

Contributors

iulianav avatar

Stargazers

Anne Thorpe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.