Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
Hugging Face Spaces - OpenAI Compatible Embedding API (API-Only)
|
| 4 |
================================================================
|
| 5 |
|
| 6 |
Deploy your EdgeHomes ModernBERT model as an OpenAI-compatible API on HF Spaces.
|
| 7 |
Pure API endpoint - no UI components.
|
| 8 |
|
| 9 |
-
API URL: https://
|
| 10 |
"""
|
| 11 |
|
| 12 |
import gradio as gr
|
|
@@ -19,7 +19,7 @@ import time
|
|
| 19 |
import os
|
| 20 |
|
| 21 |
# DEBUGGING: Print to confirm this file is being used
|
| 22 |
-
print("🚨
|
| 23 |
|
| 24 |
from transformers import AutoTokenizer, AutoModel
|
| 25 |
import torch
|
|
@@ -180,16 +180,18 @@ with gr.Blocks(title="EdgeHomes Embedding API") as demo:
|
|
| 180 |
POST /api/v1/embeddings
|
| 181 |
```
|
| 182 |
|
| 183 |
-
## Usage
|
| 184 |
```typescript
|
| 185 |
-
const
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
| 193 |
});
|
| 194 |
```
|
| 195 |
|
|
@@ -202,4 +204,4 @@ app = gr.mount_gradio_app(app, demo, path="/")
|
|
| 202 |
|
| 203 |
if __name__ == "__main__":
|
| 204 |
import uvicorn
|
| 205 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Hugging Face Spaces - OpenAI Compatible Embedding API (API-Only)
|
| 4 |
================================================================
|
| 5 |
|
| 6 |
Deploy your EdgeHomes ModernBERT model as an OpenAI-compatible API on HF Spaces.
|
| 7 |
Pure API endpoint - no UI components.
|
| 8 |
|
| 9 |
+
API URL: https://builtbyhq-edgehomes-embedding.hf.space/api/v1/embeddings
|
| 10 |
"""
|
| 11 |
|
| 12 |
import gradio as gr
|
|
|
|
| 19 |
import os
|
| 20 |
|
| 21 |
# DEBUGGING: Print to confirm this file is being used
|
| 22 |
+
print("🚨 STARTING EDGEHOMES EMBEDDING API 🚨")
|
| 23 |
|
| 24 |
from transformers import AutoTokenizer, AutoModel
|
| 25 |
import torch
|
|
|
|
| 180 |
POST /api/v1/embeddings
|
| 181 |
```
|
| 182 |
|
| 183 |
+
## Usage Example
|
| 184 |
```typescript
|
| 185 |
+
const response = await fetch('https://builtbyhq-edgehomes-embedding.hf.space/api/v1/embeddings', {
|
| 186 |
+
method: 'POST',
|
| 187 |
+
headers: {
|
| 188 |
+
'Content-Type': 'application/json',
|
| 189 |
+
'Authorization': 'Bearer your-secret-token'
|
| 190 |
+
},
|
| 191 |
+
body: JSON.stringify({
|
| 192 |
+
input: "Your text here",
|
| 193 |
+
model: "edgehomes-modernbert-v1"
|
| 194 |
+
})
|
| 195 |
});
|
| 196 |
```
|
| 197 |
|
|
|
|
| 204 |
|
| 205 |
if __name__ == "__main__":
|
| 206 |
import uvicorn
|
| 207 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|