Urvesh
Urvesh

Reputation: 425

Retrieve the Answer from the Local Chatbot in language which the User has asked in

I have created a local chatbot in python 3.10.10. I have used Langchain_community, and langchain_core, Chroma, Streamlit to build the chatbot application.

However, when I ask the question in German language, it gives me an answer in English language. I expect the answer in the same language which User has asked in the query (Question Tab).

I have tried using the package from langdetect import detect, but it still does not give me an answer in User langauge.

could anyone help me achieving this thing?

Upvotes: 0

Views: 77

Answers (1)

Arindam
Arindam

Reputation: 81

Not sure which LLM you are using from your question. But I would suggest add a line in system prompt saying "Always answer in the language of the user question" - something like that. And give it a try.

Alternatively, you need to use StructuredOutputParser() to translate to another language using external service after you get the LLM response.

More here: https://github.com/langchain-ai/langchain/issues/3306

Upvotes: 0

Related Questions