Chergpt-Basic is a simplified, login-free ChatGPT-like interface designed for quick deployment and educational use.
- β Mobile-friendly
- β Easy to deploy on Streamlit
- β Beginner-friendly
- π RAG support (Retrieval-Augmented Generation via vector embeddings)
- π Optional password protection (global and admin)
- π Built-in chat analytics and logging
- π PDF document processing for context-aware responses
- Features
- Prerequisites
- Quickstart
- Installation
- Configuration
- Use Cases
- Live Examples
- Troubleshooting
- Documentation & Resources
- Contributing
- Custom Instructions: Add tailored instructions to guide student or user interactions
- Chat Logging: Automatically store all conversations in a PostgreSQL database (NeonDB)
- Analytics Dashboard: Generate learning/teaching analytics from chatlogs
- Download Chatlogs: Export chat history as CSV for analysis
- User Name Tracking: Track conversations by user name
-
π§ RAG Support (Retrieval-Augmented Generation):
- Upload PDF documents through the admin web interface
- Automatic text extraction, chunking, and embedding generation
- Context-aware responses using pgvector similarity search
- Support for multiple PDF files with duplicate detection
- Secure in-memory processing (files never stored on disk)
- Smart query detection for context retrieval
-
π Password Protection:
- Admin Password: Protects admin panel for managing instructions, uploading PDFs, and viewing analytics
- Global Password: Optional single password to restrict access to the entire application
- See Streamlit authentication guide for additional options
-
π± Mobile Responsive: Optimized interface for both desktop and mobile devices
-
βοΈ Cloud Ready: Easy deployment on Streamlit Cloud with simple configuration
Before you begin, ensure you have the following:
- Python 3.8 or higher installed on your system
- OpenAI API Key - Get one here
- NeonDB Account (free tier available) - Sign up here
- Git (for cloning the repository)
- Streamlit Account (for cloud deployment) - Create account
- Operating System: Windows, macOS, or Linux
- RAM: Minimum 2GB (4GB recommended for PDF processing)
- Disk Space: At least 500MB free space
- Internet connection for API calls
Want to deploy immediately? You only need 4 configuration values in your secrets.toml:
OPENAI_API_KEY = "your_api_key_here"
DB_CONNECTION_STRING = "your_neondb_string_here"
ADMIN_PASSWORD = "your_secure_admin_password_here"
GLOBAL_PASSWORD = "optional_password_here"- OPENAI_API_KEY: Get from OpenAI API Keys
- DB_CONNECTION_STRING: Get from NeonDB Console after creating a project
- ADMIN_PASSWORD: Required - Create your own secure password for admin access
- GLOBAL_PASSWORD: Optional - Set this to require a password for all users to access the app
π Once these are configured, proceed to Deploy on Streamlit and you're live!
Follow these steps to run Chergpt-Basic on your local machine:
git clone https://github.com/String-sg/chergpt-basic.git
cd chergpt-basicFor Windows:
python -m venv venv
venv\Scripts\activateFor macOS/Linux:
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtThe required packages include:
streamlit- Web application frameworkopenai- OpenAI API clientpsycopg2-binary- PostgreSQL database adapterPyPDF2- PDF text extractiontiktoken- Token counting for embeddingspgvector- Vector similarity search supportpytest- Testing frameworkstreamlit-feedback- User feedback components
Create a .streamlit/secrets.toml file in your project directory:
mkdir -p .streamlit
touch .streamlit/secrets.tomlAdd your configuration (see Configuration section below):
OPENAI_API_KEY = "sk-..."
DB_CONNECTION_STRING = "postgresql://user:password@host/database"
ADMIN_PASSWORD = "your_secure_admin_password"
GLOBAL_PASSWORD = "optional_global_password" # Optionalstreamlit run main.pyThe app will open in your browser at http://localhost:8501
- Create a NeonDB Account: Go to https://console.neon.tech/
- Create a New Project:
- Click "Create Project"
- Choose a project name
- Select a region (choose Singapore or closest to your users)
- Get Connection String:
- Navigate to your project dashboard
- Click on "Connection Details"
- Copy the connection string (it looks like:
postgresql://user:password@host/database) - Use this as your
DB_CONNECTION_STRING
Note: The free tier of NeonDB provides:
- 3GB storage
- Always available (no hibernation)
- Perfect for small to medium deployments
- Create an OpenAI Account: Visit https://platform.openai.com/
- Generate API Key:
- Go to API Keys page
- Click "Create new secret key"
- Important: Copy and save the key immediately (you won't be able to see it again)
- Add Credits: Ensure your OpenAI account has available credits for API usage
Pricing Information:
- The app uses
gpt-4o-miniby default (cost-effective) - Embeddings use
text-embedding-ada-002 - Monitor usage in your OpenAI dashboard
π‘ Beginner Tip: Follow this step-by-step guide for detailed instructions on getting your OpenAI API key.
Admin Password (Required):
- Set
ADMIN_PASSWORDin your secrets.toml - Grants access to:
- Custom instruction editing
- PDF upload and RAG management
- Chat log analytics and downloads
- App title and description customization
Global Password (Optional):
- Set
GLOBAL_PASSWORDif you want to restrict general access - When configured, all users must enter this password to use the chat
- Leave empty or omit to allow unrestricted access to the chat interface
No additional configuration needed! Once your database is set up:
- Log in as admin (using
ADMIN_PASSWORD) - Navigate to "π€ Upload New Materials" in the sidebar
- Upload PDF files (up to 50MB, max 1000 pages)
- Files are processed automatically and made searchable
Security Features:
- Files are processed entirely in memory
- Original PDFs are never stored on disk
- Only text chunks and embeddings are stored in the database
- Automatic duplicate detection prevents re-processing
There are 3 simple steps to deploy your own Chergpt-Basic app:
- Set up your database (for storing chatlogs).
- Get your OpenAI API key.
- Deploy to Streamlit.
We recommend NeonDB (free tier works well).
- Create an account at Neon.
- Start a free project (choose Singapore region if relevant).
- Copy your DB connection string β you'll need this later.
π This string is what allows Chergpt-Basic to save chat data. Keep it safe.
- Go to OpenAI API keys.
- Click Create new secret key.
- Copy it somewhere safe β you'll need it for deployment.
π‘ Not sure how? Follow this beginner-friendly guide.
Click below to auto-deploy:
π Deploy Chergpt-Basic
Then:
-
Create a Streamlit account (free).
-
Connect your GitHub account.
-
Fork the repo β
String-sg/chergpt-basic. -
In Advanced Settings β Secrets.toml, paste:
OPENAI_API_KEY = "your_api_key_here" DB_CONNECTION_STRING = "your_neondb_string_here" ADMIN_PASSWORD = "set this to what you want" GLOBAL_PASSWORD = "optional_password_here"
Don't have a GitHub account and just want to deploy without cloning? Sure, you can!
-
Go to streamlit.io and create an account, then login
-
In the top right corner, click Create app
-
Select Deploy a public app from Github
-
Setup your app with the following fields:
- Repository =
https://github.com/String-sg/chergpt-basic/(You can click "Paste Github URL" and enter this) - Branch =
main - Main file path =
main.py - APP URL = choose your own or use the default
- Repository =
-
Click on Advanced settings, paste in the configuration details you previously obtained
Chergpt-Basic is ideal for educational and interactive scenarios:
Create immersive learning experiences by configuring the chatbot to assume different roles:
- Historical Figures: Students can interview historical personalities (e.g., Albert Einstein, Marie Curie)
- Medical Scenarios: Practice patient interactions for healthcare training
- Character Role-Play: Language learning through conversational practice with fictional characters
Example Setup:
Custom Instructions: "You are Isaac Newton. Respond to students' questions about
physics and mathematics from the perspective of a 17th-century scientist. Use
historical context but explain concepts clearly."
Build interactive "escape rooms" or challenge-based learning:
- Chinese Language Tasks: Students complete tasks like ordering food, asking for directions
- Spanish Conversation Practice: Progressive difficulty levels with checkpoint validation
- Vocabulary Building: Contextual word usage in realistic scenarios
Example Setup:
Custom Instructions: "You are a shopkeeper in Shanghai. Only respond in Mandarin Chinese.
Help students practice ordering items. After they successfully order 3 items,
congratulate them and move to the next checkpoint."
Run structured lessons and monitor student progress:
- Track student questions and responses
- Identify common misconceptions through chat log analysis
- Generate summaries of learning patterns
- Download data for further analysis
Example Use:
- Physics problem-solving sessions
- Economics concept explanations with RAG-powered textbook references
- Step-by-step programming tutorials
Upload course materials (PDFs) to create a subject-specific tutor:
- Economics Tutor: Upload textbooks, lecture notes, and the bot answers from course materials
- Science Lab Assistant: Upload lab manuals for procedure guidance
- Legal Studies: Upload case law documents for reference-based learning
How it Works:
- Admin uploads relevant PDF documents
- System automatically processes and creates searchable embeddings
- Student asks a question
- Bot searches uploaded materials for relevant context
- Responds with context-aware answers based on course materials
Configure the bot to conduct assessments:
- Multiple-choice quizzes with instant feedback
- Open-ended questions with guided responses
- Practice exams with performance tracking
See Chergpt-Basic in action:
- Physics (Lookang fork) - Interactive physics tutoring
- Physics (CPDD deployment) - Physics education platform
These examples showcase different configurations and use cases for educational purposes.
Issue: psycopg2.OperationalError: could not connect to server
Solutions:
- Verify your
DB_CONNECTION_STRINGis correct insecrets.toml - Check that your NeonDB project is active (not suspended)
- Ensure you're using the correct connection string format:
postgresql://user:password@host/database - Test the connection string using a PostgreSQL client or command line:
psql "your_connection_string_here"
Tip: The connection string should look like: postgresql://username:password@ep-xxxxx.region.aws.neon.tech/neondb
Issue: openai.error.AuthenticationError: Incorrect API key provided
Solutions:
- Verify your API key in
secrets.tomlstarts withsk- - Ensure there are no extra spaces or quotes in the key
- Check that your OpenAI account has available credits
- Generate a new API key from OpenAI dashboard
Issue: Rate limit exceeded
Solutions:
- Wait a few minutes before retrying
- Upgrade your OpenAI plan for higher rate limits
- Reduce the frequency of requests in your application
Issue: File too large or Processing failed
Solutions:
- Ensure PDF is under 50MB
- Check PDF page count is under 1,000 pages
- Verify PDF is not encrypted or password-protected
- Try converting the PDF to a simpler format (remove images if possible)
Issue: No text extracted from PDF
Solutions:
- PDF might be image-based (scanned) - use OCR tools first
- Try opening the PDF and copying text manually to verify it contains extractable text
- Use a different PDF or re-save the document
Issue: ModuleNotFoundError: No module named 'xyz'
Solutions:
- Verify
requirements.txtcontains all dependencies - Check that Streamlit Cloud is using the correct Python version (3.8+)
- Rebuild the app from Streamlit Cloud dashboard
Issue: Secrets not found
Solutions:
- Go to Streamlit Cloud dashboard β Your App β Settings β Secrets
- Ensure all required secrets are defined:
OPENAI_API_KEY = "sk-..." DB_CONNECTION_STRING = "postgresql://..." ADMIN_PASSWORD = "your_password"
- Click "Save" after adding secrets
- Reboot the app
Issue: "Incorrect password" even with correct password
Solutions:
- Check for extra spaces in
ADMIN_PASSWORDinsecrets.toml - Ensure you're entering the password exactly as defined
- Clear browser cache and cookies
- Try in an incognito/private browser window
Issue: Uploaded PDFs but no context is retrieved
Solutions:
- Verify PDFs were successfully processed (check admin panel β RAG Management)
- Ensure RAG is enabled in admin settings (toggle should be ON)
- Check that your query is related to the uploaded content
- Review the similarity threshold - lower it if needed in the code
Issue: pgvector extension not found
Solutions:
- Ensure NeonDB has pgvector extension enabled (should be automatic)
- Try running the initialization manually from admin panel
- Contact NeonDB support if the extension is not available
Issue: streamlit: command not found
Solutions:
- Ensure virtual environment is activated
- Reinstall streamlit:
pip install streamlit - Check Python PATH:
which pythonorwhere python
Issue: Port 8501 already in use
Solutions:
- Kill existing Streamlit process:
- Windows:
taskkill /F /IM streamlit.exe - Mac/Linux:
pkill -f streamlit
- Windows:
- Run on different port:
streamlit run main.py --server.port 8502
Issue: Slow response times
Solutions:
- Check OpenAI API status: status.openai.com
- Verify database performance (NeonDB free tier may have limits)
- Reduce RAG chunk retrieval count (modify
top_kparameter) - Consider upgrading to a paid plan for better performance
If you encounter issues not covered here:
- Check existing GitHub issues: GitHub Issues
- Create a new issue: Include:
- Error messages (sanitize sensitive information)
- Steps to reproduce
- Your environment (Python version, OS)
- Deployment method (local vs Streamlit Cloud)
- Streamlit Community Forum: discuss.streamlit.io
- Review logs: Check Streamlit Cloud logs or terminal output for detailed error messages
-
Streamlit Documentation: https://docs.streamlit.io/
-
OpenAI API Documentation: https://platform.openai.com/docs
-
NeonDB Documentation: https://neon.tech/docs
-
pgvector: Vector similarity search for PostgreSQL
-
PyPDF2: PDF text extraction
-
Tiktoken: Token counting library
- Getting OpenAI API Key: Teacher Tech Guide - Beginner-friendly walkthrough
- RAG (Retrieval-Augmented Generation): Understanding how context-aware AI works
- Prompt Engineering: OpenAI Guide - Writing effective custom instructions
- GitHub Repository: String-sg/chergpt-basic
- Issues & Bug Reports: GitHub Issues
- Streamlit Community: discuss.streamlit.io
- Streamlit Gallery: https://streamlit.io/gallery
- OpenAI Cookbook: https://github.com/openai/openai-cookbook
We welcome contributions to Chergpt-Basic! Here's how you can help:
- Report Bugs: Open an issue on GitHub with details about the bug
- Suggest Features: Share your ideas for new features or improvements
- Submit Pull Requests: Fix bugs or add features
- Improve Documentation: Help make the README and docs better
- Share Use Cases: Tell us how you're using Chergpt-Basic
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/chergpt-basic.git - Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes and test thoroughly
- Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/your-feature-name - Open a Pull Request
Run the test suite before submitting PRs:
pytestRun specific tests:
pytest test_rag.py
pytest test_user_storage.py
pytest app_test.pyThis project uses Pylint for code quality. Run it locally:
pylint $(git ls-files '*.py')This project is open source. Please check the repository for license details.
For questions, issues, or collaboration opportunities:
- Open an issue on GitHub
- Check existing documentation and troubleshooting guide above
Made with β€οΈ for educators and learners

