clean output
Browse files- src/streamlit_app.py +3 -4
src/streamlit_app.py
CHANGED
|
@@ -39,7 +39,7 @@ prompt = PromptTemplate(
|
|
| 39 |
"You are a knowledgeable agricultural research assistant.\n"
|
| 40 |
"Use the context to answer the question.\n"
|
| 41 |
# "If you don't know, say \"I don't know\".\n\n"
|
| 42 |
-
"Return ONLY the answer between an answer tag, do not include the context and question.\n\n"
|
| 43 |
"Context:\n{context}\n\n"
|
| 44 |
"Question: {question}\n\n"
|
| 45 |
# "Answer: <answer - put answer after this tag> "
|
|
@@ -92,11 +92,10 @@ if query:
|
|
| 92 |
with st.spinner("Thinking..."):
|
| 93 |
result = qa.invoke({"query":query})
|
| 94 |
raw = result["result"]
|
| 95 |
-
|
| 96 |
-
raw_answer = result["result"] # from your RAG pipeline
|
| 97 |
|
| 98 |
# Extract text from href
|
| 99 |
-
match = re.search(r
|
| 100 |
if match:
|
| 101 |
clean_answer = match.group(1)
|
| 102 |
else:
|
|
|
|
| 39 |
"You are a knowledgeable agricultural research assistant.\n"
|
| 40 |
"Use the context to answer the question.\n"
|
| 41 |
# "If you don't know, say \"I don't know\".\n\n"
|
| 42 |
+
"Return ONLY the answer between an <answer> tag, do not include the context and question.\n\n"
|
| 43 |
"Context:\n{context}\n\n"
|
| 44 |
"Question: {question}\n\n"
|
| 45 |
# "Answer: <answer - put answer after this tag> "
|
|
|
|
| 92 |
with st.spinner("Thinking..."):
|
| 93 |
result = qa.invoke({"query":query})
|
| 94 |
raw = result["result"]
|
| 95 |
+
raw_answer = result["result"]
|
|
|
|
| 96 |
|
| 97 |
# Extract text from href
|
| 98 |
+
match = re.search(r"<answer>(.*?)</answer>", raw_answer, re.DOTALL)
|
| 99 |
if match:
|
| 100 |
clean_answer = match.group(1)
|
| 101 |
else:
|