Spaces:
Sleeping
Sleeping
yashMahajan
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -39,21 +39,18 @@ def respond(
|
|
39 |
|
40 |
response = response.strip()
|
41 |
|
42 |
-
#
|
43 |
-
if
|
44 |
return response
|
45 |
|
46 |
-
#
|
47 |
-
|
48 |
-
return response
|
49 |
-
|
50 |
-
return "Sorry, I am a chatbot specializing in questions related to the Constitution of India. Please ask a relevant question."
|
51 |
|
52 |
# Create the Gradio chat interface
|
53 |
demo = gr.ChatInterface(
|
54 |
respond,
|
55 |
additional_inputs=[
|
56 |
-
gr.Textbox(value="You are a knowledgeable assistant specializing in the Constitution of India. Answer only questions related to the Constitution. If the question is
|
57 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
58 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
59 |
gr.Slider(
|
|
|
39 |
|
40 |
response = response.strip()
|
41 |
|
42 |
+
# Check relevance with leniency
|
43 |
+
if "constitution" in message.lower() or "law" in message.lower() or "rights" in message.lower():
|
44 |
return response
|
45 |
|
46 |
+
# Provide response even for less relevant questions
|
47 |
+
return response or "Sorry, I can only answer questions related to the Constitution of India. Please ask a relevant question."
|
|
|
|
|
|
|
48 |
|
49 |
# Create the Gradio chat interface
|
50 |
demo = gr.ChatInterface(
|
51 |
respond,
|
52 |
additional_inputs=[
|
53 |
+
gr.Textbox(value="You are a knowledgeable assistant specializing in the Constitution of India. Answer only questions related to the Constitution. If the question is less relevant but potentially related, still provide an answer.", label="System message", visible=False),
|
54 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
55 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
56 |
gr.Slider(
|