Giter VIP home page Giter VIP logo

speakers-corner-llm-rag-application's Introduction

Architecting Scalable AI RAG Systems

How to deploy a flask RAG application on Azure, specifically Azure Container App service- A serverless engine.

Embeddings storage

QdrantDB(Container)

Chat history storage

Redis(Container)

API server

Python Flask

LLM

OpenAI - gpt-3.5-turbo

In the python flask project we have-

  1. Added Qdrant as a vector db store
  2. Methods that have been enhanced with inclusion of Qdrant APIs(Initialize, search_results, generate methods)
  3. Redis implementation to store the chat history, which will be used as context
  4. Basic chat UI in HTML, CSS to communicate with the bot

Running this code on your local machine

Pre requistes to be installed

  1. Docker
  2. Azure CLI
  3. Python 3.9
  4. Create a .env file under src folder with below data

OPENAI_API_KEY=""

QDRANT_HOST="localhost"

QDRANT_PORT="6333"

REDIS_HOST="localhost"

REDIS_PORT="6379"

REDIS_PASSWORD="None"

On CMD line

  1. Create and activate your python environment for this project

  2. Install the required packages pip install -r requirements.txt

  3. Run Qdrant docker container docker run -d -p 6333:6333 qdrant/qdrant

  4. Run Redis docker container docker run --name redis -d -p 6379:6379 redis

  5. Run flask server and check locally if all works(from src folder). Access the app from localhost:5000/openai. python flask_rag_llm_openai_hf.py


Azure deployment


  1. Prerequisites
  • Provison a suitable Azure container app service environment, based on scale, redundancy and region of choice
  • Providon a azure container registry. You could also use a docker public image, unless you want it to be available for everyone else to use.
  1. Login to Azure on your command line and push your image to registry

az login

az account set --subscription <your specific subscription>

az acr login -n <registry name created on Azure>

  1. cd to correct folder having dockerfile, and build the image

docker build . -t speakerscornerregistry.azurecr.io/openai

takes about 100s-200s

Then push the image to registry with tag

docker push <registry name created on Azure>.azurecr.io/openai:latest

  1. On container options page pick the specific registry, image and tag of the image just pushed. Key in your environment variables manually while creating the conatiner app, i.e. your openAi key and its value.

  2. On bindings create and select your two sidecars qdrant and redis

  3. In the network tab while creating the ACA check "Enable ingress", and "Traffic from anywhere" to allow receiving traffic from internet when you open the container app link. Update the target port to 5000 as this is the port where the flask api is being served.

  4. Once you hit Create. You can check status of you deployment under "Revisons and replicas" menu.

  5. Once the app is ready, you can access the bot page. The link would be similar to below https://{container app name}.{random word}.{region}.azurecontainerapps.io/openai

Substitutes for Serverless GPU for inferencing purpose

  • Replicate
  • Runpod
  • Huggingface

This code release is being done as part of speakers corner session that was conducted on 16th April 2024 https://www.landing.ciklum.com/sc-architecting-scalable-ai

Ciklum speakers corner

speakers-corner-llm-rag-application's People

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.