Comments (3)
To avoid the memory reset when dynamically creating agents, the key is to adjust how you use the reset
method on the ReActAgent
. The memory is cleared because the reset
method, by default, clears the agent's memory. If you want to keep the memory intact, you should modify the reset
method in your agent's implementation to include a parameter that controls whether to clear the memory.
Here's a quick guide on how to do it:
-
Modify the
reset
method in theReActAgent
class to accept aclear_memory
boolean parameter. By default, set this toTrue
. Whenclear_memory
isFalse
, the method should skip the memory clearing step. -
Update your
initialize_agent
function to callreset
withclear_memory=False
when you want to preserve the memory after agent creation.
Example modification for the reset
method:
def reset(self, clear_memory: bool = True):
if clear_memory:
self._memory.reset()
And then in your initialize_agent
function:
agent.reset(clear_memory=False)
This approach allows you to dynamically create agents with preserved memory, avoiding the issue of memory being cleared upon agent creation.
Details
Sources
- llama-index-legacy/llama_index/legacy/chat_engine/condense_question.py
- llama-index-core/llama_index/core/agent/react/base.py
- llama-index-core/llama_index/core/agent/legacy/react/base.py
- llama-index-legacy/llama_index/legacy/agent/react/base.py
- llama-index-legacy/llama_index/legacy/agent/legacy/react/base.py
- llama-index-core/llama_index/core/memory/chat_memory_buffer.py
- llama-index-legacy/llama_index/legacy/memory/chat_memory_buffer.py
- llama-index-core/llama_index/core/storage/chat_store/simple_chat_store.py
- docs/docs/module_guides/storing/chat_stores.md
- llama-index-legacy/llama_index/legacy/storage/chat_store/simple_chat_store.py
About Dosu
This response is meant to be useful and save you time. 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.
To continue the conversation, mention @dosu.
from llama_index.
@risos8200 agent.reset()
resets the memory -- any reason to run this when the agent was just created? I would just remove this line
from llama_index.
@logan-markewich It gives this error if I don't
'dict' object has no attribute 'content'
from llama_index.
Related Issues (20)
- cv-assistant
- response generation issue using elasticsearch HOT 5
- Elasticsearch persistence HOT 6
- [Question]: Implementing randomized Azure resources for indexing with VectorStoreIndex in asynchronous mode HOT 3
- [Question]: sent-len of sentence-spliter HOT 2
- [Bug]: System prompt has no effect using Ollama HOT 3
- API key for content summarization HOT 1
- [Question]: How to write production grade code HOT 3
- [Question]: Generate Only SQL Query HOT 3
- [Question]: how does llamaindex support large datasets? HOT 11
- [Bug]: MongoDBAtlasVectorSearch & VectorStoreIndex.from_vector_store are not working as expected HOT 5
- [Bug]: LanceDBVectorStore database size blows up on creation HOT 1
- [Question]: node structure for elasticsearch ~ Dosubot
- [Question]: SQL query response has 'sql\n' from SQLAutoVectorQueryEngine HOT 1
- [Question]: I want to get the coordinates using Unstructured as the metadata of nodes HOT 1
- [Bug]: async functions do not work.. HOT 3
- [Feature Request]: HOT 1
- [Bug]: ChatSummaryMemoryBuffer failed with chat_engine HOT 1
- [Bug]: When using HyDE, Langfuse doesn't log trace event
- [Bug]: VertexAIVectorStore fails w/ IndexError
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llama_index.