A newer version of the Gradio SDK is available: 6.10.0
title: GPT
emoji: π¬
colorFrom: yellow
colorTo: purple
sdk: gradio
sdk_version: 5.0.1
app_file: app.py
pinned: false
short_description: AI Chatbot with File Upload Support
π€ AI Chatbot with File Upload Support
A ChatGPT-like interface built with Gradio that supports file uploads and uses a local transformer model for text generation.
β¨ Features
- π€ Chat Interface: Modern, clean chat interface similar to ChatGPT
- π File Upload Support: Upload and analyze multiple file types:
- PDF documents (.pdf)
- Word documents (.docx)
- Text files (.txt)
- CSV files (.csv)
- Excel spreadsheets (.xlsx, .xls)
- βοΈ Configurable Settings:
- Custom system messages
- Temperature control for response creativity
- Maximum token limits
- π Local Model: Uses your specified transformer model for privacy and control
- π¬ Conversation History: Maintains chat context throughout the session
- π‘οΈ Error Handling: Graceful fallback to smaller models if the main model fails
- π± Responsive Design: Clean, user-friendly interface
π How to Run the Chatbot
β οΈ IMPORTANT: Virtual Environment Required
This project uses a virtual environment with all dependencies installed. Follow the exact sequence below to run the chatbot successfully.
β Recommended Method (Step-by-Step)
Open Terminal in the project folder:
cd "C:\Users\Cosmo\Desktop\GPT\GPT"Activate Virtual Environment:
.\env\Scripts\activate.batRun with Full Python Path (this ensures it works even if activation doesn't fully work):
C:/Users/Cosmo/Desktop/GPT/GPT/env/Scripts/python.exe app.pySuccess! You should see:
* Running on local URL: http://127.0.0.1:7860Open your browser and go to: http://127.0.0.1:7860
Alternative Methods
Method 1: Using the Batch File (if available)
- Double-click the
start_chatbot.batfile in the project folder - This should automatically handle everything
Method 2: PowerShell (if execution policy allows)
- Open PowerShell in the project folder
- Fix execution policy (one-time setup):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - Activate and run:
.\env\Scripts\Activate.ps1 python app.py
Method 3: From VS Code
- Open the project folder in VS Code
- Open integrated terminal (Ctrl + `)
- Use the recommended sequence:
.\env\Scripts\activate.bat C:/Users/Cosmo/Desktop/GPT/GPT/env/Scripts/python.exe app.py
β Verify Virtual Environment is Active
When the virtual environment is active, you should see (env) at the beginning of your command prompt:
(env) C:\Users\Cosmo\Desktop\GPT\GPT>
β οΈ Important: Even with (env) showing, you may still need to use the full Python path for the app to work correctly.
β Common Errors & Solutions
Error: "ModuleNotFoundError: No module named 'gradio'"
Even if you see (env) in your prompt, this error means the Python path isn't correct.
β Solution: Always use the full Python path:
C:/Users/Cosmo/Desktop/GPT/GPT/env/Scripts/python.exe app.py
Error: ".\env\Scripts\Activate.ps1 cannot be loaded"
This is a PowerShell execution policy issue.
β Solutions (choose one):
Use Command Prompt activation instead:
.\env\Scripts\activate.batFix PowerShell execution policy:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserUse the batch file: Double-click
start_chatbot.bat
Error: Missing packages
If packages aren't installed in the virtual environment:
# Activate first
.\env\Scripts\activate.bat
# Then install
pip install -r requirements.txt
π Using the Chatbot
- Start the application using one of the methods above
- Open your browser to the displayed URL (usually http://127.0.0.1:7860)
- Upload files (optional) using the file upload area
- Type your message in the text box
- Click Send or press Enter to get AI responses
- Adjust settings in the right panel as needed
π File Processing Capabilities
The chatbot can extract and analyze content from:
- PDF files: Extracts text from all pages using PyPDF2
- Word documents: Extracts text from paragraphs using python-docx
- Text files: Reads content directly with UTF-8 encoding
- CSV/Excel files: Converts data to readable format using pandas
- Multi-file Analysis: Upload multiple files simultaneously for comprehensive analysis
π§ Model Information
- Primary Model:
openai/gpt-oss-120b - Fallback Model:
microsoft/DialoGPT-medium(if primary model fails) - Framework: Hugging Face Transformers
- Interface: Gradio web interface
- Local Processing: All inference runs locally for privacy
βοΈ Customization
Model Configuration
Edit model.py to customize:
- Change the
model_idvariable to use different models - Adjust model parameters like
torch_dtypeanddevice_map - Modify fallback behavior
Interface Customization
Edit app.py to modify:
- Chat interface appearance and behavior
- File upload restrictions and processing
- System message defaults
- Parameter ranges and defaults
π Requirements
- Python: 3.13+ (configured in virtual environment)
- GPU: CUDA-compatible GPU recommended for larger models
- Memory: Sufficient RAM for model loading (varies by model size)
- Storage: Space for model files (can be several GB)
- Internet: Required for initial model download
π¦ Dependencies
All dependencies are managed in the virtual environment:
gradio- Web interface frameworktransformers- Hugging Face model librarytorch- PyTorch deep learning frameworkPyPDF2- PDF text extractionpython-docx- Word document processingpandas- Data analysis and CSV/Excel handlingopenpyxl- Excel file support
π οΈ Troubleshooting
Common Issues:
Model Loading Errors:
- Check internet connection for initial download
- Verify sufficient disk space
- The app will automatically fall back to a smaller model
File Upload Issues:
- Ensure file types are supported
- Check file permissions and accessibility
- Large files may take time to process
Performance Issues:
- Consider using a smaller model for faster responses
- Reduce max_tokens for quicker generation
- Ensure adequate GPU memory
Environment Issues:
- Verify the virtual environment is properly activated
- Check that all dependencies are installed
- Review terminal output for specific error messages
Getting Help:
- Check the terminal output for detailed error messages
- Verify file formats are supported
- Ensure the virtual environment is activated
- Try the fallback model if the primary model fails
π― Usage Tips
- File Analysis: Upload relevant documents before asking questions about them
- Context: The AI maintains conversation history, so you can ask follow-up questions
- Settings: Adjust temperature for more creative (higher) or focused (lower) responses
- Batch Processing: Upload multiple files at once for comprehensive analysis
- Privacy: All processing happens locally - your files and conversations stay private
Your ChatGPT-like chatbot is ready to use! πPT emoji: π¬ colorFrom: yellow colorTo: purple sdk: gradio sdk_version: 5.0.1 app_file: app.py pinned: false short_description: My own gpt
An example chatbot using Gradio, huggingface_hub, and the Hugging Face Inference API.