Spaces:
Sleeping
Sleeping
ULTRA SIMPLE FIX: Remove ALL JSON components, use only Textbox inputs/outputs, no state anywhere
Browse files- gradio_app.py +23 -9
gradio_app.py
CHANGED
|
@@ -177,22 +177,36 @@ def api_respond(message, history, temperature, json_mode=None, template=None):
|
|
| 177 |
{"role": "assistant", "metadata": None, "content": f"Error: {e}", "options": None}
|
| 178 |
], ""]
|
| 179 |
|
| 180 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
demo = gr.Interface(
|
| 182 |
-
fn=
|
| 183 |
inputs=[
|
| 184 |
gr.Textbox(label="Message", lines=5, placeholder="Enter your prompt here..."),
|
| 185 |
-
gr.
|
| 186 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.8, step=0.1, label="Temperature"),
|
| 187 |
-
gr.Textbox(label="JSON Mode", value="", visible=False),
|
| 188 |
-
gr.Textbox(label="Template", value="", visible=False)
|
| 189 |
],
|
| 190 |
outputs=[
|
| 191 |
-
gr.
|
| 192 |
-
gr.Textbox(label="Status", visible=False)
|
| 193 |
],
|
| 194 |
-
title="🚀 Question Generation API -
|
| 195 |
-
description="
|
| 196 |
api_name="respond"
|
| 197 |
)
|
| 198 |
|
|
|
|
| 177 |
{"role": "assistant", "metadata": None, "content": f"Error: {e}", "options": None}
|
| 178 |
], ""]
|
| 179 |
|
| 180 |
+
# ABSOLUTE SIMPLEST INTERFACE - NO JSON, NO STATE, NOTHING FANCY
|
| 181 |
+
def simple_api(message, history_str, temperature, json_mode, template):
|
| 182 |
+
"""Ultra-simple wrapper that converts string history to list"""
|
| 183 |
+
try:
|
| 184 |
+
# Convert string history to empty list (Gradio compatibility)
|
| 185 |
+
history = []
|
| 186 |
+
result = api_respond(message, history, temperature, json_mode, template)
|
| 187 |
+
|
| 188 |
+
# Convert the result to string format for simple text output
|
| 189 |
+
import json
|
| 190 |
+
return json.dumps(result[0], indent=2), result[1]
|
| 191 |
+
except Exception as e:
|
| 192 |
+
logger.error(f"Simple API Error: {e}")
|
| 193 |
+
return f"Error: {e}", ""
|
| 194 |
+
|
| 195 |
demo = gr.Interface(
|
| 196 |
+
fn=simple_api,
|
| 197 |
inputs=[
|
| 198 |
gr.Textbox(label="Message", lines=5, placeholder="Enter your prompt here..."),
|
| 199 |
+
gr.Textbox(label="History", value="[]", visible=False), # String, not JSON
|
| 200 |
gr.Slider(minimum=0.1, maximum=1.0, value=0.8, step=0.1, label="Temperature"),
|
| 201 |
+
gr.Textbox(label="JSON Mode", value="", visible=False),
|
| 202 |
+
gr.Textbox(label="Template", value="", visible=False)
|
| 203 |
],
|
| 204 |
outputs=[
|
| 205 |
+
gr.Textbox(label="API Response", lines=10), # Simple text output
|
| 206 |
+
gr.Textbox(label="Status", visible=False)
|
| 207 |
],
|
| 208 |
+
title="🚀 Question Generation API - ULTRA SIMPLE",
|
| 209 |
+
description="The simplest possible API interface. Just works.",
|
| 210 |
api_name="respond"
|
| 211 |
)
|
| 212 |
|