Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -281,34 +281,24 @@ def simple_chat(message, temperature: float = 0.8, max_length: int = 4096, top_p
|
|
281 |
|
282 |
try:
|
283 |
json_content = json.loads(buffer)
|
284 |
-
formatted_text =
|
285 |
except json.JSONDecodeError:
|
286 |
formatted_text = buffer
|
287 |
|
288 |
-
json_example = {
|
289 |
-
"monto_total": "29.007,97",
|
290 |
-
"iva": "4.510,09",
|
291 |
-
"retenciones": "0,00"
|
292 |
-
}
|
293 |
-
|
294 |
-
ex_formatted_text = format_json_to_text(json_example)
|
295 |
-
print("---------")
|
296 |
-
print("Ejemplo: ")
|
297 |
-
print(ex_formatted_text)
|
298 |
-
print("---------")
|
299 |
-
|
300 |
print("---------")
|
301 |
-
print("
|
|
|
302 |
print(formatted_text)
|
|
|
303 |
print("---------")
|
304 |
|
305 |
return PlainTextResponse(formatted_text)
|
306 |
|
307 |
-
def
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
return
|
312 |
|
313 |
|
314 |
@app.post("/chat/")
|
|
|
281 |
|
282 |
try:
|
283 |
json_content = json.loads(buffer)
|
284 |
+
formatted_text = format_json_to_string(json_content)
|
285 |
except json.JSONDecodeError:
|
286 |
formatted_text = buffer
|
287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
print("---------")
|
289 |
+
print("Respuesta: ")
|
290 |
+
print(" ")
|
291 |
print(formatted_text)
|
292 |
+
print(" ")
|
293 |
print("---------")
|
294 |
|
295 |
return PlainTextResponse(formatted_text)
|
296 |
|
297 |
+
def format_json_to_string(json_content):
|
298 |
+
"""
|
299 |
+
Convierte un diccionario JSON a una cadena JSON sin comillas invertidas.
|
300 |
+
"""
|
301 |
+
return json.dumps(json_content, ensure_ascii=False)
|
302 |
|
303 |
|
304 |
@app.post("/chat/")
|