annikwag commited on
Commit
ddeda43
·
verified ·
1 Parent(s): 3b73ef4

Update appStore/rag_utils.py

Browse files
Files changed (1) hide show
  1. 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 following context, answer the question in same language as the question. "
110
- "Ensure that every project title and project number in your answer is wrapped in ** (markdown bold). "
111
- "Include at least one sentence summarizing what the project does in relation to the query. "
112
- "Only output the final answer below, without repeating the context or question.\n\n"
 
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)