Spaces:
Runtime error
Runtime error
Patryk Ptasiński commited on
Commit ·
329e33e
1
Parent(s): 4ac731c
Update API documentation with correct endpoints and Python example
Browse files
app.py
CHANGED
|
@@ -30,8 +30,19 @@ with gr.Blocks(title="Nomic Text Embeddings") as app:
|
|
| 30 |
# Add API usage guide
|
| 31 |
gr.Markdown("## API Usage with cURL")
|
| 32 |
gr.Markdown("""
|
| 33 |
-
You can use this API programmatically with cURL. Here
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
```bash
|
| 36 |
curl -X POST https://ipepe-nomic-embeddings.hf.space/run/predict \
|
| 37 |
-H "Content-Type: application/json" \
|
|
@@ -48,7 +59,19 @@ with gr.Blocks(title="Nomic Text Embeddings") as app:
|
|
| 48 |
}
|
| 49 |
```
|
| 50 |
|
| 51 |
-
Replace `https://ipepe-nomic-embeddings.hf.space` with your actual Space URL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
""")
|
| 53 |
|
| 54 |
if __name__ == '__main__':
|
|
|
|
| 30 |
# Add API usage guide
|
| 31 |
gr.Markdown("## API Usage with cURL")
|
| 32 |
gr.Markdown("""
|
| 33 |
+
You can use this API programmatically with cURL. Here are two methods:
|
| 34 |
|
| 35 |
+
### Method 1: Using the Gradio Client API
|
| 36 |
+
```bash
|
| 37 |
+
curl -X POST https://ipepe-nomic-embeddings.hf.space/api/predict \
|
| 38 |
+
-H "Content-Type: application/json" \
|
| 39 |
+
-d '{
|
| 40 |
+
"fn_index": 0,
|
| 41 |
+
"data": ["Your text to embed goes here"]
|
| 42 |
+
}'
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Method 2: Direct API endpoint
|
| 46 |
```bash
|
| 47 |
curl -X POST https://ipepe-nomic-embeddings.hf.space/run/predict \
|
| 48 |
-H "Content-Type: application/json" \
|
|
|
|
| 59 |
}
|
| 60 |
```
|
| 61 |
|
| 62 |
+
Replace `https://ipepe-nomic-embeddings.hf.space` with your actual Space URL if different.
|
| 63 |
+
|
| 64 |
+
### Python Example
|
| 65 |
+
```python
|
| 66 |
+
from gradio_client import Client
|
| 67 |
+
|
| 68 |
+
client = Client("ipepe/nomic-embeddings")
|
| 69 |
+
result = client.predict(
|
| 70 |
+
"Your text to embed goes here",
|
| 71 |
+
api_name="/predict"
|
| 72 |
+
)
|
| 73 |
+
print(result) # Returns the embedding array
|
| 74 |
+
```
|
| 75 |
""")
|
| 76 |
|
| 77 |
if __name__ == '__main__':
|