thinh111 commited on
Commit
ca35fda
Β·
verified Β·
1 Parent(s): 5d9a876

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -41
app.py CHANGED
@@ -1,42 +1,41 @@
1
- import subprocess
2
- import sys
3
- import gradio as gr
4
- from utils import initialize_database
5
- from model import llm_chain_response, get_response_value
6
- from process_documents import create_db_from_files
7
-
8
- def run_setup():
9
- subprocess.check_call([sys.executable, "setup.py"])
10
-
11
- # Run the setup script
12
- run_setup()
13
- llm_chain = llm_chain_response()
14
-
15
- def chat_with_mistral(user_input):
16
- if not user_input:
17
- return "The message is not be empty."
18
- response = llm_chain.invoke({"query": user_input})
19
- print(response)
20
-
21
- print("---------------Response--------------")
22
- print(get_response_value(response["result"]))
23
- return get_response_value(response["result"])
24
-
25
- def main():
26
- # Initialize the database
27
- create_db_from_files()
28
-
29
- # Set up and launch the Gradio interface
30
- iface = gr.Interface(
31
- fn=chat_with_mistral,
32
- inputs=gr.components.Textbox(label="Enter Your Message"),
33
- outputs=gr.components.Markdown(label="ChatbotResponse"),
34
- title="Resvu AI Chatbot",
35
- description="Interact with the Resvu API via this chatbot. Enter a message and get a response.",
36
- examples=["Hi, how are you", "Who are you?", "What services do you offer?", "How can I find out about upcoming community events?"],
37
- allow_flagging="never"
38
- )
39
- iface.launch()
40
-
41
- if __name__ == "__main__":
42
  main()
 
1
+ import subprocess
2
+ import sys
3
+ import gradio as gr
4
+ from model import llm_chain_response, get_response_value
5
+ from process_documents import create_db_from_files
6
+
7
+ def run_setup():
8
+ subprocess.check_call([sys.executable, "setup.py"])
9
+
10
+ # Run the setup script
11
+ run_setup()
12
+ llm_chain = llm_chain_response()
13
+
14
+ def chat_with_mistral(user_input):
15
+ if not user_input:
16
+ return "The message is not be empty."
17
+ response = llm_chain.invoke({"query": user_input})
18
+ print(response)
19
+
20
+ print("---------------Response--------------")
21
+ print(get_response_value(response["result"]))
22
+ return get_response_value(response["result"])
23
+
24
+ def main():
25
+ # Initialize the database
26
+ create_db_from_files()
27
+
28
+ # Set up and launch the Gradio interface
29
+ iface = gr.Interface(
30
+ fn=chat_with_mistral,
31
+ inputs=gr.components.Textbox(label="Enter Your Message"),
32
+ outputs=gr.components.Markdown(label="ChatbotResponse"),
33
+ title="Resvu AI Chatbot",
34
+ description="Interact with the Resvu API via this chatbot. Enter a message and get a response.",
35
+ examples=["Hi, how are you", "Who are you?", "What services do you offer?", "How can I find out about upcoming community events?"],
36
+ allow_flagging="never"
37
+ )
38
+ iface.launch()
39
+
40
+ if __name__ == "__main__":
 
41
  main()