Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ openai.api_key = os.environ['OPENAI_API_KEY']
|
|
| 18 |
def clear_chat(message, chat_history):
|
| 19 |
return "", []
|
| 20 |
|
| 21 |
-
def add_new_message(message,
|
| 22 |
new_chat = []
|
| 23 |
|
| 24 |
new_chat.append({"role": "system", "content": """
|
|
@@ -298,7 +298,6 @@ def add_new_message(message,person, chat_history):
|
|
| 298 |
VC-MP: Videoconferencia MultiPunto.
|
| 299 |
|
| 300 |
--
|
| 301 |
-
{}
|
| 302 |
|
| 303 |
You are an assistant that should behave based on the above description for a "CEI Virtual assistant".
|
| 304 |
You have to initiate the conversation with the RT (remote teacher) with the following message:
|
|
@@ -306,7 +305,7 @@ def add_new_message(message,person, chat_history):
|
|
| 306 |
How can I help you today?"
|
| 307 |
Be polite and only answer questions related to the topics included in the frequently answer questions provided above.
|
| 308 |
If you receive questions about topics not included above just respond "Sorry, I am not able to help you with that. Please contact you Institute Coordinator for more information. Is there anything else I can do for you?"
|
| 309 |
-
"""
|
| 310 |
|
| 311 |
for turn in chat_history:
|
| 312 |
user, bot = turn
|
|
@@ -317,8 +316,8 @@ def add_new_message(message,person, chat_history):
|
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
-
def respond(message,
|
| 321 |
-
prompt = add_new_message(message,
|
| 322 |
# stream = client.generate_stream(prompt,
|
| 323 |
# max_new_tokens=1024,
|
| 324 |
# stop_sequences=["\nUser:", "<|endoftext|>"],
|
|
@@ -368,8 +367,6 @@ with gr.Blocks() as demo:
|
|
| 368 |
</h3>
|
| 369 |
</center>
|
| 370 |
""".format(encoded_image))
|
| 371 |
-
with gr.Row():
|
| 372 |
-
person = gr.Textbox(label="Input option:")
|
| 373 |
with gr.Row():
|
| 374 |
chatbot = gr.Chatbot( height=550) #just to fit the notebook
|
| 375 |
with gr.Row():
|
|
@@ -383,8 +380,8 @@ with gr.Blocks() as demo:
|
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
-
btn.click(respond, inputs=[msg,
|
| 387 |
-
msg.submit(respond, inputs=[msg,
|
| 388 |
clear.click(clear_chat,inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 389 |
demo.queue()
|
| 390 |
demo.launch()
|
|
|
|
| 18 |
def clear_chat(message, chat_history):
|
| 19 |
return "", []
|
| 20 |
|
| 21 |
+
def add_new_message(message, chat_history):
|
| 22 |
new_chat = []
|
| 23 |
|
| 24 |
new_chat.append({"role": "system", "content": """
|
|
|
|
| 298 |
VC-MP: Videoconferencia MultiPunto.
|
| 299 |
|
| 300 |
--
|
|
|
|
| 301 |
|
| 302 |
You are an assistant that should behave based on the above description for a "CEI Virtual assistant".
|
| 303 |
You have to initiate the conversation with the RT (remote teacher) with the following message:
|
|
|
|
| 305 |
How can I help you today?"
|
| 306 |
Be polite and only answer questions related to the topics included in the frequently answer questions provided above.
|
| 307 |
If you receive questions about topics not included above just respond "Sorry, I am not able to help you with that. Please contact you Institute Coordinator for more information. Is there anything else I can do for you?"
|
| 308 |
+
"""})
|
| 309 |
|
| 310 |
for turn in chat_history:
|
| 311 |
user, bot = turn
|
|
|
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
+
def respond(message, chat_history):
|
| 320 |
+
prompt = add_new_message(message, chat_history)
|
| 321 |
# stream = client.generate_stream(prompt,
|
| 322 |
# max_new_tokens=1024,
|
| 323 |
# stop_sequences=["\nUser:", "<|endoftext|>"],
|
|
|
|
| 367 |
</h3>
|
| 368 |
</center>
|
| 369 |
""".format(encoded_image))
|
|
|
|
|
|
|
| 370 |
with gr.Row():
|
| 371 |
chatbot = gr.Chatbot( height=550) #just to fit the notebook
|
| 372 |
with gr.Row():
|
|
|
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
+
btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 384 |
+
msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) #Press enter to submit
|
| 385 |
clear.click(clear_chat,inputs=[msg, chatbot], outputs=[msg, chatbot])
|
| 386 |
demo.queue()
|
| 387 |
demo.launch()
|