Skip to content

[FEATURE]Unable to use user_memory with Redis / mem0 Opensource version #2426

Open
@ParthS-iViewLabs

Description

@ParthS-iViewLabs

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

I’m looking to integrate Redis history into CrewAI to manage conversation history more efficiently. The idea is to use Redis for storing and retrieving past interactions, which would help improve context handling and scalability for Crew. But i found, there is no direct support for Redis with Crew.

I tried exploring mem0 which uses Redis as a VectorDB support.

Currently there is hardcoded mem0 integration which uses API KEY, Find it here: mem0_storage.py

Describe the solution you'd like

It should be something like:

# Define configuration for Mem0 memory with Redis as the vector store
mem0_redis_config = {
    "vector_store": {
        "provider": "redis",
        "config": {
            "collection_name": "collection_mem0",
            "embedding_model_dims": 1536,
            "redis_url": "redis://localhost:6379/0"
        }
    },
    "version": "v1.1"
}

# Initialize Memory instance
mem0_instance = Memory.from_config(mem0_redis_config)
def create_sql_crew(session_id: str) -> Crew:
    """
    Create a CrewAI instance configured for SQL-related tasks.

    Args:
        user_id (str): The unique identifier for the user.

    Returns:
        Crew: A configured Crew instance for SQL operations.
    """
    agent_1 = create_sql_agent(session_id)
    extract_data = create_extract_data_task(agent_1)

    return Crew(
        agents=[agent_1],
        tasks=[extract_data],
        process=Process.sequential,
        memory=True,
        memory_config={  # Activate memory configuration
            "provider": "mem0",
            "config": {
                "client": mem0_instance,  	# Using pre-configured Redis memory
                "user_id": session_id,      # Session-specific memory isolation
            }
        },
        verbose=True
    )

Describe alternatives you've considered

No response

Additional context

No response

Willingness to Contribute

Yes, I'd be happy to submit a pull request

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions