Spaces:
Paused
Paused
Shreyas094
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -237,7 +237,8 @@ def ask_question(question, temperature, top_p, repetition_penalty, web_search):
|
|
237 |
Original Question: {original_question}
|
238 |
Rephrased Search Query: {rephrased_query}
|
239 |
If the web search results don't contain relevant information, state that the information is not available in the search results.
|
240 |
-
Provide a concise and direct answer to the original question without mentioning the web search or these instructions
|
|
|
241 |
"""
|
242 |
prompt_val = ChatPromptTemplate.from_template(prompt_template)
|
243 |
formatted_prompt = prompt_val.format(context=context_str, original_question=question, rephrased_query=rephrased_query)
|
@@ -255,7 +256,8 @@ def ask_question(question, temperature, top_p, repetition_penalty, web_search):
|
|
255 |
{context}
|
256 |
Current Question: {question}
|
257 |
If the context doesn't contain relevant information, state that the information is not available.
|
258 |
-
Provide a concise and direct answer to the question
|
|
|
259 |
"""
|
260 |
prompt_val = ChatPromptTemplate.from_template(prompt_template)
|
261 |
formatted_prompt = prompt_val.format(context=context_str, question=question)
|
@@ -277,6 +279,12 @@ def ask_question(question, temperature, top_p, repetition_penalty, web_search):
|
|
277 |
else:
|
278 |
answer = full_response.strip()
|
279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
return answer
|
281 |
|
282 |
# Gradio interface
|
|
|
237 |
Original Question: {original_question}
|
238 |
Rephrased Search Query: {rephrased_query}
|
239 |
If the web search results don't contain relevant information, state that the information is not available in the search results.
|
240 |
+
Provide a concise and direct answer to the original question without mentioning the web search or these instructions.
|
241 |
+
Do not include any source information in your answer.
|
242 |
"""
|
243 |
prompt_val = ChatPromptTemplate.from_template(prompt_template)
|
244 |
formatted_prompt = prompt_val.format(context=context_str, original_question=question, rephrased_query=rephrased_query)
|
|
|
256 |
{context}
|
257 |
Current Question: {question}
|
258 |
If the context doesn't contain relevant information, state that the information is not available.
|
259 |
+
Provide a concise and direct answer to the question.
|
260 |
+
Do not include any source information in your answer.
|
261 |
"""
|
262 |
prompt_val = ChatPromptTemplate.from_template(prompt_template)
|
263 |
formatted_prompt = prompt_val.format(context=context_str, question=question)
|
|
|
279 |
else:
|
280 |
answer = full_response.strip()
|
281 |
|
282 |
+
# Add sources section
|
283 |
+
if web_search:
|
284 |
+
sources = set(doc.metadata['source'] for doc in web_docs)
|
285 |
+
sources_section = "\n\nSources:\n" + "\n".join(f"- {source}" for source in sources)
|
286 |
+
answer += sources_section
|
287 |
+
|
288 |
return answer
|
289 |
|
290 |
# Gradio interface
|