fcernafukuzaki commited on
Commit
82dca84
1 Parent(s): 67feeda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -14
app.py CHANGED
@@ -64,7 +64,13 @@ class ChatBotInmobiliaria():
64
  if len(question) == 0:
65
  print("Debe de ingresar una pregunta.")
66
  try:
67
- return self.index.query(question + "\nResponde en español")
 
 
 
 
 
 
68
  except Exception as e:
69
  print(e)
70
  return "Hubo un error."
@@ -94,18 +100,45 @@ def chat(pregunta):
94
  time.sleep(1)
95
  return chat_history
96
 
97
- in1 = gr.inputs.Textbox(label="Pregunta")
98
- out1 = gr.outputs.Chatbot(label="Respuesta").style(height=350)
99
-
100
- demo = gr.Interface(
101
- fn=chat,
102
- inputs=in1,
103
- outputs=out1,
104
- title="Demo Inmobiliaria",
105
- description=description,
106
- article=article,
107
- enable_queue=True,
108
- examples=examples,
109
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
  demo.launch(debug=True)
 
64
  if len(question) == 0:
65
  print("Debe de ingresar una pregunta.")
66
  try:
67
+ return self.index.query(f"""
68
+ Actúa como un representante de ventas de una inmobiliaria.
69
+
70
+ {question}
71
+
72
+ Responde en español
73
+ """)
74
  except Exception as e:
75
  print(e)
76
  return "Hubo un error."
 
100
  time.sleep(1)
101
  return chat_history
102
 
103
+ def new_chat():
104
+ chat_history = []
105
+
106
+ with gr.Blocks() as demo:
107
+ gr.Markdown(
108
+ f"""<p><center><h1>Demo Inmobiliaria</h1></p></center>
109
+ {description}
110
+ """)
111
+
112
+
113
+ out1 = gr.Chatbot(label="Respuesta").style(height=350)
114
+ in2 = gr.Textbox(label="Pregunta")
115
+
116
+ clear = gr.Button("Nuevo chat")
117
+ clear.click(fn=new_chat, inputs=None, outputs=None)
118
+
119
+ gr.Markdown(article)
120
+
121
+ def respond(message, chat_history):
122
+ bot_message = str(gpt_bot.ask(question=message))
123
+ chat_history.append((message, bot_message))
124
+ time.sleep(1)
125
+ return "", chat_history
126
+
127
+ in2.submit(respond, [in2, out1], [in2, out1])
128
+ clear.click(lambda: None, None, out1, queue=False)
129
+
130
+ # in1 = gr.inputs.Textbox(label="Pregunta")
131
+ # out1 = gr.outputs.Chatbot(label="Respuesta").style(height=350)
132
+
133
+ # demo = gr.Interface(
134
+ # fn=chat,
135
+ # inputs=in1,
136
+ # outputs=out1,
137
+ # title="Demo Inmobiliaria",
138
+ # description=description,
139
+ # article=article,
140
+ # enable_queue=True,
141
+ # examples=examples,
142
+ # )
143
 
144
  demo.launch(debug=True)