Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,56 +1,39 @@
|
|
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 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
"
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
def main():
|
40 |
-
# Initialize the database
|
41 |
-
create_db_from_files()
|
42 |
-
|
43 |
-
# Set up and launch the Gradio interface
|
44 |
-
iface = gr.Interface(
|
45 |
-
fn=chat_with_mistral,
|
46 |
-
inputs=gr.components.Textbox(label="Enter Your Message"),
|
47 |
-
outputs=gr.components.Markdown(label="ChatbotResponse"),
|
48 |
-
title="Resvu AI Chatbot",
|
49 |
-
description="Interact with the Resvu API via this chatbot. Enter a message and get a response.",
|
50 |
-
examples=["Hi, how are you", "Who are you?", "What services do you offer?", "How can I find out about upcoming community events?"],
|
51 |
-
allow_flagging="never"
|
52 |
-
)
|
53 |
-
iface.launch()
|
54 |
-
|
55 |
-
if __name__ == "__main__":
|
56 |
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 |
+
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
|
8 |
+
!pip install --no-deps xformers "trl<0.9.0" peft accelerate bitsandbytes
|
9 |
+
|
10 |
+
llm_chain = llm_chain_response()
|
11 |
+
|
12 |
+
def chat_with_mistral(user_input):
|
13 |
+
if not user_input:
|
14 |
+
return "The message is not be empty."
|
15 |
+
response = llm_chain.invoke({"query": user_input})
|
16 |
+
print(response)
|
17 |
+
|
18 |
+
print("---------------Response--------------")
|
19 |
+
print(get_response_value(response["result"]))
|
20 |
+
return get_response_value(response["result"])
|
21 |
+
|
22 |
+
def main():
|
23 |
+
# Initialize the database
|
24 |
+
create_db_from_files()
|
25 |
+
|
26 |
+
# Set up and launch the Gradio interface
|
27 |
+
iface = gr.Interface(
|
28 |
+
fn=chat_with_mistral,
|
29 |
+
inputs=gr.components.Textbox(label="Enter Your Message"),
|
30 |
+
outputs=gr.components.Markdown(label="ChatbotResponse"),
|
31 |
+
title="Resvu AI Chatbot",
|
32 |
+
description="Interact with the Resvu API via this chatbot. Enter a message and get a response.",
|
33 |
+
examples=["Hi, how are you", "Who are you?", "What services do you offer?", "How can I find out about upcoming community events?"],
|
34 |
+
allow_flagging="never"
|
35 |
+
)
|
36 |
+
iface.launch()
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
main()
|