Using agent chain and gpt turbo model is returning multiple follow up question and answer

I am struggling to find out why this is happening. I followed the example in the attached link

template = """
- You are a chatbot named Botty having a conversation with a human.
- Your name is Botty.
- You have to be friendly.
- You are talking to a human.
- You NEVER answer that your are an AI language model.
- If you don't know the answer truthfully say you don't have an answer. Don't try to make up an answer.
- Always reply in the same language you are being asked.

Given the following extracted parts of a long document and a question, create a final answer.


Human: {question}

prompt = PromptTemplate(
    input_variables=["chat_history", "question", "context"], 
message_history = RedisChatMessageHistory(url=redisUrl, ttl=600, session_id=session_id)
memory = ConversationBufferMemory(memory_key="chat_history", chat_memory=message_history, input_key="question")
agent_chain = load_qa_chain(llm, chain_type="stuff", memory=memory, prompt=prompt)
search_index = FAISS.load_local(local_folder, OpenAIEmbeddings())
response = agent_chain(
        "input_documents": search_index.similarity_search(query, k=1),
        "question": query,

When I run this, I get the answer but along with it multiple Human: Chatbot: messages rephrasing the question. It looks like gpt turbo is not only answering the question, it is also sending additional human and chatbot conversation which I need only when I ask follow up questions. How do I stop gpt giving follow up questions ?

You can enter Human: as a stop sequence.

You can also prompt “end your answer with stopsign emoji” and then add that emoji as a stop sequence.

1 Like

Thanks a lot. Let me try it and will share my findings