Spaces:
Sleeping
Sleeping
Update chatbot_rag.py
Browse files- chatbot_rag.py +13 -14
chatbot_rag.py
CHANGED
|
@@ -79,23 +79,22 @@ def build_qa():
|
|
| 79 |
retriever = vectorstore.as_retriever(search_kwargs={"k": 3})
|
| 80 |
|
| 81 |
prompt = PromptTemplate(
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
Answer (one short sentence):
|
| 95 |
-
""",
|
| 96 |
)
|
| 97 |
|
| 98 |
|
|
|
|
| 99 |
# 6. Helper functions
|
| 100 |
def format_docs(docs):
|
| 101 |
"""Join document contents into a single string, skipping empty ones."""
|
|
|
|
| 79 |
retriever = vectorstore.as_retriever(search_kwargs={"k": 3})
|
| 80 |
|
| 81 |
prompt = PromptTemplate(
|
| 82 |
+
input_variables=["context", "question"],
|
| 83 |
+
template="""
|
| 84 |
+
You are a helpful assistant.
|
| 85 |
+
Use the following context to answer the question.
|
| 86 |
+
- If the answer is in the context, provide it in ONE short, plain sentence.
|
| 87 |
+
- If not in the context, say: "I don't know."
|
| 88 |
+
|
| 89 |
+
Context:
|
| 90 |
+
{context}
|
| 91 |
+
Question: {question}
|
| 92 |
+
Answer:
|
| 93 |
+
""",
|
|
|
|
|
|
|
| 94 |
)
|
| 95 |
|
| 96 |
|
| 97 |
+
|
| 98 |
# 6. Helper functions
|
| 99 |
def format_docs(docs):
|
| 100 |
"""Join document contents into a single string, skipping empty ones."""
|