Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ initialize()
|
|
42 |
|
43 |
def bot_kadi(chat_history):
|
44 |
user_query = chat_history[-1][0]
|
45 |
-
response = kadiAPY_ragchain.process_query(user_query)
|
46 |
chat_history[-1] = (user_query, response)
|
47 |
|
48 |
return chat_history
|
@@ -50,7 +50,7 @@ def bot_kadi(chat_history):
|
|
50 |
|
51 |
import gradio as gr
|
52 |
|
53 |
-
def
|
54 |
|
55 |
chat_history = chat_history + [(user_input, None)]
|
56 |
return chat_history, ""
|
@@ -87,14 +87,14 @@ def main():
|
|
87 |
],
|
88 |
inputs=user_txt,
|
89 |
outputs=chatbot,
|
90 |
-
fn=
|
91 |
label="Try asking...",
|
92 |
cache_examples=False,
|
93 |
examples_per_page=3,
|
94 |
)
|
95 |
|
96 |
# Use the state to persist chat history between interactions
|
97 |
-
submit_btn.click(
|
98 |
.then(bot_kadi, [chat_history], [chatbot])
|
99 |
|
100 |
clear_btn.click(lambda: ([], ""), None, [chat_history, chatbot, user_txt])
|
@@ -103,9 +103,3 @@ def main():
|
|
103 |
|
104 |
if __name__ == "__main__":
|
105 |
main()
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
if __name__ == "__main__":
|
111 |
-
main()
|
|
|
42 |
|
43 |
def bot_kadi(chat_history):
|
44 |
user_query = chat_history[-1][0]
|
45 |
+
response = kadiAPY_ragchain.process_query(user_query, chat_history)
|
46 |
chat_history[-1] = (user_query, response)
|
47 |
|
48 |
return chat_history
|
|
|
50 |
|
51 |
import gradio as gr
|
52 |
|
53 |
+
def add_text_to_chat_history(chat_history, user_input):
|
54 |
|
55 |
chat_history = chat_history + [(user_input, None)]
|
56 |
return chat_history, ""
|
|
|
87 |
],
|
88 |
inputs=user_txt,
|
89 |
outputs=chatbot,
|
90 |
+
fn=add_text_to_chat_history,
|
91 |
label="Try asking...",
|
92 |
cache_examples=False,
|
93 |
examples_per_page=3,
|
94 |
)
|
95 |
|
96 |
# Use the state to persist chat history between interactions
|
97 |
+
submit_btn.click(add_text_to_chat_history, [chat_history, user_txt], [chat_history, user_txt]).then(show_history,[chat_history], [chatbot])\
|
98 |
.then(bot_kadi, [chat_history], [chatbot])
|
99 |
|
100 |
clear_btn.click(lambda: ([], ""), None, [chat_history, chatbot, user_txt])
|
|
|
103 |
|
104 |
if __name__ == "__main__":
|
105 |
main()
|
|
|
|
|
|
|
|
|
|
|
|