Spaces:
Running
Running
chore: update something
Browse files
lightweight_embeddings/__init__.py
CHANGED
@@ -183,70 +183,71 @@ def create_main_interface():
|
|
183 |
|
184 |
with gr.Blocks(title="Lightweight Embeddings", theme="default") as demo:
|
185 |
gr.Markdown(APP_DESCRIPTION)
|
186 |
-
with gr.
|
187 |
-
with gr.
|
188 |
-
gr.
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
"""
|
215 |
-
|
216 |
-
|
217 |
-
**Generate Embeddings (OpenAI compatible)**
|
218 |
-
```bash
|
219 |
-
curl -X 'POST' \\
|
220 |
-
'https://lamhieu-lightweight-embeddings.hf.space/v1/embeddings' \\
|
221 |
-
-H 'accept: application/json' \\
|
222 |
-
-H 'Content-Type: application/json' \\
|
223 |
-
-d '{
|
224 |
-
"model": "snowflake-arctic-embed-l-v2.0",
|
225 |
-
"input": "That is a happy person"
|
226 |
-
}'
|
227 |
-
```
|
228 |
-
|
229 |
-
**Perform Ranking**
|
230 |
-
```bash
|
231 |
-
curl -X 'POST' \\
|
232 |
-
'https://lamhieu-lightweight-embeddings.hf.space/v1/rank' \\
|
233 |
-
-H 'accept: application/json' \\
|
234 |
-
-H 'Content-Type: application/json' \\
|
235 |
-
-d '{
|
236 |
-
"model": "snowflake-arctic-embed-l-v2.0",
|
237 |
-
"queries": "That is a happy person",
|
238 |
-
"candidates": [
|
239 |
-
"That is a happy dog",
|
240 |
-
"That is a very happy person",
|
241 |
-
"Today is a sunny day"
|
242 |
-
]
|
243 |
-
}'
|
244 |
-
```
|
245 |
-
"""
|
246 |
-
)
|
247 |
|
248 |
# STATS SECTION: display stats in tables
|
249 |
-
with gr.
|
250 |
stats_btn = gr.Button("Get Stats")
|
251 |
access_df = gr.DataFrame(
|
252 |
label="Access Stats",
|
|
|
183 |
|
184 |
with gr.Blocks(title="Lightweight Embeddings", theme="default") as demo:
|
185 |
gr.Markdown(APP_DESCRIPTION)
|
186 |
+
with gr.Tab("Embeddings Playground"):
|
187 |
+
with gr.Row():
|
188 |
+
with gr.Column():
|
189 |
+
gr.Markdown("### 🔬 Try the Embeddings Playground")
|
190 |
+
input_text = gr.Textbox(
|
191 |
+
label="Input Text or Image URL",
|
192 |
+
placeholder="Enter text or an image URL...",
|
193 |
+
lines=3,
|
194 |
+
)
|
195 |
+
model_dropdown = gr.Dropdown(
|
196 |
+
choices=model_options,
|
197 |
+
value=model_options[0],
|
198 |
+
label="Select Model",
|
199 |
+
)
|
200 |
+
generate_btn = gr.Button("Generate Embeddings")
|
201 |
+
output_json = gr.Textbox(
|
202 |
+
label="Embeddings API Response",
|
203 |
+
lines=10,
|
204 |
+
interactive=False,
|
205 |
+
)
|
206 |
+
|
207 |
+
generate_btn.click(
|
208 |
+
fn=call_embeddings_api,
|
209 |
+
inputs=[input_text, model_dropdown],
|
210 |
+
outputs=output_json,
|
211 |
+
)
|
212 |
+
|
213 |
+
with gr.Column():
|
214 |
+
gr.Markdown(
|
215 |
+
"""
|
216 |
+
### 🛠️ cURL Examples
|
217 |
+
|
218 |
+
**Generate Embeddings (OpenAI compatible)**
|
219 |
+
```bash
|
220 |
+
curl -X 'POST' \\
|
221 |
+
'https://lamhieu-lightweight-embeddings.hf.space/v1/embeddings' \\
|
222 |
+
-H 'accept: application/json' \\
|
223 |
+
-H 'Content-Type: application/json' \\
|
224 |
+
-d '{
|
225 |
+
"model": "snowflake-arctic-embed-l-v2.0",
|
226 |
+
"input": "That is a happy person"
|
227 |
+
}'
|
228 |
+
```
|
229 |
+
|
230 |
+
**Perform Ranking**
|
231 |
+
```bash
|
232 |
+
curl -X 'POST' \\
|
233 |
+
'https://lamhieu-lightweight-embeddings.hf.space/v1/rank' \\
|
234 |
+
-H 'accept: application/json' \\
|
235 |
+
-H 'Content-Type: application/json' \\
|
236 |
+
-d '{
|
237 |
+
"model": "snowflake-arctic-embed-l-v2.0",
|
238 |
+
"queries": "That is a happy person",
|
239 |
+
"candidates": [
|
240 |
+
"That is a happy dog",
|
241 |
+
"That is a very happy person",
|
242 |
+
"Today is a sunny day"
|
243 |
+
]
|
244 |
+
}'
|
245 |
+
```
|
246 |
"""
|
247 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
|
249 |
# STATS SECTION: display stats in tables
|
250 |
+
with gr.Tab("Analytics Stats"):
|
251 |
stats_btn = gr.Button("Get Stats")
|
252 |
access_df = gr.DataFrame(
|
253 |
label="Access Stats",
|