Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastapi-app-with-langchain

This project is purposed to create RAG(retriever-augmented-generation) chatbot application using fastapi and docker.

If you upload .pdf file, RAG chatbot performs Q&A based on your document.

This project heavily referenced @AshishSinha5’s rag_api project.

Table of Content

  • Getting Started
  • Usage
    • Starting the local server
    • Deploying the server

Getting Started

  1. Clone this repository to your local machine.

    git clone https://github.com/jodog0412/langchain-app-with-fastapi.git
    cd langchain-app-with-fastapi
  2. Create a virtual environment in your local directory and activate it.

    python -m venv .venv
    .venv/bin/activate.bat
  3. Install Python packages in your virtual environment.

    pip install -r requirements.txt
    
  4. Set OPEN_AI_API_KEY on .env file in the app directory.

    # app/.env
    OPENAI_API_KEY =
    

Usage

Starting the local server

cd app
uvicorn main:app --reload

Deploying the server

  1. Set OPEN_AI_API_KEY on Dockerfile.

    FROM python:3.10
    
    WORKDIR /code
    
    COPY . /code
    
    RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
    
    ENV OPENAI_API_KEY "ENTER YOUR OPENAI API KEY"
    
    WORKDIR /code/app
    
    CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
    
  2. Build docker-image.

    docker build --pull --rm -f "Dockerfile" -t langchainappwithfastapi:latest "." 
  3. Create docker-container.

    docker run -d --name container -p 8000:8000 langchainappwithfastapi

Features/Update

  • build history-aware RAG chatbot
  • implement client-server RESTful-API
  • implement websocket connection
  • deploy the app
  • bug fixes(deployed app has some errors)
  • support local LLM(only supports GPT model in current version)

About

RAG chatbot applilcation with fastapi and docker

Topics

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages