Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -34,9 +34,9 @@ model = HuggingFaceHub(
|
|
34 |
task="conversational",
|
35 |
model_kwargs={"temperature": 0.8, "max_length": 1000},
|
36 |
)
|
37 |
-
template = """
|
38 |
-
{context}
|
39 |
-
|
40 |
Helpful Answer:"""
|
41 |
QA_CHAIN_PROMPT = PromptTemplate.from_template(template)
|
42 |
|
@@ -73,6 +73,7 @@ def greet(question, pdf_file):
|
|
73 |
print("chat_history: ", chat_history)
|
74 |
a = load_db(pdf_file, 5)
|
75 |
r = a.invoke({"question": question, "chat_history": chat_history})
|
|
|
76 |
match = re.search(r'Helpful Answer:(.*)', r['answer'])
|
77 |
if match:
|
78 |
helpful_answer = match.group(1).strip()
|
|
|
34 |
task="conversational",
|
35 |
model_kwargs={"temperature": 0.8, "max_length": 1000},
|
36 |
)
|
37 |
+
template = """<s>[INST] You are a friendly study tutor chatbot that has access to a database of documents provided by the students. Use the chat history and your existing knowledge to answer the follow up question in a helpful and friendly way. Make sure your tone is that of a friendly study buddy. [/INST]
|
38 |
+
Chat History: {context}
|
39 |
+
Follow up question: {question}
|
40 |
Helpful Answer:"""
|
41 |
QA_CHAIN_PROMPT = PromptTemplate.from_template(template)
|
42 |
|
|
|
73 |
print("chat_history: ", chat_history)
|
74 |
a = load_db(pdf_file, 5)
|
75 |
r = a.invoke({"question": question, "chat_history": chat_history})
|
76 |
+
print(a.return_source_documents)
|
77 |
match = re.search(r'Helpful Answer:(.*)', r['answer'])
|
78 |
if match:
|
79 |
helpful_answer = match.group(1).strip()
|