Не могу позволить моему боту продолжать отвечать на мой вопросPython

Программы на Python
Anonymous
Не могу позволить моему боту продолжать отвечать на мой вопрос

Сообщение Anonymous »

Все в порядке, пока я не добавлю этот MessagesPlaceholder(variable_name="chat_history"), мой бот не может продолжать отвечать на мои вопросы.

Код: Выделить всё

memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)

prompt_chat = ChatPromptTemplate(
messages=[
SystemMessagePromptTemplate.from_template(
"you are a bartender, and you will have a conversation with customers"
),
MessagesPlaceholder(variable_name="chat_history"),
HumanMessagePromptTemplate.from_template("{question}")
]
)

qa = LLMChain(
llm=llm,
prompt=prompt_chat,
verbose=True,
memory=memory
)

t0 = time.time()

done = False
print('若要退出,請輸入 over.')
while not done:
input_chi = input()
if input_chi == 'over':
done = True
else:
t0 = time.time()
output_chi = qa({ "question": input_chi+ 'Q:' })
output_chi = output_chi['text']

print("回答時間:", time.time()-t0)
Надеюсь, кто-нибудь поможет мне решить эту проблему или даст несколько советов.

Подробнее здесь: https://stackoverflow.com/questions/785 ... y-question

Вернуться в «Python»