Bhanumani12 commited on
Commit
763fb6d
·
verified ·
1 Parent(s): e3161e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -35,12 +35,8 @@ severities = {
35
  "Best Practice": "Low"
36
  }
37
 
38
- # ---------- Load QnA Model (optimized) ----------
39
- qa_pipeline = pipeline(
40
- "text2text-generation",
41
- model="google/flan-t5-base", # ✅ Smaller, faster model
42
- device=-1 # ✅ Use CPU explicitly or 0 for GPU if available
43
- )
44
 
45
  # ---------- Logging ----------
46
  def log_to_console(data, log_type):
@@ -181,7 +177,7 @@ Assistant:
181
  """
182
 
183
  try:
184
- result = qa_pipeline(prompt, max_new_tokens=512, do_sample=False, temperature=0.1, top_k=50) # ✅ Faster
185
  output = result[0]["generated_text"].strip()
186
  if output.startswith("Assistant:"):
187
  output = output.replace("Assistant:", "").strip()
@@ -240,4 +236,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
240
  clear_button.click(fn=clear_chat, inputs=None, outputs=[chatbot_output, query_input])
241
 
242
  if __name__ == "__main__":
243
- demo.launch()
 
35
  "Best Practice": "Low"
36
  }
37
 
38
+ # ---------- Load QnA Model (no fallback) ----------
39
+ qa_pipeline = pipeline("text2text-generation", model="google/flan-t5-large")
 
 
 
 
40
 
41
  # ---------- Logging ----------
42
  def log_to_console(data, log_type):
 
177
  """
178
 
179
  try:
180
+ result = qa_pipeline(prompt, max_new_tokens=1024, do_sample=False, temperature=0.1, top_k=50)
181
  output = result[0]["generated_text"].strip()
182
  if output.startswith("Assistant:"):
183
  output = output.replace("Assistant:", "").strip()
 
236
  clear_button.click(fn=clear_chat, inputs=None, outputs=[chatbot_output, query_input])
237
 
238
  if __name__ == "__main__":
239
+ demo.launch()