lamhieu commited on
Commit
0176b09
·
1 Parent(s): 8784815

chore: update something

Browse files
Files changed (1) hide show
  1. lightweight_embeddings/__init__.py +62 -61
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.Row():
187
- with gr.Column():
188
- gr.Markdown("### 🔬 Try the Embeddings Playground")
189
- input_text = gr.Textbox(
190
- label="Input Text or Image URL",
191
- placeholder="Enter text or an image URL...",
192
- lines=3,
193
- )
194
- model_dropdown = gr.Dropdown(
195
- choices=model_options,
196
- value=model_options[0],
197
- label="Select Model",
198
- )
199
- generate_btn = gr.Button("Generate Embeddings")
200
- output_json = gr.Textbox(
201
- label="Embeddings API Response",
202
- lines=10,
203
- interactive=False,
204
- )
205
-
206
- generate_btn.click(
207
- fn=call_embeddings_api,
208
- inputs=[input_text, model_dropdown],
209
- outputs=output_json,
210
- )
211
-
212
- with gr.Column():
213
- gr.Markdown(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  """
215
- ### 🛠️ cURL Examples
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.Accordion("Analytics Stats"):
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",