Find answers from the community

Updated 12 months ago

Running into this issue on llama-index-

At a glance

The community member is experiencing an AttributeError when trying to use the ContextChatEngine from the llama-index-core library version 0.10.21.post1. The issue seems to be related to the ChatMemoryBuffer and the SimpleChatStore classes, where the append method is not available on the ContextChatEngine object.

The comments suggest that the chat_engine was not constructed properly, and that the self.store should not be a ContextChatEngine object.

There is no explicitly marked answer in the provided information.

Running into this issue on llama-index-core 0.10.21.post1 when trying to do .chat on my ContextChatEngine, any ideas?:

Plain Text
AttributeError                            Traceback (most recent call last)
Cell In[24], line 3
      1 global chat_engine
----> 3 response = chat_engine.chat("What do you know about Darthus?")

File ~\miniconda3\lib\site-packages\llama_index\core\callbacks\utils.py:41, in trace_method.<locals>.decorator.<locals>.wrapper(self, *args, **kwargs)
     39 callback_manager = cast(CallbackManager, callback_manager)
     40 with callback_manager.as_trace(trace_id):
---> 41     return func(self, *args, **kwargs)

File ~\miniconda3\lib\site-packages\llama_index\core\chat_engine\context.py:160, in ContextChatEngine.chat(self, message, chat_history)
    158 if chat_history is not None:
    159     self._memory.set(chat_history)
--> 160 self._memory.put(ChatMessage(content=message, role="user"))
    162 context_str_template, nodes = self._generate_context(message)
    163 prefix_messages = self._get_prefix_messages_with_context(context_str_template)

File ~\miniconda3\lib\site-packages\llama_index\core\memory\chat_memory_buffer.py:140, in ChatMemoryBuffer.put(self, message)
    138 def put(self, message: ChatMessage) -> None:
    139     """Put chat history."""
--> 140     self.chat_store.add_message(self.chat_store_key, message)

File ~\miniconda3\lib\site-packages\llama_index\core\storage\chat_store\simple_chat_store.py:34, in SimpleChatStore.add_message(self, key, message, idx)
     32 """Add a message for a key."""
     33 if idx is None:
---> 34     self.store.setdefault(key, []).append(message)
     35 else:
     36     self.store.setdefault(key, []).insert(idx, message)

AttributeError: 'ContextChatEngine' object has no attribute 'append'
d
L
2 comments
How have you created your chat_engine?
Yea that seems like something was not constructed properly (self.store should not be a chat engine object here lol)
Add a reply
Sign up and join the conversation on Discord