Coder Social home page Coder Social logo

xcloudplatform / 1template_aiservicegpuhostedstabilityotterllama Goto Github PK

View Code? Open in Web Editor NEW

This project forked from proteusiq/huggingfastapi

0.0 0.0 0.0 126 KB

FastAPI โšก ๐Ÿค— Huggingface Service Template

Home Page: https://github.com/Proteusiq/huggingfastapi

Shell 1.08% Python 87.34% Makefile 9.69% Dockerfile 1.89%

1template_aiservicegpuhostedstabilityotterllama's Introduction

Question Answering API

๐Ÿค— Huggingface + โšก FastAPI = โค๏ธ Awesomeness. How to structure Deep Learning model serving REST API with FastAPI

huggingfastapi How to server Hugging face models with FastAPI, the Python's fastest REST API framework.

The minimalistic project structure for development and production.

Installation and setup instructions to run the development mode model and serve a local RESTful API endpoint.

Project structure

Files related to application are in the huggingfastapi or tests directories. Application parts are:

huggingfastapi
โ”œโ”€โ”€ api              - Main API.
โ”‚ย ย  โ””โ”€โ”€ routes       - Web routes.
โ”œโ”€โ”€ core             - Application configuration, startup events, logging.
โ”œโ”€โ”€ models           - Pydantic models for api.
โ”œโ”€โ”€ services         - NLP logics.
โ””โ”€โ”€ main.py          - FastAPI application creation and configuration.
โ”‚
tests                - Codes without tests is an illusion 

Swagger Example

post_swagger response_swagger

Requirements

Python 3.6+, [Make and Docker]

Installation

Install the required packages in your local environment (ideally virtualenv, conda, etc.).

python -m venv .venv
source .venv/bin/activate
make install

Running Localhost

make run

Running Via Docker

make deploy

Running Tests

make test

Setup

  1. Duplicate the .env.example file and rename it to .env

  2. In the .env file configure the API_KEY entry. The key is used for authenticating our API.
    Execute script to generate .env, and replace example_keywith the UUID generated:

make generate_dot_env
python -c "import uuid;print(str(uuid.uuid4()))"

Run without make for development

  1. Start your app with:
PYTHONPATH=./huggingfastapi uvicorn main:app --reload
  1. Go to http://localhost:8000/docs or http://localhost:8000/redoc for alternative swagger

  2. Click Authorize and enter the API key as created in the Setup step.

Run Tests without using make

Intall testing libraries and run tox:

pip install tox pytest flake8 coverage bandit
tox

This runs tests and coverage for Python 3.8 and Flake8, Bandit.

TODO

  • Change make to invoke: invoke is overrated
  • Add endpoint for uploading text file and questions

1template_aiservicegpuhostedstabilityotterllama's People

Contributors

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