Skip to content

Type Mismatch in Langchain Vector Store Adapter's update Method #3767

@firedai

Description

@firedai

🐛 Describe the bug

Description

There is a type mismatch issue in the update method of the mem0/vector_stores/langchain.py file when passing parameters to the insert method.

Location

File: mem0/vector_stores/langchain.py Method: update Line: approximately line 118

Details

When the update method calls the insert method, the vector and payload parameters are not wrapped in lists, but the insert method's parameter definitions require them to be lists:

Current problematic code

def update(self, vector_id, vector=None, payload=None):
"""
Update a vector and its payload.
"""
self.delete(vector_id)
self.insert(vector, payload, [vector_id]) # Here payload and vector are not wrapped in []

insert method parameter definitions

def insert(
self, vectors: List[List[float]], payloads: Optional[List[Dict]] = None, ids: Optional[List[str]] = None
):

Suggested Fix

The vector and payload parameters should be wrapped in lists:

def update(self, vector_id, vector=None, payload=None):
"""
Update a vector and its payload.
"""
self.delete(vector_id)
self.insert([vector], [payload], [vector_id]) # Fixed: added []

Environment Information

  • mem0 version: 1.0.0
  • Python version: 3.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions