Spaces:
Running
Running
Replace gr.api() (not in installed Gradio) with hidden-button api_name registrations
Browse files- __pycache__/app.cpython-310.pyc +0 -0
- app.py +21 -7
__pycache__/app.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
|
|
|
app.py
CHANGED
|
@@ -1145,13 +1145,27 @@ Chef-facing operators over three sibling ingredient embeddings (Cooc / Core / Ch
|
|
| 1145 |
show_progress="hidden",
|
| 1146 |
)
|
| 1147 |
|
| 1148 |
-
# ---- Public API endpoints ----
|
| 1149 |
-
gr.
|
| 1150 |
-
|
| 1151 |
-
|
| 1152 |
-
|
| 1153 |
-
|
| 1154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1155 |
|
| 1156 |
gr.Markdown(
|
| 1157 |
"""---
|
|
|
|
| 1145 |
show_progress="hidden",
|
| 1146 |
)
|
| 1147 |
|
| 1148 |
+
# ---- Public API endpoints via hidden buttons (gr.api not always available) ----
|
| 1149 |
+
with gr.Group(visible=False):
|
| 1150 |
+
api_in_s1 = gr.Textbox(visible=False)
|
| 1151 |
+
api_in_s2 = gr.Textbox(visible=False)
|
| 1152 |
+
api_in_n = gr.Number(visible=False, value=5)
|
| 1153 |
+
api_in_n2 = gr.Number(visible=False, value=30)
|
| 1154 |
+
api_in_l1 = gr.JSON(visible=False, value=[])
|
| 1155 |
+
api_in_l2 = gr.JSON(visible=False, value=[])
|
| 1156 |
+
api_out = gr.JSON(visible=False)
|
| 1157 |
+
api_btn_neigh = gr.Button(visible=False)
|
| 1158 |
+
api_btn_slerp = gr.Button(visible=False)
|
| 1159 |
+
api_btn_arith = gr.Button(visible=False)
|
| 1160 |
+
api_btn_embed = gr.Button(visible=False)
|
| 1161 |
+
api_btn_dirs = gr.Button(visible=False)
|
| 1162 |
+
api_btn_modes = gr.Button(visible=False)
|
| 1163 |
+
api_btn_neigh.click(api_neighbors, inputs=[api_in_s1, api_in_s2, api_in_n], outputs=api_out, api_name="neighbors")
|
| 1164 |
+
api_btn_slerp.click(api_slerp, inputs=[api_in_s1, api_in_s2, api_in_n2, gr.Textbox(visible=False, value="chem"), api_in_n], outputs=api_out, api_name="slerp")
|
| 1165 |
+
api_btn_arith.click(api_arithmetic, inputs=[api_in_l1, api_in_l2, api_in_s1, api_in_n], outputs=api_out, api_name="arithmetic")
|
| 1166 |
+
api_btn_embed.click(api_embed, inputs=[api_in_s1, api_in_s2], outputs=api_out, api_name="embed")
|
| 1167 |
+
api_btn_dirs.click(api_list_directions, inputs=[api_in_s1], outputs=api_out, api_name="list_directions")
|
| 1168 |
+
api_btn_modes.click(api_list_factor_modes, inputs=[api_in_s1], outputs=api_out, api_name="list_factor_modes")
|
| 1169 |
|
| 1170 |
gr.Markdown(
|
| 1171 |
"""---
|