This project provides a comprehensive interface for managing and analyzing conversation data stored in a SQLite database. The application is built with Flask and supports various utilities such as viewing, linking, and searching through conversation records.
- Project Structure
- Setup Instructions
- Usage
- Scripts Overview
- Key Features
- Data Schema
- Requirements
- Troubleshooting
The project is organized into the following main folders and files:
├── app/
│ ├── __init__.py # Flask initialization
│ ├── app.py # Main app setup and blueprint registration
│ ├── db.py # Database connection utility
│ ├── parsers.py # Parsing JSON data for conversation details
│ ├── routes.py # Route definitions for web interface
│ ├── utils.py # Utility functions (e.g., timestamp formatting)
│ ├── helpers.py # Helper functions to fetch additional data
├── debug_scripts/
│ ├── add_timestamp.py # Migrates and updates 'timestamp' fields in Conversations table
│ ├── find.py # Script to search for specific IDs in database tables
│ ├── link_orphan_db.py # Script to link orphaned messages to conversations
│ ├── timestamp_fix.py # Script to fix missing timestamps in conversation records
├── static/
│ └── style.css # CSS for styling the web interface
├── templates/ # HTML templates for the app views
│ ├── index.html
│ ├── base.html
│ ├── review_orphaned_messages.html
│ ├── export_template.html
│ ├── message_detail.html
│ ├── conversation.html
├── data/
│ └── search_history.json # JSON file to log search history
├── GPT_conversations_database.db # SQLite database file
├── requirements.txt # Python dependencies
└── run.py # Script to run the Flask application
-
Clone the Repository
Clone this repository to your local machine:git clone https://github.com/sulaimonao/Conversations--Database-Search-App.git
-
Install Dependencies
Install the required Python packages by running:pip install -r requirements.txt
-
Database Setup
Ensure that theGPT_conversations_database.db
file is present in the project root. This SQLite database stores the conversation records.- If you encounter issues with missing or outdated columns, run the
debug_scripts/add_timestamp.py
script to migrate and update thetimestamp
column.
- If you encounter issues with missing or outdated columns, run the
Start the Flask server with:
python run.py
The application will start in development mode and be accessible at http://127.0.0.1:5000
.
- Home (
/
): Displays a list of conversations with options to filter by date and search by keywords. - View Conversation: Click on a conversation to view detailed messages and metadata.
- Review Orphaned Messages (
/review_orphaned_messages
): A page to review and link messages lacking a conversation ID.
The main entry point to run the Flask application. This script imports the app
instance and lists all registered endpoints.
Contains the core application files, including:
parsers.py
: Definesparse_conversation_data()
to process conversation and message metadata.routes.py
: Provides endpoints for viewing, searching, and exporting conversation data.db.py
: Supplies a reusable database connection viaget_db_connection()
.
Scripts to assist with database maintenance:
add_timestamp.py
: Adds and populates thetimestamp
column in theConversations
table.link_orphan_db.py
: Links orphaned messages to appropriate conversations based on timestamps.timestamp_fix.py
: Fixestimestamp
data in cases where it is null.
- Conversation Search and Filter: Search conversations by keywords and filter by date.
- Detailed View: Inspect conversation messages, metadata, and additional insights.
- Orphaned Message Linking: Automatically link orphaned messages to potential conversations.
- Export Options: Export conversations as JSON or HTML files.
- Database Maintenance Tools: Scripts for troubleshooting and updating the database.
-
Conversations
- Columns:
conversation_id
,title
,create_time
,update_time
,timestamp
- Columns:
-
Messages
- Columns:
message_id
,conversation_id
,content
,author_role
,create_time
- Columns:
-
Feedback
- Stores user feedback linked to specific messages.
-
ModelComparisons
- Logs model-generated comparison data.
- Python 3.10+
- Flask==2.2.5
- pandas==1.5.3
-
Database Issues
- Run
debug_scripts/add_timestamp.py
if thetimestamp
column is missing or outdated. - Ensure
GPT_conversations_database.db
is in the root directory.
- Run
-
Parsing Errors
- Confirm all conversation data adheres to the expected schema with valid
conversation_data
.
- Confirm all conversation data adheres to the expected schema with valid
-
Search Issues
- Validate the
search_history.json
file format and its path in thedata/
directory.
- Validate the