refactor: uuid
Browse files
app.py
CHANGED
@@ -7,9 +7,6 @@ import uuid
|
|
7 |
def generate_session_id():
|
8 |
return str(uuid.uuid4())
|
9 |
|
10 |
-
def start_new_conversation():
|
11 |
-
return None, "", "", generate_session_id()
|
12 |
-
|
13 |
def slow_api_response(message, history, property_id="c0ced2220b87fc23762facf617157a4f", session_id="12345"):
|
14 |
url = "https://data-monopolio.dev.dd360.mx/ai-assistant/v1"
|
15 |
|
@@ -60,23 +57,17 @@ session_id_input = gr.Textbox(
|
|
60 |
placeholder="Ingresa el ID de tu sesion"
|
61 |
)
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
examples = [
|
67 |
["Hola", "6072ef21835a01fee0f14ace35e5d814", generate_session_id()],
|
68 |
["Hola", "db674f4a5bb6b696698f2ab5825d68dd", generate_session_id()],
|
69 |
["Hola", "7ba0195e733b613efb3379af7cbd3613", generate_session_id()]
|
70 |
-
]
|
|
|
71 |
|
72 |
demo = gr.ChatInterface(fn=slow_api_response,
|
73 |
title="AI Assistant",
|
74 |
additional_inputs=[property_id_input, session_id_input],
|
75 |
description="Esta app simula una conversación con un asistente virtual que conoce una propiedad.",
|
76 |
-
examples=
|
77 |
-
)
|
78 |
-
|
79 |
-
demo.add_component(new_conversation_button)
|
80 |
-
new_conversation_button.click(start_new_conversation, inputs=[], outputs=[demo, property_id_input, session_id_input])
|
81 |
-
|
82 |
-
demo.launch()
|
|
|
7 |
def generate_session_id():
|
8 |
return str(uuid.uuid4())
|
9 |
|
|
|
|
|
|
|
10 |
def slow_api_response(message, history, property_id="c0ced2220b87fc23762facf617157a4f", session_id="12345"):
|
11 |
url = "https://data-monopolio.dev.dd360.mx/ai-assistant/v1"
|
12 |
|
|
|
57 |
placeholder="Ingresa el ID de tu sesion"
|
58 |
)
|
59 |
|
60 |
+
def dynamic_examples():
|
61 |
+
examples = [
|
|
|
|
|
62 |
["Hola", "6072ef21835a01fee0f14ace35e5d814", generate_session_id()],
|
63 |
["Hola", "db674f4a5bb6b696698f2ab5825d68dd", generate_session_id()],
|
64 |
["Hola", "7ba0195e733b613efb3379af7cbd3613", generate_session_id()]
|
65 |
+
]
|
66 |
+
return examples
|
67 |
|
68 |
demo = gr.ChatInterface(fn=slow_api_response,
|
69 |
title="AI Assistant",
|
70 |
additional_inputs=[property_id_input, session_id_input],
|
71 |
description="Esta app simula una conversación con un asistente virtual que conoce una propiedad.",
|
72 |
+
examples=dynamic_examples()
|
73 |
+
).launch()
|
|
|
|
|
|
|
|
|
|