Skip to content

fix: remove duplicate load() and add missing @classmethod in BasicVectorMemory#107

Open
Mr-Neutr0n wants to merge 1 commit intoBAAI-Agents:mainfrom
Mr-Neutr0n:fix/vector-memory-load-method
Open

fix: remove duplicate load() and add missing @classmethod in BasicVectorMemory#107
Mr-Neutr0n wants to merge 1 commit intoBAAI-Agents:mainfrom
Mr-Neutr0n:fix/vector-memory-load-method

Conversation

@Mr-Neutr0n
Copy link

Summary

The BasicVectorMemory class in cradle/memory/basic_vector_memory.py has three bugs related to the load method:

  1. Duplicate method names: Two methods are both named load. In Python, the second definition silently overwrites the first, making the first load(self) dead code that can never be called.
  2. Infinite recursion in dead code: The first load(self) calls self.load(), which would recurse infinitely if it were ever reachable.
  3. Missing @classmethod decorator: The second load method uses cls as its first parameter and calls cls(...) to construct a new instance, which is the pattern of a classmethod, but the @classmethod decorator is missing. Without it, cls is just a regular parameter name and calling BasicVectorMemory.load(...) would fail.
  4. Incorrect attribute access: The method used cls.memory_path instead of the memory_path parameter passed as an argument. Since memory_path is an instance attribute (not a class attribute), cls.memory_path would raise an AttributeError.

Changes

  • Removed the dead-code first load(self) method
  • Added the @classmethod decorator to the remaining load method
  • Changed cls.memory_path to memory_path to use the function parameter

Test plan

  • Verify BasicVectorMemory.load(memory_path, vectorstore, embedding_provider) works as a classmethod
  • Verify the loaded memory path is read correctly from the memory_path parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant