Spaces:
Sleeping
Sleeping
Update chatbot_rag.py
Browse files- chatbot_rag.py +11 -10
chatbot_rag.py
CHANGED
|
@@ -64,18 +64,19 @@ def build_qa():
|
|
| 64 |
|
| 65 |
# 5. Prompt
|
| 66 |
prompt = PromptTemplate(
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
| 76 |
)
|
| 77 |
|
| 78 |
-
|
| 79 |
# 6. Helper functions
|
| 80 |
def format_docs(docs):
|
| 81 |
return "\n".join(doc.page_content for doc in docs)
|
|
|
|
| 64 |
|
| 65 |
# 5. Prompt
|
| 66 |
prompt = PromptTemplate(
|
| 67 |
+
input_variables=["context", "question"],
|
| 68 |
+
template="""
|
| 69 |
+
Use the following context to answer the question at the end.
|
| 70 |
+
If you don't know the answer, just say "I don't know" — do not make up an answer.
|
| 71 |
+
|
| 72 |
+
Context:
|
| 73 |
+
{context}
|
| 74 |
+
|
| 75 |
+
Question: {question}
|
| 76 |
+
Answer (one short sentence):
|
| 77 |
+
""",
|
| 78 |
)
|
| 79 |
|
|
|
|
| 80 |
# 6. Helper functions
|
| 81 |
def format_docs(docs):
|
| 82 |
return "\n".join(doc.page_content for doc in docs)
|