Spaces:
Running
Running
Patryk Ptasiński
commited on
Commit
·
f336786
1
Parent(s):
bb5fa37
Add cURL usage guide to Gradio interface
Browse files
app.py
CHANGED
|
@@ -10,15 +10,42 @@ def embed(document: str):
|
|
| 10 |
return model.encode(document)
|
| 11 |
|
| 12 |
|
| 13 |
-
with gr.Blocks() as app:
|
|
|
|
|
|
|
|
|
|
| 14 |
# Create an input text box
|
| 15 |
-
text_input = gr.Textbox(label="Enter text to embed")
|
| 16 |
|
| 17 |
# Create an output component to display the embedding
|
| 18 |
output = gr.JSON(label="Text Embedding")
|
| 19 |
|
| 20 |
# When the input text is submitted, call the embedding function and display the output
|
| 21 |
text_input.submit(embed, inputs=text_input, outputs=output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
if __name__ == '__main__':
|
| 24 |
app.queue().launch(server_name="0.0.0.0", show_error=True, server_port=7860)
|
|
|
|
| 10 |
return model.encode(document)
|
| 11 |
|
| 12 |
|
| 13 |
+
with gr.Blocks(title="Nomic Text Embeddings") as app:
|
| 14 |
+
gr.Markdown("# Nomic Text Embeddings v1.5")
|
| 15 |
+
gr.Markdown("Generate embeddings for your text using the nomic-embed-text-v1.5 model.")
|
| 16 |
+
|
| 17 |
# Create an input text box
|
| 18 |
+
text_input = gr.Textbox(label="Enter text to embed", placeholder="Type or paste your text here...")
|
| 19 |
|
| 20 |
# Create an output component to display the embedding
|
| 21 |
output = gr.JSON(label="Text Embedding")
|
| 22 |
|
| 23 |
# When the input text is submitted, call the embedding function and display the output
|
| 24 |
text_input.submit(embed, inputs=text_input, outputs=output)
|
| 25 |
+
|
| 26 |
+
# Add API usage guide
|
| 27 |
+
gr.Markdown("## API Usage with cURL")
|
| 28 |
+
gr.Markdown("""
|
| 29 |
+
You can use this API programmatically with cURL. Here's how:
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
curl -X POST https://ipepe-nomic-embeddings.hf.space/run/predict \
|
| 33 |
+
-H "Content-Type: application/json" \
|
| 34 |
+
-d '{
|
| 35 |
+
"data": ["Your text to embed goes here"]
|
| 36 |
+
}'
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
The response will be in JSON format:
|
| 40 |
+
```json
|
| 41 |
+
{
|
| 42 |
+
"data": [[0.123, -0.456, 0.789, ...]],
|
| 43 |
+
"duration": 0.123
|
| 44 |
+
}
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
Replace `https://ipepe-nomic-embeddings.hf.space` with your actual Space URL.
|
| 48 |
+
""")
|
| 49 |
|
| 50 |
if __name__ == '__main__':
|
| 51 |
app.queue().launch(server_name="0.0.0.0", show_error=True, server_port=7860)
|