Create README.md
Browse filesOpenRouter Hugging Face Space
This Hugging Face Space allows you to interact with various AI models via OpenRouter.
Setup Instructions
For Hugging Face Spaces
1. Create a new Space:
Go to Hugging Face Spaces and create a new Space.
Choose the "Gradio" app template.
2. Upload files:
Upload the following files to your Space:
app.py
requirements.txt
3. Add your OpenRouter API key as a secret:
Go to your Space settings.
Under Repository secrets, click Add secret:
Name: OPENROUTER_API_KEY
Value: Your actual OpenRouter API key.
4. Deploy your Space:
Wait for the Space to build and deploy automatically.
---
For Local Development
1. Clone the repository (or create these files locally):
Clone this repository or manually create the necessary files on your machine.
2. Create a .env file:
Run the following command to create the .env file:
cp .env.example .env
Open the .env file and add your OpenRouter API key.
3. Install dependencies:
Install the required Python libraries:
pip install -r requirements.txt
4. Run the application:
Run the app locally using the following command:
python app.py
---
Usage
Once the app is running:
1. Select a model:
Use the dropdown menu to choose a model.
2. Customize the system prompt (optional):
Modify the system prompt if desired.
3. Adjust the temperature:
Temperature controls the creativity of the model. Higher values (e.g., 0.8) make the output more creative, while lower values (e.g., 0.2) make it more deterministic.
4. Send a message:
Enter your input in the text box and click "Send" to get a response from the selected model.
---
Adding More Models
To add additional models to the list:
1. Update the AVAILABLE_MODELS list in app.py with the model identifiers you want to use from OpenRouter.
---
Troubleshooting
If you encounter errors, check the following:
1. ModuleNotFoundError:
If you see errors like ModuleNotFoundError: No module named 'openai', ensure the Space has finished building and that all dependencies are installed correctly.
2. API Errors:
Ensure your OpenRouter API key is correct and has sufficient credits.
Make sure you're using a valid model identifier.
Verify that your requests comply with OpenRouter's usage policies.
---
Feel free to customize or extend the app as needed! If you have any issues or need assistance, feel free to open an issue in the repository.
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
title: Openrouter Huggingface Space
|
4 |
+
sdk: gradio
|
5 |
+
emoji: 🌍
|
6 |
+
colorFrom: purple
|
7 |
+
colorTo: yellow
|
8 |
+
pinned: true
|
9 |
+
thumbnail: >-
|
10 |
+
https://cdn-uploads.huggingface.co/production/uploads/67a5180b9213931bd7efb6e8/LRO6Qzx-Mi7gpmCh7iYxd.png
|
11 |
+
---
|