Find answers from the community

Updated 2 months ago

Agent

Hi Guys,
I am trying to build a react agent but it doesn't seem to have conversation history. Like i provide my name and ask it the next time but it is not responding,
Plain Text
chat_store = SimpleChatStore()
context = """You are a computer assistant"""
chat_memory = ChatMemoryBuffer.from_defaults(
    token_limit=3000,
    chat_store=chat_store,
    chat_store_key="user1",
)
tools = [
    QueryEngineTool(
        query_engine=query_engine,
        metadata=ToolMetadata(
            name="Data",
            description="this gives detailed information on pc data",),),
]
llm = OpenAI(model="gpt-3.5-turbo-0613")
agent = ReActAgent.from_tools(tools, llm=llm, verbose=True, context=context,memory=chat_memory)
while (prompt := input("Enter a prompt (q to quit): ")) != "q":
    result = agent.query(prompt)
    print("HISTORY:",agent.memory)

HISTORY: token_limit=8000 tokenizer_fn=functools.partial(<bound method Encoding.encode of <Encoding 'cl100k_base'>>, allowed_special='all') chat_store=SimpleChatStore(store={'user1': [ChatMessage(role=<MessageRole.USER: 'user'>, content='Hi', additional_kwargs={}), ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, content='Hello! How can I assist you today?', additional_kwargs={})]}) chat_store_key='user1'
HISTORY: token_limit=8000 tokenizer_fn=functools.partial(<bound method Encoding.encode of <Encoding 'cl100k_base'>>, allowed_special='all') chat_store=SimpleChatStore(store={'user1': [ChatMessage(role=<MessageRole.USER: 'user'>, content='Hello', additional_kwargs={}), ChatMessage(role=<MessageRole.ASSISTANT: 'assistant'>, content='Hi there! How can I assist you today?', additional_kwargs={})]}) chat_store_key='user1'
L
p
2 comments
You should be using agent.chat(), instead of query
Oh Thanks a lot πŸ™ bro its now working
Add a reply
Sign up and join the conversation on Discord