7AM7 / movie-recommender-chatbot

Movie recommender chatbot using LangChain, OpenAI and Semantic Router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Movie Recommender Chatbot

Movie recommender chatbot using FastAPI, Streamlit, LangChain and semantic-router with FAISS RAG.

Streamlit app

How to Run it 🛫

Navigate to the project directory 1.

cd movie-recommender-chatbot
  1. Create .env file and add these keys
OPENAI_API_KEY={OPENAI_API_KEY}
RETRIEVER_EMBEDDING_MODEL=text-embedding-3-small
OPENAI_TIMEOUT=30
OPENAI_TEMPERATURE=0.3
OPENAI_MODEL_NAME=gpt-4o
RETRIEVER_EMBEDDING_THRESHOLD=0.4

Run - with Docker 🐳

docker-compose up --build

Run - locally 💻

Backend

  1. Make sure you have Poetry innstalled in your enviornment
pip install poetry
  1. Navigate to the backed directory
cd components/backend
  1. Install dependencies
poetry shell
poetry install
  1. Run the app
 cd src/
 uvicorn app:app --host 0.0.0.0 --port 8080

Frontend

  1. Navigate to the backed directory
cd components/frontend
  1. Install dependencies
poetry shell
poetry install
  1. Run the frontend (optional)

Make sure you are in the right dir frontend

streamlit run src/app.py --server.port 8081 --server.address 0.0.0.0

APIs

  • URL: /chat
  • Method: POST
  • Description: stream the chatbot response to the user
  • Request Body:
{
    "message": "hello",
    "clear_history": false
}
  • Success Response:

  • Response Type: text/event-stream

  • Code: 200 OK

  • Content:

      data: {"streamed_text": "Hello! I'm here to help you find the perfect movie to watch. ", "is_final": false}
    
      data: {"streamed_text": "Could you tell me a bit about what you're in the mood for? ", "is_final": false}
    
      data: {"streamed_text": "Are there any specific themes, settings, or favorite movies you'd like me to consider for my recommendations?", "is_final": true}
    
    

About

Movie recommender chatbot using LangChain, OpenAI and Semantic Router


Languages

Language:Python 91.0%Language:Dockerfile 9.0%