tstone87 commited on
Commit
94e7992
·
verified ·
1 Parent(s): 9390961

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -58,8 +58,22 @@ def get_huggingface_response(query):
58
  # 🔹 Main Chatbot Function
59
  def chatbot_response(message, history):
60
  relevant_info = search_faiss(message)
 
61
  if "No relevant information found." not in relevant_info:
62
- return relevant_info
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  return get_huggingface_response(message)
64
 
65
  # 🔹 Gradio Chat Interface
 
58
  # 🔹 Main Chatbot Function
59
  def chatbot_response(message, history):
60
  relevant_info = search_faiss(message)
61
+
62
  if "No relevant information found." not in relevant_info:
63
+ # Summarize and clarify the retrieved policy text using Hugging Face LLM
64
+ user_query_with_context = f"""
65
+ The user is asking: {message}
66
+
67
+ The most relevant policy information retrieved is:
68
+
69
+ {relevant_info}
70
+
71
+ Please summarize this information in a clear, concise, and user-friendly way for someone inquiring about Colorado food stamps.
72
+ Provide the most recent information you can. If the most relevant policy information does not seem to apply do your best to answer the question accurately but make it clear you are not pulling the reply from the SNAP policy CCR and at that point you can encourage they try searching other keywords to possibly find better policy information.
73
+ """
74
+
75
+ return get_huggingface_response(user_query_with_context)
76
+
77
  return get_huggingface_response(message)
78
 
79
  # 🔹 Gradio Chat Interface