Spaces:
Runtime error
Runtime error
SunderAli17
commited on
Commit
•
695545c
1
Parent(s):
01e9056
Update app.py
Browse files
app.py
CHANGED
@@ -48,7 +48,7 @@ def handle_query(query):
|
|
48 |
(
|
49 |
"user",
|
50 |
"""
|
51 |
-
You are the
|
52 |
|
53 |
Context:
|
54 |
{context_str}
|
@@ -79,7 +79,7 @@ def handle_query(query):
|
|
79 |
elif isinstance(answer, dict) and 'response' in answer:
|
80 |
response = answer['response']
|
81 |
else:
|
82 |
-
response = "Sorry, as per my current knowledge I am unable to answer this question. Is there anything else I can help you with?"
|
83 |
|
84 |
# Remove sensitive information and unwanted sections from the response
|
85 |
sensitive_keywords = [PERSIST_DIR, PDF_DIRECTORY, "/", "\\", ".pdf", ".doc", ".txt"]
|
@@ -119,14 +119,29 @@ def chatbot_handler(query):
|
|
119 |
response = handle_query(query)
|
120 |
return response
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
# Create the Gradio interface
|
123 |
interface = gr.Interface(
|
124 |
fn=chatbot_handler,
|
125 |
inputs=input_component,
|
126 |
outputs=output_component,
|
127 |
title="Welcome to SAK solutions",
|
128 |
-
description="I am here to assist you with any questions you have about Heart Disease Preventions. How can the Savior Bot help you?"
|
|
|
|
|
129 |
)
|
130 |
|
131 |
# Launch the Gradio interface
|
132 |
-
interface.launch()
|
|
|
48 |
(
|
49 |
"user",
|
50 |
"""
|
51 |
+
You are the Savior Bot. Your goal is to provide accurate, preventions, and helpful answers to user queries based on the available data. Always ensure your responses are clear and concise.
|
52 |
|
53 |
Context:
|
54 |
{context_str}
|
|
|
79 |
elif isinstance(answer, dict) and 'response' in answer:
|
80 |
response = answer['response']
|
81 |
else:
|
82 |
+
response = "Sorry, SAK solutions are trying to improve my knowledge further, however, as per my current knowledge I am unable to answer this question. Is there anything else I can help you with?"
|
83 |
|
84 |
# Remove sensitive information and unwanted sections from the response
|
85 |
sensitive_keywords = [PERSIST_DIR, PDF_DIRECTORY, "/", "\\", ".pdf", ".doc", ".txt"]
|
|
|
119 |
response = handle_query(query)
|
120 |
return response
|
121 |
|
122 |
+
theme = gr.themes.Soft(
|
123 |
+
font=[gr.themes.GoogleFont('Pacifico'), gr.themes.GoogleFont('Public Sans'), 'system-ui', 'sans-serif'],
|
124 |
+
)
|
125 |
+
js_func = """
|
126 |
+
function refresh() {
|
127 |
+
const url = new URL(window.location);
|
128 |
+
if (url.searchParams.get('__theme') !== 'dark') {
|
129 |
+
url.searchParams.set('__theme', 'dark');
|
130 |
+
window.location.href = url.href;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
"""
|
134 |
+
|
135 |
# Create the Gradio interface
|
136 |
interface = gr.Interface(
|
137 |
fn=chatbot_handler,
|
138 |
inputs=input_component,
|
139 |
outputs=output_component,
|
140 |
title="Welcome to SAK solutions",
|
141 |
+
description="I am here to assist you with any questions you have about Heart Disease Preventions. How can the Savior Bot help you?",
|
142 |
+
theme = theme,
|
143 |
+
js = js_func
|
144 |
)
|
145 |
|
146 |
# Launch the Gradio interface
|
147 |
+
interface.launch(share=True)
|