Create README.md
Browse files
README.md
CHANGED
@@ -1,10 +1,60 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# OpenRouter Hugging Face Space
|
2 |
+
|
3 |
+
This Hugging Face Space provides a simple interface to interact with various AI models through [OpenRouter](https://openrouter.ai/).
|
4 |
+
|
5 |
+
## Setup Instructions
|
6 |
+
|
7 |
+
### For Hugging Face Spaces
|
8 |
+
|
9 |
+
1. Create a new Space on Hugging Face and choose the "Gradio" app template.
|
10 |
+
2. Upload these files to your Space:
|
11 |
+
- `app.py`
|
12 |
+
- `requirements.txt`
|
13 |
+
|
14 |
+
3. Add your OpenRouter API key as a secret:
|
15 |
+
- Go to your Space settings
|
16 |
+
- Under "Repository secrets", add a new secret with:
|
17 |
+
- Name: `OPENROUTER_API_KEY`
|
18 |
+
- Value: Your actual OpenRouter API key
|
19 |
+
|
20 |
+
4. Wait for your Space to build and deploy!
|
21 |
+
|
22 |
+
### For Local Development
|
23 |
+
|
24 |
+
1. Clone this repository or create these files locally.
|
25 |
+
2. Create a `.env` file from the provided `.env.example`:
|
26 |
+
```
|
27 |
+
cp .env.example .env
|
28 |
+
```
|
29 |
+
3. Edit the `.env` file and add your OpenRouter API key.
|
30 |
+
4. Install dependencies:
|
31 |
+
```
|
32 |
+
pip install -r requirements.txt
|
33 |
+
```
|
34 |
+
5. Run the application:
|
35 |
+
```
|
36 |
+
python app.py
|
37 |
+
```
|
38 |
+
|
39 |
+
## Usage
|
40 |
+
|
41 |
+
Once the app is running:
|
42 |
+
|
43 |
+
1. Select a model from the dropdown menu.
|
44 |
+
2. Customize the system prompt if desired.
|
45 |
+
3. Adjust the temperature value (higher values = more creative, lower = more deterministic).
|
46 |
+
4. Enter your message in the input box.
|
47 |
+
5. Click "Send" to get a response from the selected model.
|
48 |
+
|
49 |
+
## Adding More Models
|
50 |
+
|
51 |
+
To add more models to the list, update the `AVAILABLE_MODELS` list in `app.py` with the model identifiers you want to use from OpenRouter.
|
52 |
+
|
53 |
+
## Troubleshooting
|
54 |
+
|
55 |
+
If you encounter an error like `ModuleNotFoundError: No module named 'openai'`, make sure the Space has finished building and all dependencies are installed correctly.
|
56 |
+
|
57 |
+
For any API errors, check:
|
58 |
+
1. That your API key is correct and has sufficient credits
|
59 |
+
2. That you're using a valid model identifier
|
60 |
+
3. That your requests comply with OpenRouter's usage policies
|