DIRECT CONTENT API: Return just the generated content, no API wrappers or tuples - perfect for client parsing
Browse files- gradio_app.py +9 -9
gradio_app.py
CHANGED
|
@@ -179,15 +179,15 @@ def api_respond(message, history, temperature, json_mode=None, template=None):
|
|
| 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
|
| 183 |
try:
|
| 184 |
-
#
|
| 185 |
-
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
| 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}", ""
|
|
@@ -205,8 +205,8 @@ demo = gr.Interface(
|
|
| 205 |
gr.Textbox(label="API Response", lines=10), # Simple text output
|
| 206 |
gr.Textbox(label="Status", visible=False)
|
| 207 |
],
|
| 208 |
-
title="🚀 Question Generation API -
|
| 209 |
-
description="
|
| 210 |
api_name="respond"
|
| 211 |
)
|
| 212 |
|
|
|
|
| 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 - returns JUST the content for easy client parsing"""
|
| 183 |
try:
|
| 184 |
+
# Generate the response directly
|
| 185 |
+
response_content = generate_response(message, temperature)
|
| 186 |
+
|
| 187 |
+
# Return JUST the content - no API wrapper, no tuples, just the actual response
|
| 188 |
+
logger.info(f"Returning direct content: {len(response_content)} chars")
|
| 189 |
+
return response_content, ""
|
| 190 |
|
|
|
|
|
|
|
|
|
|
| 191 |
except Exception as e:
|
| 192 |
logger.error(f"Simple API Error: {e}")
|
| 193 |
return f"Error: {e}", ""
|
|
|
|
| 205 |
gr.Textbox(label="API Response", lines=10), # Simple text output
|
| 206 |
gr.Textbox(label="Status", visible=False)
|
| 207 |
],
|
| 208 |
+
title="🚀 Question Generation API - DIRECT CONTENT",
|
| 209 |
+
description="Returns content directly - no wrappers, no complications. Perfect for client integration.",
|
| 210 |
api_name="respond"
|
| 211 |
)
|
| 212 |
|