krisha06 commited on
Commit
a61ec87
·
verified ·
1 Parent(s): 0cfc11a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -11,8 +11,11 @@ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
11
  # Chat function with prompt-based filtering
12
  def chat(instruction):
13
  prompt = f"""You are a helpful and expert Python programming tutor.
14
- If the question is about Python, explain clearly with examples.
15
- If the question is unrelated to Python, respond with "Sorry, I can only answer Python-related questions."
 
 
 
16
 
17
  ### Instruction:
18
  {instruction}
 
11
  # Chat function with prompt-based filtering
12
  def chat(instruction):
13
  prompt = f"""You are a helpful and expert Python programming tutor.
14
+
15
+ Only answer questions that are clearly related to Python programming. Do not try to answer any questions that are greetings, general knowledge, or unrelated topics.
16
+
17
+ If the question is not related to Python, simply respond with:
18
+ "Sorry, I can only answer Python-related questions."
19
 
20
  ### Instruction:
21
  {instruction}