mateoluksenberg commited on
Commit
47616a8
·
verified ·
1 Parent(s): c3179b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -19
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 = format_json_to_text(json_content)
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("Text: ")
 
302
  print(formatted_text)
 
303
  print("---------")
304
 
305
  return PlainTextResponse(formatted_text)
306
 
307
- def format_json_to_text(json_content):
308
- formatted_lines = []
309
- for key, value in json_content.items():
310
- formatted_lines.append(f"{key}: {value}")
311
- return "\n".join(formatted_lines)
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/")