This project is a PDF Question Answering Assistant that utilizes OpenAI's API, Gradio, and a Postgres-backed Vector Database. It allows users to input a PDF URL and ask questions about its content, leveraging vector search to provide accurate answers.
- Extracts knowledge from a PDF using its URL.
- Utilizes vector search with PgVector2 for efficient information retrieval.
- Stores chat history in a Postgres database.
- Provides a user-friendly web interface using Gradio.
- Integrates with OpenAI's API for natural language processing.
docker run -d \
-e POSTGRES_DB=ai \
-e POSTGRES_USER=ai \
-e POSTGRES_PASSWORD=ai \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v pgvolume:/var/lib/postgresql/data \
-p 5532:5432 \
--name pgvector \
phidata/pgvector:16This sets up a PostgreSQL instance with the pgvector extension on port 5532.
-
Clone the Repository:
git clone <repository_url> cd <repository_folder>
-
Install Dependencies:
pip install -r requirements.txt
-
Create a
.envFile:OPENAI_API_KEY=your_openai_api_key
python main.pyOpen your browser and go to: http://127.0.0.1:7860
You can:
- Enter a PDF URL
- Ask questions about the PDF content
- Extracts knowledge from a PDF URL using
PDFUrlKnowledgeBase - Stores and retrieves conversation history with
PgAssistantStorage - Uses
PgVectorfor vector-based knowledge search - Gradio interface for user interaction
- Database URL:
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
- Environment Variable:
OPENAI_API_KEY=your_openai_api_key