Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update appStore/rag_utils.py
Browse files- appStore/rag_utils.py +6 -5
appStore/rag_utils.py
CHANGED
@@ -103,17 +103,18 @@ def get_rag_answer(query, top_results, endpoint, token):
|
|
103 |
context = "\n\n".join([build_context_for_result(res, compute_title) for res in top_results])
|
104 |
context = truncate_to_tokens(context,11500) # Truncate to ~11.5k tokens
|
105 |
|
106 |
-
# Construct the prompt
|
107 |
prompt = (
|
108 |
"You are a project portfolio adviser at the development cooperation GIZ. "
|
109 |
-
"Using the
|
110 |
-
"
|
111 |
-
"
|
112 |
-
"
|
|
|
113 |
f"Context:\n{context}\n\n"
|
114 |
f"Question: {query}\n\n"
|
115 |
"Answer:"
|
116 |
)
|
|
|
117 |
headers = {"Authorization": f"Bearer {token}"}
|
118 |
payload = {"inputs": prompt, "parameters": {"max_new_tokens": 300}}
|
119 |
response = requests.post(endpoint, headers=headers, json=payload)
|
|
|
103 |
context = "\n\n".join([build_context_for_result(res, compute_title) for res in top_results])
|
104 |
context = truncate_to_tokens(context,11500) # Truncate to ~11.5k tokens
|
105 |
|
|
|
106 |
prompt = (
|
107 |
"You are a project portfolio adviser at the development cooperation GIZ. "
|
108 |
+
"Using the context below, answer the question in the same language as the question. "
|
109 |
+
"Your answer must be formatted in bullet points. "
|
110 |
+
"Ensure that every project title and project number in your answer is wrapped in double asterisks (e.g., **Project Title [2018.2101.6]**) to display them as markdown bold. "
|
111 |
+
"Include at least one short sentence per project summarizing what the project does in relation to the query. "
|
112 |
+
"Do not repeat any part of the provided context or the question in your final answer.\n\n"
|
113 |
f"Context:\n{context}\n\n"
|
114 |
f"Question: {query}\n\n"
|
115 |
"Answer:"
|
116 |
)
|
117 |
+
|
118 |
headers = {"Authorization": f"Bearer {token}"}
|
119 |
payload = {"inputs": prompt, "parameters": {"max_new_tokens": 300}}
|
120 |
response = requests.post(endpoint, headers=headers, json=payload)
|