sample_id
stringlengths
21
196
text
stringlengths
105
936k
metadata
dict
category
stringclasses
6 values
marimo-team/marimo:tests/_pyodide/test_pyodide_session.py
# Copyright 2026 Marimo. All rights reserved. from __future__ import annotations import asyncio import json from textwrap import dedent from typing import TYPE_CHECKING from unittest.mock import MagicMock, Mock import msgspec import pytest from marimo._ast.app_config import _AppConfig from marimo._config.config impo...
{ "repo_id": "marimo-team/marimo", "file_path": "tests/_pyodide/test_pyodide_session.py", "license": "Apache License 2.0", "lines": 684, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
marimo-team/marimo:tests/_pyodide/test_pyodide_streams.py
import asyncio import json from unittest.mock import Mock import pytest from marimo._pyodide.streams import ( PyodideStderr, PyodideStdin, PyodideStdout, PyodideStream, ) from marimo._types.ids import CellId_t cell_id = CellId_t("test-cell-id") @pytest.fixture def pyodide_pipe() -> Mock: return...
{ "repo_id": "marimo-team/marimo", "file_path": "tests/_pyodide/test_pyodide_streams.py", "license": "Apache License 2.0", "lines": 155, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
marimo-team/marimo:tests/_pyodide/test_restartable_task.py
import asyncio import pytest from marimo._pyodide.restartable_task import RestartableTask async def test_restartable_task(): # Test basic start/stop counter = 0 event = asyncio.Event() async def increment_counter(): nonlocal counter counter += 1 event.set() # Signal that we...
{ "repo_id": "marimo-team/marimo", "file_path": "tests/_pyodide/test_restartable_task.py", "license": "Apache License 2.0", "lines": 204, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
marimo-team/marimo:tests/_utils/test_inline_script_metadata.py
from __future__ import annotations from typing import TYPE_CHECKING import pytest from marimo._utils.inline_script_metadata import ( PyProjectReader, _pyproject_toml_to_requirements_txt, has_marimo_in_script_metadata, is_marimo_dependency, script_metadata_hash_from_filename, ) from marimo._utils....
{ "repo_id": "marimo-team/marimo", "file_path": "tests/_utils/test_inline_script_metadata.py", "license": "Apache License 2.0", "lines": 373, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
marimo-team/marimo:marimo/_save/stores/rest.py
# Copyright 2026 Marimo. All rights reserved. from __future__ import annotations import urllib.error import urllib.request from typing import Optional from marimo import _loggers from marimo._save.stores.store import Store from marimo._version import __version__ LOGGER = _loggers.marimo_logger() class RestStore(St...
{ "repo_id": "marimo-team/marimo", "file_path": "marimo/_save/stores/rest.py", "license": "Apache License 2.0", "lines": 87, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
marimo-team/marimo:tests/_output/formatters/test_ipython_update.py
from __future__ import annotations from unittest.mock import MagicMock, patch import pytest from marimo._dependencies.dependencies import DependencyManager from marimo._output.formatters.ipython_formatters import ( IPythonFormatter, ) HAS_DEPS = DependencyManager.ipython.has() @pytest.mark.skipif(not HAS_DEPS...
{ "repo_id": "marimo-team/marimo", "file_path": "tests/_output/formatters/test_ipython_update.py", "license": "Apache License 2.0", "lines": 58, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
marimo-team/marimo:marimo/_smoke_tests/issues/4746_altair_hstacks.py
import marimo __generated_with = "0.15.5" app = marimo.App(width="medium") @app.cell def _(): import altair as alt import pandas as pd import marimo as mo from vega_datasets import data source = data.cars() plot_1 = mo.ui.altair_chart( alt.Chart(source) .mark_point() ...
{ "repo_id": "marimo-team/marimo", "file_path": "marimo/_smoke_tests/issues/4746_altair_hstacks.py", "license": "Apache License 2.0", "lines": 42, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:examples/misc/strands_agent_aws_elasticache_neptune.py
""" GitHub Repository Research Agent with Persistent Memory This example demonstrates how to build an AI agent with persistent memory using: - Mem0 for memory orchestration and lifecycle management - Amazon ElastiCache for Valkey for high-performance vector similarity search - Amazon Neptune Analytics for graph-based...
{ "repo_id": "mem0ai/mem0", "file_path": "examples/misc/strands_agent_aws_elasticache_neptune.py", "license": "Apache License 2.0", "lines": 314, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/configs/vector_stores/cassandra.py
from typing import Any, Dict, List, Optional from pydantic import BaseModel, Field, model_validator class CassandraConfig(BaseModel): """Configuration for Apache Cassandra vector database.""" contact_points: List[str] = Field( ..., description="List of contact point addresses (e.g., ['127.0....
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/vector_stores/cassandra.py", "license": "Apache License 2.0", "lines": 62, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/vector_stores/cassandra.py
import json import logging import uuid from typing import Any, Dict, List, Optional import numpy as np from pydantic import BaseModel try: from cassandra.cluster import Cluster from cassandra.auth import PlainTextAuthProvider except ImportError: raise ImportError( "Apache Cassandra vector store re...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/vector_stores/cassandra.py", "license": "Apache License 2.0", "lines": 432, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/vector_stores/test_cassandra.py
import json import pytest from unittest.mock import Mock, patch from mem0.vector_stores.cassandra import CassandraDB, OutputData @pytest.fixture def mock_session(): """Create a mock Cassandra session.""" session = Mock() session.execute = Mock(return_value=Mock()) session.prepare = Mock(return_value=...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_cassandra.py", "license": "Apache License 2.0", "lines": 228, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/embeddings/fastembed.py
from typing import Optional, Literal from mem0.embeddings.base import EmbeddingBase from mem0.configs.embeddings.base import BaseEmbedderConfig try: from fastembed import TextEmbedding except ImportError: raise ImportError("FastEmbed is not installed. Please install it using `pip install fastembed`") class ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/embeddings/fastembed.py", "license": "Apache License 2.0", "lines": 24, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:tests/embeddings/test_fastembed_embeddings.py
from unittest.mock import Mock, patch import pytest import numpy as np from mem0.configs.embeddings.base import BaseEmbedderConfig try: from mem0.embeddings.fastembed import FastEmbedEmbedding except ImportError: pytest.skip("fastembed not installed", allow_module_level=True) @pytest.fixture def mock_fast...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/embeddings/test_fastembed_embeddings.py", "license": "Apache License 2.0", "lines": 32, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/configs/rerankers/base.py
from typing import Optional from pydantic import BaseModel, Field class BaseRerankerConfig(BaseModel): """ Base configuration for rerankers with only common parameters. Provider-specific configurations should be handled by separate config classes. This class contains only the parameters that are comm...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/rerankers/base.py", "license": "Apache License 2.0", "lines": 13, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:mem0/configs/rerankers/cohere.py
from typing import Optional from pydantic import Field from mem0.configs.rerankers.base import BaseRerankerConfig class CohereRerankerConfig(BaseRerankerConfig): """ Configuration class for Cohere reranker-specific parameters. Inherits from BaseRerankerConfig and adds Cohere-specific settings. """ ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/rerankers/cohere.py", "license": "Apache License 2.0", "lines": 11, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/rerankers/config.py
from typing import Optional from pydantic import BaseModel, Field class RerankerConfig(BaseModel): """Configuration for rerankers.""" provider: str = Field(description="Reranker provider (e.g., 'cohere', 'sentence_transformer')", default="cohere") config: Optional[dict] = Field(description="Provider-spe...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/rerankers/config.py", "license": "Apache License 2.0", "lines": 7, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/rerankers/huggingface.py
from typing import Optional from pydantic import Field from mem0.configs.rerankers.base import BaseRerankerConfig class HuggingFaceRerankerConfig(BaseRerankerConfig): """ Configuration class for HuggingFace reranker-specific parameters. Inherits from BaseRerankerConfig and adds HuggingFace-specific setti...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/rerankers/huggingface.py", "license": "Apache License 2.0", "lines": 13, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/rerankers/llm.py
from typing import Optional from pydantic import Field from mem0.configs.rerankers.base import BaseRerankerConfig class LLMRerankerConfig(BaseRerankerConfig): """ Configuration for LLM-based reranker. Attributes: model (str): LLM model to use for reranking. Defaults to "gpt-4o-mini". ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/rerankers/llm.py", "license": "Apache License 2.0", "lines": 43, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/rerankers/sentence_transformer.py
from typing import Optional from pydantic import Field from mem0.configs.rerankers.base import BaseRerankerConfig class SentenceTransformerRerankerConfig(BaseRerankerConfig): """ Configuration class for Sentence Transformer reranker-specific parameters. Inherits from BaseRerankerConfig and adds Sentence ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/rerankers/sentence_transformer.py", "license": "Apache License 2.0", "lines": 12, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/rerankers/zero_entropy.py
from typing import Optional from pydantic import Field from mem0.configs.rerankers.base import BaseRerankerConfig class ZeroEntropyRerankerConfig(BaseRerankerConfig): """ Configuration for Zero Entropy reranker. Attributes: model (str): Model to use for reranking. Defaults to "zerank-1". ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/rerankers/zero_entropy.py", "license": "Apache License 2.0", "lines": 23, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/reranker/base.py
from abc import ABC, abstractmethod from typing import List, Dict, Any class BaseReranker(ABC): """Abstract base class for all rerankers.""" @abstractmethod def rerank(self, query: str, documents: List[Dict[str, Any]], top_k: int = None) -> List[Dict[str, Any]]: """ Rerank documents ba...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/reranker/base.py", "license": "Apache License 2.0", "lines": 16, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:mem0/reranker/cohere_reranker.py
import os from typing import List, Dict, Any from mem0.reranker.base import BaseReranker try: import cohere COHERE_AVAILABLE = True except ImportError: COHERE_AVAILABLE = False class CohereReranker(BaseReranker): """Cohere-based reranker implementation.""" def __init__(self, config): ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/reranker/cohere_reranker.py", "license": "Apache License 2.0", "lines": 69, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/reranker/huggingface_reranker.py
from typing import List, Dict, Any, Union import numpy as np from mem0.reranker.base import BaseReranker from mem0.configs.rerankers.base import BaseRerankerConfig from mem0.configs.rerankers.huggingface import HuggingFaceRerankerConfig try: from transformers import AutoTokenizer, AutoModelForSequenceClassificati...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/reranker/huggingface_reranker.py", "license": "Apache License 2.0", "lines": 120, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/reranker/llm_reranker.py
import re from typing import List, Dict, Any, Union from mem0.reranker.base import BaseReranker from mem0.utils.factory import LlmFactory from mem0.configs.rerankers.base import BaseRerankerConfig from mem0.configs.rerankers.llm import LLMRerankerConfig class LLMReranker(BaseReranker): """LLM-based reranker impl...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/reranker/llm_reranker.py", "license": "Apache License 2.0", "lines": 112, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/reranker/sentence_transformer_reranker.py
from typing import List, Dict, Any, Union import numpy as np from mem0.reranker.base import BaseReranker from mem0.configs.rerankers.base import BaseRerankerConfig from mem0.configs.rerankers.sentence_transformer import SentenceTransformerRerankerConfig try: from sentence_transformers import SentenceTransformer ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/reranker/sentence_transformer_reranker.py", "license": "Apache License 2.0", "lines": 87, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/reranker/zero_entropy_reranker.py
import os from typing import List, Dict, Any from mem0.reranker.base import BaseReranker try: from zeroentropy import ZeroEntropy ZERO_ENTROPY_AVAILABLE = True except ImportError: ZERO_ENTROPY_AVAILABLE = False class ZeroEntropyReranker(BaseReranker): """Zero Entropy-based reranker implementation.""...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/reranker/zero_entropy_reranker.py", "license": "Apache License 2.0", "lines": 77, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/utils/gcp_auth.py
import os import json from typing import Optional, Dict, Any try: from google.oauth2 import service_account from google.auth import default import google.auth.credentials except ImportError: raise ImportError("google-auth is required for GCP authentication. Install with: pip install google-auth") cla...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/utils/gcp_auth.py", "license": "Apache License 2.0", "lines": 140, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/vector_stores/test_milvus.py
""" Unit tests for Milvus vector store implementation. These tests verify: 1. Correct type handling for vector dimensions 2. Batch insert functionality 3. Filter creation for metadata queries 4. Update/upsert operations """ import pytest from unittest.mock import MagicMock, patch from mem0.vector_stores.milvus import...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_milvus.py", "license": "Apache License 2.0", "lines": 202, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/configs/vector_stores/azure_mysql.py
from typing import Any, Dict, Optional from pydantic import BaseModel, Field, model_validator class AzureMySQLConfig(BaseModel): """Configuration for Azure MySQL vector database.""" host: str = Field(..., description="MySQL server host (e.g., myserver.mysql.database.azure.com)") port: int = Field(3306, ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/vector_stores/azure_mysql.py", "license": "Apache License 2.0", "lines": 68, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/vector_stores/azure_mysql.py
import json import logging from contextlib import contextmanager from typing import Any, Dict, List, Optional from pydantic import BaseModel try: import pymysql from pymysql.cursors import DictCursor from dbutils.pooled_db import PooledDB except ImportError: raise ImportError( "Azure MySQL vec...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/vector_stores/azure_mysql.py", "license": "Apache License 2.0", "lines": 404, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/vector_stores/test_azure_mysql.py
import json import pytest from unittest.mock import Mock, patch from mem0.vector_stores.azure_mysql import AzureMySQL, OutputData @pytest.fixture def mock_connection_pool(): """Create a mock connection pool.""" pool = Mock() conn = Mock() cursor = Mock() # Setup cursor mock cursor.fetchall =...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_azure_mysql.py", "license": "Apache License 2.0", "lines": 208, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:tests/memory/test_storage.py
import os import sqlite3 import tempfile import uuid from datetime import datetime import pytest from mem0.memory.storage import SQLiteManager class TestSQLiteManager: """Comprehensive test cases for SQLiteManager class.""" @pytest.fixture def temp_db_path(self): """Create temporary database fi...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/memory/test_storage.py", "license": "Apache License 2.0", "lines": 242, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/graphs/neptune/neptunedb.py
import logging import uuid from datetime import datetime import pytz from .base import NeptuneBase try: from langchain_aws import NeptuneGraph except ImportError: raise ImportError("langchain_aws is not installed. Please install it using 'make install_all'.") logger = logging.getLogger(__name__) class Memor...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/graphs/neptune/neptunedb.py", "license": "Apache License 2.0", "lines": 453, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:mem0/graphs/neptune/neptunegraph.py
import logging from .base import NeptuneBase try: from langchain_aws import NeptuneAnalyticsGraph from botocore.config import Config except ImportError: raise ImportError("langchain_aws is not installed. Please install it using 'make install_all'.") logger = logging.getLogger(__name__) class MemoryGrap...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/graphs/neptune/neptunegraph.py", "license": "Apache License 2.0", "lines": 422, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:tests/memory/test_neptune_analytics_memory.py
import unittest from unittest.mock import MagicMock, patch import pytest from mem0.graphs.neptune.neptunegraph import MemoryGraph from mem0.graphs.neptune.base import NeptuneBase class TestNeptuneMemory(unittest.TestCase): """Test suite for the Neptune Memory implementation.""" def setUp(self): """Se...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/memory/test_neptune_analytics_memory.py", "license": "Apache License 2.0", "lines": 261, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/exceptions.py
"""Structured exception classes for Mem0 with error codes, suggestions, and debug information. This module provides a comprehensive set of exception classes that replace the generic APIError with specific, actionable exceptions. Each exception includes error codes, user-friendly suggestions, and debug information to e...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/exceptions.py", "license": "Apache License 2.0", "lines": 408, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:mem0/configs/vector_stores/neptune.py
""" Configuration for Amazon Neptune Analytics vector store. This module provides configuration settings for integrating with Amazon Neptune Analytics as a vector store backend for Mem0's memory layer. """ from pydantic import BaseModel, Field class NeptuneAnalyticsConfig(BaseModel): """ Configuration class...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/vector_stores/neptune.py", "license": "Apache License 2.0", "lines": 20, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:mem0/vector_stores/neptune_analytics.py
import logging import time import uuid from typing import Dict, List, Optional from pydantic import BaseModel try: from langchain_aws import NeptuneAnalyticsGraph except ImportError: raise ImportError("langchain_aws is not installed. Please install it using pip install langchain_aws") from mem0.vector_stores...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/vector_stores/neptune_analytics.py", "license": "Apache License 2.0", "lines": 372, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:tests/vector_stores/test_neptune_analytics.py
import logging import os import sys import pytest from dotenv import load_dotenv from mem0.utils.factory import VectorStoreFactory load_dotenv() # Configure logging logging.getLogger("mem0.vector.neptune.main").setLevel(logging.INFO) logging.getLogger("mem0.vector.neptune.base").setLevel(logging.INFO) logger = logg...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_neptune_analytics.py", "license": "Apache License 2.0", "lines": 145, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/configs/vector_stores/valkey.py
from pydantic import BaseModel class ValkeyConfig(BaseModel): """Configuration for Valkey vector store.""" valkey_url: str collection_name: str embedding_model_dims: int timezone: str = "UTC" index_type: str = "hnsw" # Default to HNSW, can be 'hnsw' or 'flat' # HNSW specific parameters w...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/vector_stores/valkey.py", "license": "Apache License 2.0", "lines": 12, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/vector_stores/valkey.py
import json import logging from datetime import datetime from typing import Dict import numpy as np import pytz import valkey from pydantic import BaseModel from valkey.exceptions import ResponseError from mem0.memory.utils import extract_json from mem0.vector_stores.base import VectorStoreBase logger = logging.getL...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/vector_stores/valkey.py", "license": "Apache License 2.0", "lines": 695, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/vector_stores/test_valkey.py
import json from datetime import datetime from unittest.mock import MagicMock, patch import numpy as np import pytest import pytz from valkey.exceptions import ResponseError from mem0.vector_stores.valkey import ValkeyDB @pytest.fixture def mock_valkey_client(): """Create a mock Valkey client.""" with patch...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_valkey.py", "license": "Apache License 2.0", "lines": 665, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/configs/vector_stores/s3_vectors.py
from typing import Any, Dict, Optional from pydantic import BaseModel, ConfigDict, Field, model_validator class S3VectorsConfig(BaseModel): vector_bucket_name: str = Field(description="Name of the S3 Vector bucket") collection_name: str = Field("mem0", description="Name of the vector index") embedding_mo...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/vector_stores/s3_vectors.py", "license": "Apache License 2.0", "lines": 23, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/vector_stores/s3_vectors.py
import json import logging from typing import Dict, List, Optional from pydantic import BaseModel from mem0.vector_stores.base import VectorStoreBase try: import boto3 from botocore.exceptions import ClientError except ImportError: raise ImportError("The 'boto3' library is required. Please install it usi...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/vector_stores/s3_vectors.py", "license": "Apache License 2.0", "lines": 151, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/vector_stores/test_s3_vectors.py
from mem0.configs.vector_stores.s3_vectors import S3VectorsConfig import pytest from botocore.exceptions import ClientError from mem0.memory.main import Memory from mem0.vector_stores.s3_vectors import S3Vectors BUCKET_NAME = "test-bucket" INDEX_NAME = "test-index" EMBEDDING_DIMS = 1536 REGION = "us-east-1" @pytest...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_s3_vectors.py", "license": "Apache License 2.0", "lines": 182, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:openmemory/api/app/routers/backup.py
from datetime import UTC, datetime import io import json import gzip import zipfile from typing import Optional, List, Dict, Any from uuid import UUID from fastapi import APIRouter, Depends, HTTPException, UploadFile, File, Query, Form from fastapi.responses import StreamingResponse from pydantic import BaseModel f...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/routers/backup.py", "license": "Apache License 2.0", "lines": 409, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/llms/test_azure_openai_structured.py
from unittest import mock from mem0.llms.azure_openai_structured import SCOPE, AzureOpenAIStructuredLLM class DummyAzureKwargs: def __init__( self, api_key=None, azure_deployment="test-deployment", azure_endpoint="https://test-endpoint.openai.azure.com", api_version="2024-...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/llms/test_azure_openai_structured.py", "license": "Apache License 2.0", "lines": 87, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/configs/llms/aws_bedrock.py
import os from typing import Any, Dict, List, Optional from mem0.configs.llms.base import BaseLlmConfig class AWSBedrockConfig(BaseLlmConfig): """ Configuration class for AWS Bedrock LLM integration. Supports all available Bedrock models with automatic provider detection. """ def __init__( ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/llms/aws_bedrock.py", "license": "Apache License 2.0", "lines": 162, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/configs/vector_stores/databricks.py
from typing import Any, Dict, Optional from pydantic import BaseModel, ConfigDict, Field, model_validator from databricks.sdk.service.vectorsearch import EndpointType, VectorIndexType, PipelineType class DatabricksConfig(BaseModel): """Configuration for Databricks Vector Search vector store.""" workspace_u...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/vector_stores/databricks.py", "license": "Apache License 2.0", "lines": 51, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/vector_stores/databricks.py
import json import logging import uuid from typing import Optional, List from datetime import datetime, date from databricks.sdk.service.catalog import ColumnInfo, ColumnTypeName, TableType, DataSourceFormat from databricks.sdk.service.catalog import TableConstraint, PrimaryKeyConstraint from databricks.sdk import Work...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/vector_stores/databricks.py", "license": "Apache License 2.0", "lines": 683, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/vector_stores/test_databricks.py
from types import SimpleNamespace from unittest.mock import MagicMock, patch from databricks.sdk.service.vectorsearch import VectorIndexType, QueryVectorIndexResponse, ResultManifest, ResultData, ColumnInfo from mem0.vector_stores.databricks import Databricks import pytest # ---------------------- Fixtures ----------...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_databricks.py", "license": "Apache License 2.0", "lines": 281, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/memory/kuzu_memory.py
import logging from mem0.memory.utils import format_entities try: import kuzu except ImportError: raise ImportError("kuzu is not installed. Please install it using pip install kuzu") try: from rank_bm25 import BM25Okapi except ImportError: raise ImportError("rank_bm25 is not installed. Please install...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/memory/kuzu_memory.py", "license": "Apache License 2.0", "lines": 621, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/memory/test_kuzu.py
import numpy as np import pytest from unittest.mock import Mock, patch from mem0.memory.kuzu_memory import MemoryGraph class TestKuzu: """Test that Kuzu memory works correctly""" # Create distinct embeddings that won't match with threshold=0.7 # Each embedding is mostly zeros with ones in different posit...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/memory/test_kuzu.py", "license": "Apache License 2.0", "lines": 173, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:tests/memory/test_neo4j_cypher_syntax.py
import os from unittest.mock import Mock, patch class TestNeo4jCypherSyntaxFix: """Test that Neo4j Cypher syntax fixes work correctly""" def test_get_all_generates_valid_cypher_with_agent_id(self): """Test that get_all method generates valid Cypher with agent_id""" # Mock the langchain_ne...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/memory/test_neo4j_cypher_syntax.py", "license": "Apache License 2.0", "lines": 223, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/configs/llms/anthropic.py
from typing import Optional from mem0.configs.llms.base import BaseLlmConfig class AnthropicConfig(BaseLlmConfig): """ Configuration class for Anthropic-specific parameters. Inherits from BaseLlmConfig and adds Anthropic-specific settings. """ def __init__( self, # Base parameter...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/llms/anthropic.py", "license": "Apache License 2.0", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/llms/azure.py
from typing import Any, Dict, Optional from mem0.configs.base import AzureConfig from mem0.configs.llms.base import BaseLlmConfig class AzureOpenAIConfig(BaseLlmConfig): """ Configuration class for Azure OpenAI-specific parameters. Inherits from BaseLlmConfig and adds Azure OpenAI-specific settings. ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/llms/azure.py", "license": "Apache License 2.0", "lines": 51, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/llms/deepseek.py
from typing import Optional from mem0.configs.llms.base import BaseLlmConfig class DeepSeekConfig(BaseLlmConfig): """ Configuration class for DeepSeek-specific parameters. Inherits from BaseLlmConfig and adds DeepSeek-specific settings. """ def __init__( self, # Base parameters ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/llms/deepseek.py", "license": "Apache License 2.0", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/llms/lmstudio.py
from typing import Any, Dict, Optional from mem0.configs.llms.base import BaseLlmConfig class LMStudioConfig(BaseLlmConfig): """ Configuration class for LM Studio-specific parameters. Inherits from BaseLlmConfig and adds LM Studio-specific settings. """ def __init__( self, # Base...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/llms/lmstudio.py", "license": "Apache License 2.0", "lines": 53, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/llms/ollama.py
from typing import Optional from mem0.configs.llms.base import BaseLlmConfig class OllamaConfig(BaseLlmConfig): """ Configuration class for Ollama-specific parameters. Inherits from BaseLlmConfig and adds Ollama-specific settings. """ def __init__( self, # Base parameters ...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/llms/ollama.py", "license": "Apache License 2.0", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/llms/openai.py
from typing import Any, Callable, List, Optional from mem0.configs.llms.base import BaseLlmConfig class OpenAIConfig(BaseLlmConfig): """ Configuration class for OpenAI and OpenRouter-specific parameters. Inherits from BaseLlmConfig and adds OpenAI-specific settings. """ def __init__( sel...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/llms/openai.py", "license": "Apache License 2.0", "lines": 72, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/configs/llms/vllm.py
from typing import Optional from mem0.configs.llms.base import BaseLlmConfig class VllmConfig(BaseLlmConfig): """ Configuration class for vLLM-specific parameters. Inherits from BaseLlmConfig and adds vLLM-specific settings. """ def __init__( self, # Base parameters model...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/llms/vllm.py", "license": "Apache License 2.0", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:tests/vector_stores/test_pgvector.py
import importlib import sys import unittest import uuid from unittest.mock import MagicMock, patch from mem0.vector_stores.pgvector import PGVector class TestPGVector(unittest.TestCase): def setUp(self): """Set up test fixtures.""" self.mock_conn = MagicMock() self.mock_cursor = MagicMock...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_pgvector.py", "license": "Apache License 2.0", "lines": 1860, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:examples/misc/personalized_search.py
""" Personalized Search Agent with Mem0 + Tavily Uses LangChain agent pattern with Tavily tools for personalized search based on user memories stored in Mem0. """ from dotenv import load_dotenv from mem0 import MemoryClient from langchain.agents import create_openai_tools_agent, AgentExecutor from langchain_core.promp...
{ "repo_id": "mem0ai/mem0", "file_path": "examples/misc/personalized_search.py", "license": "Apache License 2.0", "lines": 192, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:examples/multiagents/llamaindex_learning_system.py
""" Multi-Agent Personal Learning System: Mem0 + LlamaIndex AgentWorkflow Example INSTALLATIONS: !pip install llama-index-core llama-index-memory-mem0 openai You need MEM0_API_KEY and OPENAI_API_KEY to run the example. """ import asyncio import logging from datetime import datetime from dotenv import load_dotenv #...
{ "repo_id": "mem0ai/mem0", "file_path": "examples/multiagents/llamaindex_learning_system.py", "license": "Apache License 2.0", "lines": 165, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:examples/misc/multillm_memory.py
""" Multi-LLM Research Team with Shared Knowledge Base Use Case: AI Research Team where each model has different strengths: - GPT-4: Technical analysis and code review - Claude: Writing and documentation All models share a common knowledge base, building on each other's work. Example: GPT-4 analyzes a tech stack → Cl...
{ "repo_id": "mem0ai/mem0", "file_path": "examples/misc/multillm_memory.py", "license": "Apache License 2.0", "lines": 135, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/client/project.py
import logging from abc import ABC, abstractmethod from typing import Any, Dict, List, Optional import httpx from pydantic import BaseModel, ConfigDict, Field from mem0.client.utils import api_error_handler from mem0.memory.telemetry import capture_client_event # Exception classes are referenced in docstrings only l...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/client/project.py", "license": "Apache License 2.0", "lines": 788, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:mem0/client/utils.py
import json import logging import httpx from mem0.exceptions import ( NetworkError, create_exception_from_response, ) logger = logging.getLogger(__name__) class APIError(Exception): """Exception raised for errors in the API. Deprecated: Use specific exception classes from mem0.exceptions instea...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/client/utils.py", "license": "Apache License 2.0", "lines": 95, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/test_memory_integration.py
from unittest.mock import MagicMock, patch from mem0.memory.main import Memory def test_memory_configuration_without_env_vars(): """Test Memory configuration with mock config instead of environment variables""" # Mock configuration without relying on environment variables mock_config = { "llm": ...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/test_memory_integration.py", "license": "Apache License 2.0", "lines": 152, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/graphs/neptune/base.py
import logging from abc import ABC, abstractmethod from mem0.memory.utils import format_entities try: from rank_bm25 import BM25Okapi except ImportError: raise ImportError("rank_bm25 is not installed. Please install it using pip install rank-bm25") from mem0.graphs.tools import ( DELETE_MEMORY_STRUCT_TOO...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/graphs/neptune/base.py", "license": "Apache License 2.0", "lines": 424, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/memory/test_neptune_memory.py
import unittest from unittest.mock import MagicMock, patch import pytest from mem0.graphs.neptune.neptunedb import MemoryGraph from mem0.graphs.neptune.base import NeptuneBase class TestNeptuneMemory(unittest.TestCase): """Test suite for the Neptune Memory implementation.""" def setUp(self): """Set u...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/memory/test_neptune_memory.py", "license": "Apache License 2.0", "lines": 306, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:examples/misc/test.py
from agents import Agent, Runner, enable_verbose_stdout_logging, function_tool from dotenv import load_dotenv from mem0 import MemoryClient enable_verbose_stdout_logging() load_dotenv() # Initialize Mem0 client mem0 = MemoryClient() # Define memory tools for the agent @function_tool def search_memory(query: str, ...
{ "repo_id": "mem0ai/mem0", "file_path": "examples/misc/test.py", "license": "Apache License 2.0", "lines": 65, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:examples/misc/vllm_example.py
""" Example of using vLLM with mem0 for high-performance memory operations. SETUP INSTRUCTIONS: 1. Install vLLM: pip install vllm 2. Start vLLM server (in a separate terminal): vllm serve microsoft/DialoGPT-small --port 8000 Wait for the message: "Uvicorn running on http://0.0.0.0:8000" (Small model: ~50...
{ "repo_id": "mem0ai/mem0", "file_path": "examples/misc/vllm_example.py", "license": "Apache License 2.0", "lines": 115, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/llms/test_vllm.py
from unittest.mock import MagicMock, Mock, patch import pytest from mem0 import AsyncMemory, Memory from mem0.configs.llms.base import BaseLlmConfig from mem0.llms.vllm import VllmLLM @pytest.fixture def mock_vllm_client(): with patch("mem0.llms.vllm.OpenAI") as mock_openai: mock_client = Mock() ...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/llms/test_vllm.py", "license": "Apache License 2.0", "lines": 155, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:mem0/configs/vector_stores/baidu.py
from typing import Any, Dict from pydantic import BaseModel, ConfigDict, Field, model_validator class BaiduDBConfig(BaseModel): endpoint: str = Field("http://localhost:8287", description="Endpoint URL for Baidu VectorDB") account: str = Field("root", description="Account for Baidu VectorDB") api_key: str...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/vector_stores/baidu.py", "license": "Apache License 2.0", "lines": 22, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:tests/vector_stores/test_baidu.py
from unittest.mock import Mock, PropertyMock, patch import pytest from pymochow.exception import ServerError from pymochow.model.enum import ServerErrCode, TableState from pymochow.model.table import ( FloatVector, Table, VectorSearchConfig, VectorTopkSearchRequest, ) from mem0.vector_stores.baidu imp...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_baidu.py", "license": "Apache License 2.0", "lines": 174, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:examples/misc/diet_assistant_voice_cartesia.py
"""Simple Voice Agent with Memory: Personal Food Assistant. A food assistant that remembers your dietary preferences and speaks recommendations Powered by Agno + Cartesia + Mem0 export MEM0_API_KEY=your_mem0_api_key export OPENAI_API_KEY=your_openai_api_key export CARTESIA_API_KEY=your_cartesia_api_key """ from textw...
{ "repo_id": "mem0ai/mem0", "file_path": "examples/misc/diet_assistant_voice_cartesia.py", "license": "Apache License 2.0", "lines": 103, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:mem0/configs/vector_stores/mongodb.py
from typing import Any, Dict, Optional from pydantic import BaseModel, Field, model_validator class MongoDBConfig(BaseModel): """Configuration for MongoDB vector database.""" db_name: str = Field("mem0_db", description="Name of the MongoDB database") collection_name: str = Field("mem0", description="Nam...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/configs/vector_stores/mongodb.py", "license": "Apache License 2.0", "lines": 20, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/vector_stores/mongodb.py
import logging from importlib.metadata import version from typing import Any, Dict, List, Optional from pydantic import BaseModel try: from pymongo import MongoClient from pymongo.driver_info import DriverInfo from pymongo.errors import PyMongoError from pymongo.operations import SearchIndexModel exce...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/vector_stores/mongodb.py", "license": "Apache License 2.0", "lines": 269, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/vector_stores/test_mongodb.py
from unittest.mock import MagicMock, patch import pytest from mem0.vector_stores.mongodb import MongoDB @pytest.fixture @patch("mem0.vector_stores.mongodb.MongoClient") def mongo_vector_fixture(mock_mongo_client): mock_client = mock_mongo_client.return_value mock_db = mock_client["test_db"] mock_collect...
{ "repo_id": "mem0ai/mem0", "file_path": "tests/vector_stores/test_mongodb.py", "license": "Apache License 2.0", "lines": 272, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
mem0ai/mem0:openmemory/api/alembic/versions/afd00efbd06b_add_unique_user_id_constraints.py
"""remove_global_unique_constraint_on_app_name_add_composite_unique Revision ID: afd00efbd06b Revises: add_config_table Create Date: 2025-06-04 01:59:41.637440 """ from typing import Sequence, Union from alembic import op # revision identifiers, used by Alembic. revision: str = 'afd00efbd06b' down_revision: Union[s...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/alembic/versions/afd00efbd06b_add_unique_user_id_constraints.py", "license": "Apache License 2.0", "lines": 26, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/llms/sarvam.py
import os from typing import Dict, List, Optional import requests from mem0.configs.llms.base import BaseLlmConfig from mem0.llms.base import LLMBase class SarvamLLM(LLMBase): def __init__(self, config: Optional[BaseLlmConfig] = None): super().__init__(config) # Set default model if not provide...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/llms/sarvam.py", "license": "Apache License 2.0", "lines": 66, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:openmemory/api/alembic/versions/add_config_table.py
"""add_config_table Revision ID: add_config_table Revises: 0b53c747049a Create Date: 2023-06-01 10:00:00.000000 """ import uuid import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision = 'add_config_table' down_revision = '0b53c747049a' branch_labels = None depends_on = None ...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/alembic/versions/add_config_table.py", "license": "Apache License 2.0", "lines": 31, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/app/routers/config.py
from typing import Any, Dict, Optional from app.database import get_db from app.models import Config as ConfigModel from app.utils.memory import reset_memory_client from fastapi import APIRouter, Depends, HTTPException from pydantic import BaseModel, Field from sqlalchemy.orm import Session router = APIRouter(prefix=...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/routers/config.py", "license": "Apache License 2.0", "lines": 235, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:examples/misc/healthcare_assistant_google_adk.py
import asyncio import warnings from google.adk.agents import Agent from google.adk.runners import Runner from google.adk.sessions import InMemorySessionService from google.genai import types from mem0 import MemoryClient warnings.filterwarnings("ignore", category=DeprecationWarning) # Initialize Mem0 client mem0_c...
{ "repo_id": "mem0ai/mem0", "file_path": "examples/misc/healthcare_assistant_google_adk.py", "license": "Apache License 2.0", "lines": 159, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:openmemory/api/alembic/env.py
import os import sys from logging.config import fileConfig from alembic import context from dotenv import load_dotenv from sqlalchemy import engine_from_config, pool # Add the parent directory to the Python path sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # Load environment variables...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/alembic/env.py", "license": "Apache License 2.0", "lines": 66, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/alembic/versions/0b53c747049a_initial_migration.py
"""Initial migration Revision ID: 0b53c747049a Revises: Create Date: 2025-04-19 00:59:56.244203 """ from typing import Sequence, Union import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision: str = '0b53c747049a' down_revision: Union[str, None] = None branch_labels: Union[s...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/alembic/versions/0b53c747049a_initial_migration.py", "license": "Apache License 2.0", "lines": 217, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/app/database.py
import os from dotenv import load_dotenv from sqlalchemy import create_engine from sqlalchemy.orm import declarative_base, sessionmaker # load .env file (make sure you have DATABASE_URL set) load_dotenv() DATABASE_URL = os.getenv("DATABASE_URL", "sqlite:///./openmemory.db") if not DATABASE_URL: raise RuntimeErro...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/database.py", "license": "Apache License 2.0", "lines": 24, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/app/mcp_server.py
""" MCP Server for OpenMemory with resilient memory client handling. This module implements an MCP (Model Context Protocol) server that provides memory operations for OpenMemory. The memory client is initialized lazily to prevent server crashes when external dependencies (like Ollama) are unavailable. If the memory cl...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/mcp_server.py", "license": "Apache License 2.0", "lines": 415, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:openmemory/api/app/models.py
import datetime import enum import uuid import sqlalchemy as sa from app.database import Base from app.utils.categorization import get_categories_for_memory from sqlalchemy import ( JSON, UUID, Boolean, Column, DateTime, Enum, ForeignKey, Index, Integer, String, Table, e...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/models.py", "license": "Apache License 2.0", "lines": 200, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/app/routers/apps.py
from typing import Optional from uuid import UUID from app.database import get_db from app.models import App, Memory, MemoryAccessLog, MemoryState from fastapi import APIRouter, Depends, HTTPException, Query from sqlalchemy import desc, func from sqlalchemy.orm import Session, joinedload router = APIRouter(prefix="/a...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/routers/apps.py", "license": "Apache License 2.0", "lines": 198, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:openmemory/api/app/routers/stats.py
from app.database import get_db from app.models import App, Memory, MemoryState, User from fastapi import APIRouter, Depends, HTTPException from sqlalchemy.orm import Session router = APIRouter(prefix="/api/v1/stats", tags=["stats"]) @router.get("/") async def get_profile( user_id: str, db: Session = Depends(...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/routers/stats.py", "license": "Apache License 2.0", "lines": 23, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/app/schemas.py
from datetime import datetime from typing import List, Optional from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, validator class MemoryBase(BaseModel): content: str metadata_: Optional[dict] = Field(default_factory=dict) class MemoryCreate(MemoryBase): user_id: UUID app_id: U...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/schemas.py", "license": "Apache License 2.0", "lines": 49, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/app/utils/categorization.py
import logging from typing import List from app.utils.prompts import MEMORY_CATEGORIZATION_PROMPT from dotenv import load_dotenv from openai import OpenAI from pydantic import BaseModel from tenacity import retry, stop_after_attempt, wait_exponential load_dotenv() openai_client = OpenAI() class MemoryCategories(Bas...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/utils/categorization.py", "license": "Apache License 2.0", "lines": 34, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/app/utils/db.py
from typing import Tuple from app.models import App, User from sqlalchemy.orm import Session def get_or_create_user(db: Session, user_id: str) -> User: """Get or create a user with the given user_id""" user = db.query(User).filter(User.user_id == user_id).first() if not user: user = User(user_id=...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/utils/db.py", "license": "Apache License 2.0", "lines": 26, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:openmemory/api/app/utils/memory.py
""" Memory client utilities for OpenMemory. This module provides functionality to initialize and manage the Mem0 memory client with automatic configuration management and Docker environment support. Docker Ollama Configuration: When running inside a Docker container and using Ollama as the LLM or embedder provider, t...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/utils/memory.py", "license": "Apache License 2.0", "lines": 330, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:openmemory/api/app/utils/permissions.py
from typing import Optional from uuid import UUID from app.models import App, Memory, MemoryState from sqlalchemy.orm import Session def check_memory_access_permissions( db: Session, memory: Memory, app_id: Optional[UUID] = None ) -> bool: """ Check if the given app has permission to access a mem...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/utils/permissions.py", "license": "Apache License 2.0", "lines": 42, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:openmemory/api/app/utils/prompts.py
MEMORY_CATEGORIZATION_PROMPT = """Your task is to assign each piece of information (or “memory”) to one or more of the following categories. Feel free to use multiple categories per item when appropriate. - Personal: family, friends, home, hobbies, lifestyle - Relationships: social network, significant others, colleag...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/app/utils/prompts.py", "license": "Apache License 2.0", "lines": 26, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
mem0ai/mem0:openmemory/api/main.py
import datetime from uuid import uuid4 from app.config import DEFAULT_APP_ID, USER_ID from app.database import Base, SessionLocal, engine from app.mcp_server import setup_mcp_server from app.models import App, User from app.routers import apps_router, backup_router, config_router, memories_router, stats_router from fa...
{ "repo_id": "mem0ai/mem0", "file_path": "openmemory/api/main.py", "license": "Apache License 2.0", "lines": 75, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
mem0ai/mem0:mem0/embeddings/aws_bedrock.py
import json import os from typing import Literal, Optional try: import boto3 except ImportError: raise ImportError("The 'boto3' library is required. Please install it using 'pip install boto3'.") import numpy as np from mem0.configs.embeddings.base import BaseEmbedderConfig from mem0.embeddings.base import E...
{ "repo_id": "mem0ai/mem0", "file_path": "mem0/embeddings/aws_bedrock.py", "license": "Apache License 2.0", "lines": 77, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
mem0ai/mem0:tests/memory/test_main.py
import logging from unittest.mock import MagicMock import pytest from mem0.memory.main import AsyncMemory, Memory def _setup_mocks(mocker): """Helper to setup common mocks for both sync and async fixtures""" mock_embedder = mocker.MagicMock() mock_embedder.return_value.embed.return_value = [0.1, 0.2, 0....
{ "repo_id": "mem0ai/mem0", "file_path": "tests/memory/test_main.py", "license": "Apache License 2.0", "lines": 102, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test