Patryk Ptasiński commited on
Commit
4ac731c
·
1 Parent(s): f336786

Fix API endpoint by adding submit button with api_name='predict'

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -19,8 +19,12 @@ with gr.Blocks(title="Nomic Text Embeddings") as app:
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
 
19
 
20
  # Create an output component to display the embedding
21
  output = gr.JSON(label="Text Embedding")
22
+
23
+ # Add a submit button with API name
24
+ submit_btn = gr.Button("Generate Embedding", variant="primary")
25
 
26
+ # Handle both button click and text submission
27
+ submit_btn.click(embed, inputs=text_input, outputs=output, api_name="predict")
28
  text_input.submit(embed, inputs=text_input, outputs=output)
29
 
30
  # Add API usage guide