bugfix: components
Browse files
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 |
-
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
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", "
|
38 |
-
["acepta mascotas?", "
|
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,
|