Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -101,11 +101,11 @@ def chatbot_response(user_query, top_k=3, num_candidates=3):
|
|
101 |
best_response = grade_responses(speculative_responses, user_query)
|
102 |
return best_response
|
103 |
|
104 |
-
def chatbot(query):
|
105 |
if not query.strip():
|
106 |
return "Please ask a question about hadiths."
|
107 |
try:
|
108 |
-
answer = chatbot_response(query)
|
109 |
if "don't know" in answer.lower() or "not sure" in answer.lower():
|
110 |
return "Sorry. I don't have information about the hadiths related. It might be a dhoif, or maudhu, or I just don't have the knowledge."
|
111 |
else:
|
@@ -117,7 +117,9 @@ def chatbot(query):
|
|
117 |
if __name__ == "__main__":
|
118 |
iface = gr.Interface(
|
119 |
fn=chatbot,
|
120 |
-
inputs=
|
|
|
|
|
121 |
outputs=gr.Textbox(label="Answer"),
|
122 |
title="Hadith QA Chatbot",
|
123 |
description="Ask questions related to Hadiths."
|
|
|
101 |
best_response = grade_responses(speculative_responses, user_query)
|
102 |
return best_response
|
103 |
|
104 |
+
def chatbot(query, num_candidates):
|
105 |
if not query.strip():
|
106 |
return "Please ask a question about hadiths."
|
107 |
try:
|
108 |
+
answer = chatbot_response(query, num_candidates)
|
109 |
if "don't know" in answer.lower() or "not sure" in answer.lower():
|
110 |
return "Sorry. I don't have information about the hadiths related. It might be a dhoif, or maudhu, or I just don't have the knowledge."
|
111 |
else:
|
|
|
117 |
if __name__ == "__main__":
|
118 |
iface = gr.Interface(
|
119 |
fn=chatbot,
|
120 |
+
inputs=[
|
121 |
+
gr.Textbox(lines=2, placeholder="Enter your question here..."),
|
122 |
+
gr.Slider(minimum=1, maximum=10, value=3, step=1, label="Number of Hadiths as References")],
|
123 |
outputs=gr.Textbox(label="Answer"),
|
124 |
title="Hadith QA Chatbot",
|
125 |
description="Ask questions related to Hadiths."
|