Spaces:
Sleeping
Sleeping
app20
Browse files
app.py
CHANGED
|
@@ -83,7 +83,6 @@ Your name is AngryGreta and you are a recycling chatbot with the objective to an
|
|
| 83 |
Use the following pieces of context to answer the question /
|
| 84 |
Answer in the same language of the question /
|
| 85 |
Context: {context}
|
| 86 |
-
Chat history: {chat_history}
|
| 87 |
User: {question}
|
| 88 |
{format_instructions}
|
| 89 |
"""
|
|
@@ -93,7 +92,6 @@ sys_prompt = SystemMessagePromptTemplate.from_template(template)
|
|
| 93 |
qa_prompt = ChatPromptTemplate(
|
| 94 |
messages=[
|
| 95 |
sys_prompt,
|
| 96 |
-
MessagesPlaceholder(variable_name="chat_history"),
|
| 97 |
HumanMessagePromptTemplate.from_template("{question}")],
|
| 98 |
partial_variables={"format_instructions": parser.get_format_instructions()}
|
| 99 |
)
|
|
@@ -108,17 +106,14 @@ llm = HuggingFaceHub(
|
|
| 108 |
},
|
| 109 |
)
|
| 110 |
|
| 111 |
-
memory = ConversationBufferMemory(llm=llm, memory_key="chat_history", input_key='question', output_key='output', return_messages=True)
|
| 112 |
-
|
| 113 |
qa_chain = ConversationalRetrievalChain.from_llm(
|
| 114 |
llm = llm,
|
| 115 |
-
|
| 116 |
-
memory = memory,
|
| 117 |
retriever = retriever,
|
| 118 |
verbose = True,
|
| 119 |
combine_docs_chain_kwargs={'prompt': qa_prompt},
|
| 120 |
get_chat_history = lambda h : h,
|
| 121 |
-
rephrase_question =
|
| 122 |
output_key = 'output',
|
| 123 |
)
|
| 124 |
|
|
|
|
| 83 |
Use the following pieces of context to answer the question /
|
| 84 |
Answer in the same language of the question /
|
| 85 |
Context: {context}
|
|
|
|
| 86 |
User: {question}
|
| 87 |
{format_instructions}
|
| 88 |
"""
|
|
|
|
| 92 |
qa_prompt = ChatPromptTemplate(
|
| 93 |
messages=[
|
| 94 |
sys_prompt,
|
|
|
|
| 95 |
HumanMessagePromptTemplate.from_template("{question}")],
|
| 96 |
partial_variables={"format_instructions": parser.get_format_instructions()}
|
| 97 |
)
|
|
|
|
| 106 |
},
|
| 107 |
)
|
| 108 |
|
|
|
|
|
|
|
| 109 |
qa_chain = ConversationalRetrievalChain.from_llm(
|
| 110 |
llm = llm,
|
| 111 |
+
memory = ConversationBufferMemory(llm=llm, memory_key="chat_history", input_key='question', output_key='output'),
|
|
|
|
| 112 |
retriever = retriever,
|
| 113 |
verbose = True,
|
| 114 |
combine_docs_chain_kwargs={'prompt': qa_prompt},
|
| 115 |
get_chat_history = lambda h : h,
|
| 116 |
+
rephrase_question = False,
|
| 117 |
output_key = 'output',
|
| 118 |
)
|
| 119 |
|