Find answers from the community

Updated 3 months ago

Hello, I'm curious about the discrepancy

Hello, I'm curious about the discrepancy in behavior between the OpenAiAgent and the as_chat_engine when retrieving answers from the knowledge base. While using as_chat_engine, the responses align with the information in the knowledge base and are accurate. However, when employing OpenAiAgent, it seems to exhibit a different behavior. Could you please shed light on this inconsistency?
Here is my code:
system_messages = [ ChatMessage(role=MessageRole('system'), content="🌟 Welcome to our chat!"), ChatMessage(role=MessageRole( 'system'), content="πŸ€– I'm your friendly bot assistant. Ask me anything and let's explore together!"), ] messages = custom_chat_history messages.extend(system_messages) memory = ChatMemoryBuffer.from_defaults(chat_history=messages) agent = OpenAIAgent.from_tools( query_engine_tools, verbose=True, memory=memory) response = agent.chat(text)
L
A
4 comments
as_chat_engine() uses a default query engine tool name and description, and does not include those system messages (unless you added them as well to as_chat_engine()

Specifically, the default name is query_engine_tool and the default description is Useful for running a natural language query against a knowledge base and get back a natural language response.
right.. @Logan M but i've used the description for QueryEngineTool to restrict on knowledge base with high similarity_top_k then Bot gives the answer as I apologize, but I don't have any knowledge in my knowledge base
how could we achieve the same behaviour of query_engine with OpenAiAgent.
is it possible to achieve?
Probably better to let the system prompt restrict the knowledge instead of the description?

(Also, it's usually better to add the system prompt with OpenAIAgent.from_tools(..., system_prompt="...."), otherwise your current method will lose the system prompt if the chat gets too long, due to the sliding window on the memory)
thanks @Logan M .
i've used system_prompt and description to restrict on knowledge base. But idk why it still grab the answer from the outside of the knowledge base. ☹️
Add a reply
Sign up and join the conversation on Discord