JuanMa360 commited on
Commit
2561089
1 Parent(s): 4178c7f

refactor: uuid

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -3,6 +3,9 @@ import gradio as gr
3
  import requests
4
  import json
5
 
 
 
 
6
  def slow_api_response(message, history, property_id="c0ced2220b87fc23762facf617157a4f", session_id="12345"):
7
  url = "https://data-monopolio.dev.dd360.mx/ai-assistant/v1"
8
 
@@ -53,15 +56,18 @@ session_id_input = gr.Textbox(
53
  placeholder="Ingresa el ID de tu sesion"
54
  )
55
 
56
- examples = [
57
- ["Hola", "6072ef21835a01fee0f14ace35e5d814", "property_1"],
58
- ["Hola", "db674f4a5bb6b696698f2ab5825d68dd", "property_2"],
59
- ["Hola", "7ba0195e733b613efb3379af7cbd3613", "property_3"]
60
- ]
 
 
61
 
62
  demo = gr.ChatInterface(fn=slow_api_response,
63
  title="AI Assistant",
64
  additional_inputs=[property_id_input, session_id_input],
65
  description="Esta app simula una conversación con un asistente virtual que conoce una propiedad.",
66
- examples=examples
 
67
  ).launch()
 
3
  import requests
4
  import json
5
 
6
+ def generate_session_id():
7
+ return str(uuid.uuid4())
8
+
9
  def slow_api_response(message, history, property_id="c0ced2220b87fc23762facf617157a4f", session_id="12345"):
10
  url = "https://data-monopolio.dev.dd360.mx/ai-assistant/v1"
11
 
 
56
  placeholder="Ingresa el ID de tu sesion"
57
  )
58
 
59
+ def dynamic_examples():
60
+ examples = [
61
+ ["Hola", "6072ef21835a01fee0f14ace35e5d814", generate_session_id()],
62
+ ["Hola", "db674f4a5bb6b696698f2ab5825d68dd", generate_session_id()],
63
+ ["Hola", "7ba0195e733b613efb3379af7cbd3613", generate_session_id()]
64
+ ]
65
+ return examples
66
 
67
  demo = gr.ChatInterface(fn=slow_api_response,
68
  title="AI Assistant",
69
  additional_inputs=[property_id_input, session_id_input],
70
  description="Esta app simula una conversación con un asistente virtual que conoce una propiedad.",
71
+ examples=dynamic_examples(),
72
+ live=True
73
  ).launch()