bugfix: format
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ def slow_api_response(message, history):
|
|
11 |
payload = json.dumps({
|
12 |
"query": message,
|
13 |
"sessionId": "12345",
|
14 |
-
"numMessages": "3",
|
15 |
"userId": "user-01",
|
16 |
"property_id": "c0ced2220b87fc23762facf617157a4f"
|
17 |
})
|
@@ -21,23 +21,23 @@ def slow_api_response(message, history):
|
|
21 |
}
|
22 |
|
23 |
try:
|
24 |
-
|
25 |
response = requests.request("POST", url, headers=headers, data=payload)
|
26 |
api_response = response.text
|
27 |
api_response = api_response.encode().decode('unicode_escape')
|
28 |
|
29 |
-
# Simula una respuesta progresiva
|
30 |
for i in range(len(api_response)):
|
31 |
-
time.sleep(0.05)
|
32 |
-
yield api_response[:i + 1]
|
33 |
|
34 |
except requests.RequestException as e:
|
35 |
yield f"Error: {str(e)}"
|
36 |
|
37 |
-
|
38 |
demo = gr.ChatInterface(fn=slow_api_response,
|
39 |
-
title="AI Assistant",
|
40 |
description="Esta app simula una conversación con un asistente virtual que conoce una propiedad.",
|
41 |
-
|
|
|
42 |
|
43 |
|
|
|
11 |
payload = json.dumps({
|
12 |
"query": message,
|
13 |
"sessionId": "12345",
|
14 |
+
"numMessages": "3",
|
15 |
"userId": "user-01",
|
16 |
"property_id": "c0ced2220b87fc23762facf617157a4f"
|
17 |
})
|
|
|
21 |
}
|
22 |
|
23 |
try:
|
24 |
+
|
25 |
response = requests.request("POST", url, headers=headers, data=payload)
|
26 |
api_response = response.text
|
27 |
api_response = api_response.encode().decode('unicode_escape')
|
28 |
|
|
|
29 |
for i in range(len(api_response)):
|
30 |
+
time.sleep(0.05)
|
31 |
+
yield api_response[:i + 1]
|
32 |
|
33 |
except requests.RequestException as e:
|
34 |
yield f"Error: {str(e)}"
|
35 |
|
36 |
+
|
37 |
demo = gr.ChatInterface(fn=slow_api_response,
|
38 |
+
title="AI Assistant",
|
39 |
description="Esta app simula una conversación con un asistente virtual que conoce una propiedad.",
|
40 |
+
examples=[{"text": "hello"}, {"text": "me gustaria mas informacion de la casa en venta"}, {"text": "acepta mascotas?"}]
|
41 |
+
).launch()
|
42 |
|
43 |
|