Perplexity AI Query Interface is a quite simple Python Flask web application that lets you interact with the Perplexity AI API in a user-friendly way. The app is designed to be simple, modular, and efficient.
-
Query the Perplexity AI API:
- Send customizable user and system prompts.
- (Optional) Append uploaded
.txt
file content to the query.
-
File Upload:
- Upload
.txt
files and combine their content with your query prompt.
- Upload
-
Save API Responses:
- Automatically save the API response as a
.json
file with a timestamped filename (e.g.,query_result_yy-dd-mm-hh-mm.json
).
- Automatically save the API response as a
-
Display Results:
- View formatted query results in a table for easy readability.
- Access the raw JSON response for advanced debugging or sharing.
-
Dark-Themed Interface:
- Sleek, modern design with a dark color palette.
-
Results in a New Tab:
- Query results are displayed in a separate browser tab.
-
Copy JSON Results:
- A "Copy" button allows you to quickly copy the raw JSON output.
-
Error Handling:
- (Hopefully) gracefully handles missing inputs and file upload errors.
- Logs server-side issues to
app.log
for easy debugging.
-
Modular Code:
- Clean structure with helper functions and well-organized routes.
-
Install Dependencies Make sure you have Python installed (version 3.7+ recommended). Install required packages: pip install flask requests python-magic
-
Set Up Your API Key Create a .env file in the project root and add your Perplexity AI API key: PERPLEXITYAI_API_KEY=your_api_key_here
-
Run the Application
python app.py Open your browser and navigate to http://127.0.0.1:5000/.
Enter a system prompt and user prompt on the home page. (Optional) Upload a .txt file to append its content to your query. Submit the query to get: A formatted view of key results. The raw JSON output. Save the JSON file locally for further use.
Contributions are always welcome! Feel free to fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you'd like to change.
This project is licensed under the MIT License. See the LICENSE file for details.
Thanks to Perplexity AI for the nice API ;) Built with 🐍 Python and ❤️ Flask.