yvann-ba / Robby-chatbot

AI chatbot 🤖 for chat with CSV, PDF, TXT files 📄 and YTB videos 🎥 | using Langchain🦜 | OpenAI | Streamlit ⚡

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

standalone question often translated into English, even the user using other language. how to aviod it?

chinesewebman opened this issue · comments

I modified _template and qa_template in chatbot.py, ask it to use specific language, but it still goes back to English after several conversations... how to avoid it? please let me know, thanks!

commented

Hi! I think one of the possible solutions would be to use FewShot PromptTemplate from Langchain. It allows you to give examples of conversations in the prompt to show the chatbot how to do it, maybe try putting examples where it answers in the same language as the user. Or else put a button to choose the language or the clicked language is added at the end of the user's prompt in "answer in french" . Or we could initialize the chat_history with bits of conversations where the chatbot answers in the same language as the user, it will serve as an example. I hope that these tracks can help you, do not hesitate to keep me informed

many thanks!

Does this method work? I am trying to make language dynamic too but with no success.

in the new version or Robby it seems one template is missing, so I modified like this;
`
cq_template = """"给定以下聊天历史和后续问题,如果后续问题是完整的句子,就原样将后续问题复制为独立问题,如果后续问题不是一个完整句子或完整问题,就参考聊天历史将其补全为独立问题。
聊天历史:
{chat_history}
后续问题: {question}
独立问题:"""

CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(cq_template)

chain = ConversationalRetrievalChain.from_llm(llm=llm,
retriever=retriever, condense_question_prompt=self.CONDENSE_QUESTION_PROMPT, verbose=True, return_source_documents=True, max_tokens_limit=4097, combine_docs_chain_kwargs={'prompt': self.QA_PROMPT})
chain_input = {"question": query, "chat_history": st.session_state["history"]}
`
my code was heavy modified and it's in Chinese, so... sorry for can't request a PR for this.