JuanMa360 commited on
Commit
b06e2c3
1 Parent(s): e0b6915

bugfix: components

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -21,12 +21,16 @@ def slow_api_response(message, history, property_id="c0ced2220b87fc23762facf6171
21
  try:
22
 
23
  response = requests.request("POST", url, headers=headers, data=payload)
24
- api_response = response.text
25
- api_response = api_response.encode().decode('unicode_escape')
26
 
27
- for i in range(len(api_response)):
28
- time.sleep(0.05)
29
- yield api_response[:i + 1]
 
 
 
 
30
 
31
  except requests.RequestException as e:
32
  yield f"Error: {str(e)}"
@@ -34,8 +38,8 @@ def slow_api_response(message, history, property_id="c0ced2220b87fc23762facf6171
34
  property_id_input = gr.Textbox(label="Property ID", placeholder="Ingresa el ID de la propiedad")
35
  examples = [
36
  ["hola", "c0ced2220b87fc23762facf617157a4f"],
37
- ["me gustaria mas informacion de la casa en venta", "d1ab12345b87fc23762facf617159bcd"],
38
- ["acepta mascotas?", "e2xy67890b87fc23762facf617151xyz"]
39
  ]
40
 
41
  demo = gr.ChatInterface(fn=slow_api_response,
 
21
  try:
22
 
23
  response = requests.request("POST", url, headers=headers, data=payload)
24
+ if response.status_code == 500: # Verifica si hay un error interno del servidor
25
+ yield "Error: No existe el ID de la propiedad."
26
 
27
+ else:
28
+ api_response = response.text
29
+ api_response = api_response.encode().decode('unicode_escape')
30
+
31
+ for i in range(len(api_response)):
32
+ time.sleep(0.05)
33
+ yield api_response[:i + 1]
34
 
35
  except requests.RequestException as e:
36
  yield f"Error: {str(e)}"
 
38
  property_id_input = gr.Textbox(label="Property ID", placeholder="Ingresa el ID de la propiedad")
39
  examples = [
40
  ["hola", "c0ced2220b87fc23762facf617157a4f"],
41
+ ["me gustaria mas informacion de la casa en venta", "c0ced2220b87fc23762facf617157a4f"],
42
+ ["acepta mascotas?", "c0ced2220b87fc23762facf617157a4f"]
43
  ]
44
 
45
  demo = gr.ChatInterface(fn=slow_api_response,