-
I have a use case to create a simple multi-language support chatbot that mainly has 2 function, which is answer faq and handle other function like sign up that uses another lambda. I've created 2 tools for it, one is to trigger sign up function, another one is to answer faq question. The faq tool function uses RetrievalQA.from_chain_type function with Anthropic model claude-instant-1.1 and Opensearch as the vectorstore. I used initialize_agent with CONVERSATIONAL_REACT_DESCRIPTION as AgentType, put the 2 tools that mentioned above as params with OpenAI model gpt-3.5-turbo-0613. I've facing the problem where the result from tools is unable to detect and translate to the same language as the user input. Any idea how to solve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Answer generated by a 🤖 AnswerI found related issues that might be helpful. I did my best to summarize the solutions, but I recommend looking at the related issues yourself. Open IssuesAny ideas on making input and output languages consistent?The suggested solution is: A user suggested a solution that involves tweaking the tool and agent prompt. Here is the code snippet they provided: # For Tool have a pre-defined format
class KnowledgeTool(BaseTool):
request_format = '{{"USER": "<input_question>"}}'
name = 'Knowledge Tool'
description = f"""
Tool to answer something knowledgeable. Input should be JSON in the following format: {request_format}
"""
return_direct = False
# define your tool methods etc.....
# Initialize agent
conversational_agent = initialize_agent(
agent='conversational-react-description',
tools=[KnowledgeTool()])
# You can identify the language with any modules like lingua or fasttext
prompt_prefix = f"""<Your description similar to system message> Use only {language} language to reply"""
# Now the magic part
conversational_agent.agent.llm_chain.prompt = prompt_prefix However, another user reported an error when trying to implement this solution. The error was related to the 'run' method and the setup of the memory. The original user who suggested the solution asked for more information to replicate the issue, but no further solution was provided. This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. |
Beta Was this translation helpful? Give feedback.
Answer generated by a 🤖
Answer
I found related issues that might be helpful. I did my best to summarize the solutions, but I recommend looking at the related issues yourself.
Open Issues
Any ideas on making input and output languages consistent?
The suggested solution is:
A user suggested a solution that involves tweaking the tool and agent prompt. Here is the code snippet they provided: