Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,14 +13,13 @@ def generate_json(prompt):
|
|
13 |
generated_text = result[0]["generated_text"]
|
14 |
|
15 |
try:
|
16 |
-
parsed =
|
17 |
formatted_json = json.dumps(parsed, indent=2)
|
18 |
except Exception as e:
|
19 |
formatted_json = f"Raw Output:\n{generated_text}\n\nError parsing JSON: {e}"
|
20 |
|
21 |
return formatted_json
|
22 |
|
23 |
-
# π₯ Make sure to assign to a variable
|
24 |
demo = gr.Interface(
|
25 |
fn=generate_json,
|
26 |
inputs=gr.Textbox(lines=4, label="Enter Prompt"),
|
@@ -29,6 +28,5 @@ demo = gr.Interface(
|
|
29 |
description="Enter a prompt describing the structure or content you want in JSON format."
|
30 |
)
|
31 |
|
32 |
-
# π This is what allows external API calls
|
33 |
demo.queue()
|
34 |
demo.launch(show_error=True)
|
|
|
13 |
generated_text = result[0]["generated_text"]
|
14 |
|
15 |
try:
|
16 |
+
parsed = json.loads(generated_text)
|
17 |
formatted_json = json.dumps(parsed, indent=2)
|
18 |
except Exception as e:
|
19 |
formatted_json = f"Raw Output:\n{generated_text}\n\nError parsing JSON: {e}"
|
20 |
|
21 |
return formatted_json
|
22 |
|
|
|
23 |
demo = gr.Interface(
|
24 |
fn=generate_json,
|
25 |
inputs=gr.Textbox(lines=4, label="Enter Prompt"),
|
|
|
28 |
description="Enter a prompt describing the structure or content you want in JSON format."
|
29 |
)
|
30 |
|
|
|
31 |
demo.queue()
|
32 |
demo.launch(show_error=True)
|