Skip to content

Commit 199f0d3

Browse files
committed
Return messages
1 parent 9afee6a commit 199f0d3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

services/chatbot/src/chatbot_api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ def get_qa_chain(llm, retriever, session):
7979
{summaries}
8080
Previous conversation:
8181
"""
82-
chat_prompt_template = "{chat_history}"
8382
human_prompt_template = "{question}"
8483
chatbot_prompt_template = "CrapBot:"
8584
messages = [
8685
("system", system_prompt_template),
87-
("placeholder", chat_prompt_template),
86+
MessagesPlaceholder(variable_name="chat_history", optional=True),
8887
("human", human_prompt_template),
8988
("system", chatbot_prompt_template),
9089
]
@@ -105,14 +104,17 @@ def get_qa_chain(llm, retriever, session):
105104
output_key="answer",
106105
k=6,
107106
chat_memory=chat_message_history,
107+
return_messages=True,
108108
),
109109
)
110110
# qa = LLMChain(prompt=PROMPT, llm=llm, retriever= retriever , memory=ConversationBufferWindowMemory(memory_key="chat_history", input_key="question", k=6), verbose = False)
111111
return qa
112112

113113

114114
def qa_answer(model, session, query):
115-
result = model.invoke({"question": query})
115+
result = model.invoke(
116+
{"question": query}
117+
)
116118
app.logger.debug("Result %s", result)
117119
app.logger.debug("Answering question %s", result["answer"])
118120
return result["answer"]

0 commit comments

Comments
 (0)