Installation
Install dependencies
Install the required Python packages:Required dependencies:
gradio- Web interface frameworkpandas- Data manipulationnumpy- Numerical computingmistralai- Mistral AI API clientopenai- OpenAI API clientpydantic- Data validationpython-dotenv- Environment variable management
Configure API keys
Set up your API keys using one of these methods:Option 1: Environment variablesExport the keys in your terminal:Option 2: .env fileCreate a
.env file in the project root:Local storage configuration
When running locally, the application stores data differently than in Hugging Face Spaces:Primary storage location
By default, the application attempts to use a/data directory (pas2.py:384):
Fallback storage
If/data is not accessible (common on local systems), the application automatically falls back to a temporary directory (pas2.py:423-427):
temp_data directory in your project folder to store the SQLite database.
The feedback database persists between runs as long as the
temp_data directory remains intact. You can safely delete this directory to reset all stored feedback and statistics.Database schema
The SQLite database automatically initializes with the following schema (pas2.py:401-416):Model configuration
The application uses the following AI models (pas2.py:57-58):- Response generation:
mistral-large-latest(Mistral AI) - Hallucination judgment:
o3-mini(OpenAI)
Development mode
For development, you can customize the Gradio interface settings:Library usage
You can also use PAS2 as a Python library without the web interface:Performance considerations
API rate limits
Be aware of rate limits for both APIs:- Monitor your API usage in the respective dashboards
- Reduce
n_paraphrasesparameter to minimize API calls - Implement delays between requests if needed
Parallel processing
The application uses parallel API calls for efficiency (pas2.py:180):max_workers if you experience rate limiting.
Logging configuration
The application logs all operations at INFO level (pas2.py:20-26). To adjust logging:Troubleshooting
Module not found errors
If you encounter import errors:API authentication failures
Verify your API keys are set correctly:Database locked errors
If SQLite reports database locks:- Ensure only one instance of the application is running
- Check file permissions on the
temp_datadirectory - Delete
temp_data/feedback.dband restart
Port already in use
If port 7860 is already in use:Security best practices
Sharing your local instance
Gradio allows temporary public sharing:- Quick demos
- User testing
- Temporary collaboration
For permanent public deployment, use Hugging Face Spaces instead of local sharing.