Skip to content

enriquecatala/fastapi-ai-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cloud Data Ninjas GitHub followers of Enrique Catalá Sponsor Enrique Catalá on GitHub LinkedIn Enrique Catalá Twitter @enriquecatala Data Engineering with Enrique Catalá Canal de Enrique Catalá

Author: Enrique Catalá Bañuls

fastapi-ai-template

FastAPI ai templates to deploy AI models. ❤️ Sponsor this project

You don´t need to fork this project. This project is a template for cookiecutter that can be used directly from your command line without forking it. The output of this project is a fully configured FastAPI application ready for you to start coding and deploy.

What is included on this template?

🖼️ The base to start an openapi project for AI: spacy/huggingface, FastAPI.

🐋 A Dockerfile+docker-compose to build the container image for your project. If you want to contribute to this template please open an issue or fork and send a PULL REQUEST.

⏯ Visual studio code launch.json and tasks.json to debug the project in VS Code with container support

Setup

Since this is a template for cookiecutter, you need first to install cookiecutter.

Install cookiecutter

This template requires cookiecutter to be installed.

FastAPI base template

Once installed, you can run the following command to create a new project:

# go to the directory where you want to create the project
cd ~
mkdir your-project
cd your-project
# create your project using this template
cookiecutter https://github.com/enriquecatala/fastapi-ai-template.git \
             -v \
             --directory="base-template"

This will create a base ApiREST project ready for you to test and deploy. It will include a test method that you can use to test your code.

docker compose build
docker compose up

Now navigate to http://127.0.0.1:5000/docs to see the documentation.

FastAPI + spacy template

Once installed, you can run the following command to create a new project:

# go to the directory where you want to create the project
cd ~
mkdir your-project
cd your-project
# create your project using this template
cookiecutter https://github.com/enriquecatala/fastapi-ai-template.git \
             -v \
             --directory="spacy-template"

FastAPI + huggingface template

TODO

Configuration

After asking you for parameter configuration values, it will create the following files:

your-project/
├── fastapi-ai-template/  <--------- Project template 
    └── .vs-code/         <--------- visual studio debug config 
        ├── launch.json        
        └── tasks.json
    └── app/              <--------- Project folder 
        ├── api/          <--------- api routing
        ├── core/         <--------- event handling and security
        ├── models/       <--------- Model classes definition
        ├── services/     <--------- API main methods (this is where you have the main logic)
        └── main.py
    ├── Dockerfile 
    ├── docker-compose.yml 
    ├── gunicorn_conf.py  <--------- web server config
    ├── requirements.txt  <--------- default libraries
    └── ...    

Project template parameters

Executing the cookiecutter command will ask you in the command prompt for all the parameters defined in the cookiecutter.json file. Default values are the following:

{
    "full_name": "Enrique Catalá Bañuls",
    "email": "[email protected]",
    "project_name": "FastAPI AI template",
    "project_slug": "{{ cookiecutter.project_name|lower|replace(' ', '-') }}",
    "project_role": "fastapi API",
    "container_name": "fastapi-ecb-api",
    "port": "5000",
    "repo_name": "fastapi-ai-template",
    "project_short_description": "FastAPI template generator for AI projects. It generates a template for a FastAPI project with a simple and easy to use interface.",        
    "version": "0.1.0",
    "application_insights_key": "USE A VALID APP INSIGHTS KEY",
    "api_key": "WRITE YOUR OWN API KEY :)",
    "_copy_without_render": [      
      "model-best"
  ]
  }

NOTE: For more tips, please check the docs.

About

FastAPI ai template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published