Skip to content

Intelligent-Intern/openai-rag-chat-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAG Application with Flask Chat (Developer Mode)

This is a Python application that maps user questions to database entries and now includes a web-based chat interface built with Flask. When a question closely matches an existing entry, the stored answer is retrieved. Otherwise, the OpenAI API (using the o3-mini model) is called to generate an answer, which is then stored and returned.

Developer Mode

In developer mode, any changes you make to the code will be automatically applied thanks to volume mapping and Flask's auto-reload feature.

Environment Setup

Before starting the application, ensure that you have your OpenAI API key set in your environment. You can create a .env file in the project root with the following content:

OPENAI_API_KEY=your_openai_api_key_here

Docker Compose will automatically pass this variable to the app service.

Running with Docker Compose

  1. Build the Package:
    When building the package, you will be prompted for your OpenAI API token if it is not set in the environment.

    make build
    
  2. Start the Application:
    Run the following command to start both the PostgreSQL database and the Flask app in developer mode:

    make up
    

    After starting, you'll see a message with a clickable link. Click or copy the following link into your browser to access the chat interface: http://localhost:5000

  3. Stop the Application:
    To stop the application, run:

    make down