Spaces:
Running
Running
Thomas Stone
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -79,10 +79,20 @@ def respond(
|
|
79 |
if val[1]:
|
80 |
messages.append({"role": "assistant", "content": val[1]})
|
81 |
|
82 |
-
# 🔹
|
83 |
policy_context = search_policy(message)
|
|
|
84 |
if policy_context:
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
messages.append({"role": "user", "content": message})
|
88 |
|
@@ -98,6 +108,7 @@ def respond(
|
|
98 |
response += token
|
99 |
yield response
|
100 |
|
|
|
101 |
# 🔹 Gradio Chat Interface
|
102 |
demo = gr.ChatInterface(
|
103 |
respond,
|
|
|
79 |
if val[1]:
|
80 |
messages.append({"role": "assistant", "content": val[1]})
|
81 |
|
82 |
+
# 🔹 Retrieve policy info related to the query
|
83 |
policy_context = search_policy(message)
|
84 |
+
|
85 |
if policy_context:
|
86 |
+
# 🔹 Force the LLM to use retrieved policy text
|
87 |
+
system_context = f"""
|
88 |
+
You are an expert in Colorado public assistance policies.
|
89 |
+
Below is relevant information retrieved from official policy documents:
|
90 |
+
|
91 |
+
{policy_context}
|
92 |
+
|
93 |
+
Based on this information, answer the user's question accurately and concisely.
|
94 |
+
"""
|
95 |
+
messages.append({"role": "system", "content": system_context})
|
96 |
|
97 |
messages.append({"role": "user", "content": message})
|
98 |
|
|
|
108 |
response += token
|
109 |
yield response
|
110 |
|
111 |
+
|
112 |
# 🔹 Gradio Chat Interface
|
113 |
demo = gr.ChatInterface(
|
114 |
respond,
|