Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -277,7 +277,15 @@ def simple_chat(message, temperature: float = 0.8, max_length: int = 4096, top_p
|
|
| 277 |
print(buffer)
|
| 278 |
print("---------")
|
| 279 |
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
|
| 283 |
|
|
|
|
| 277 |
print(buffer)
|
| 278 |
print("---------")
|
| 279 |
|
| 280 |
+
# If the generated text is JSON, parse it and format it as plain text
|
| 281 |
+
try:
|
| 282 |
+
json_content = json.loads(buffer)
|
| 283 |
+
formatted_text = "\n".join(f"{key}: {value}" for key, value in json_content.items())
|
| 284 |
+
except json.JSONDecodeError:
|
| 285 |
+
# If the buffer is not valid JSON, return it as is
|
| 286 |
+
formatted_text = buffer
|
| 287 |
+
|
| 288 |
+
return PlainTextResponse(formatted_text)
|
| 289 |
|
| 290 |
|
| 291 |
|