Home / File/ entity.py — langchain Source File

entity.py — langchain Source File

Architecture documentation for entity.py, a python file in the langchain codebase. 19 imports, 0 dependents.

File python CoreAbstractions Serialization 19 imports 1 functions 6 classes

Entity Profile

Dependency Diagram

graph LR
  d32f2004_60b5_cb46_fb04_539f46b711ad["entity.py"]
  2a7f66a7_8738_3d47_375b_70fcaa6ac169["logging"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> 2a7f66a7_8738_3d47_375b_70fcaa6ac169
  cccbe73e_4644_7211_4d55_e8fb133a8014["abc"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> cccbe73e_4644_7211_4d55_e8fb133a8014
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  436f77bc_653d_0edb_555c_c2679d5a59ac["itertools"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> 436f77bc_653d_0edb_555c_c2679d5a59ac
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  b19a8b7e_fbee_95b1_65b8_509a1ed3cad7["langchain_core._api"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> b19a8b7e_fbee_95b1_65b8_509a1ed3cad7
  ba43b74d_3099_7e1c_aac3_cf594720469e["langchain_core.language_models"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> ba43b74d_3099_7e1c_aac3_cf594720469e
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> d758344f_537f_649e_f467_b9d7442e86df
  e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> e6b4f61e_7b98_6666_3641_26b069517d4a
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> 91721f45_4909_e489_8c1f_084f8bd87145
  31974615_0d58_bd26_13f1_776e0a9d1413["langchain_classic.chains.llm"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> 31974615_0d58_bd26_13f1_776e0a9d1413
  34f6662f_3e50_5bf7_54f1_05e82f591554["langchain_classic.memory.chat_memory"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> 34f6662f_3e50_5bf7_54f1_05e82f591554
  006aa41a_5887_821e_0410_39c9449a6ec1["langchain_classic.memory.prompt"]
  d32f2004_60b5_cb46_fb04_539f46b711ad --> 006aa41a_5887_821e_0410_39c9449a6ec1
  style d32f2004_60b5_cb46_fb04_539f46b711ad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Deprecated as of LangChain v0.3.4 and will be removed in LangChain v1.0.0."""

import logging
from abc import ABC, abstractmethod
from collections.abc import Iterable
from itertools import islice
from typing import TYPE_CHECKING, Any

from langchain_core._api import deprecated
from langchain_core.language_models import BaseLanguageModel
from langchain_core.messages import BaseMessage, get_buffer_string
from langchain_core.prompts import BasePromptTemplate
from pydantic import BaseModel, ConfigDict, Field
from typing_extensions import override

from langchain_classic.chains.llm import LLMChain
from langchain_classic.memory.chat_memory import BaseChatMemory
from langchain_classic.memory.prompt import (
    ENTITY_EXTRACTION_PROMPT,
    ENTITY_SUMMARIZATION_PROMPT,
)
from langchain_classic.memory.utils import get_prompt_input_key

if TYPE_CHECKING:
    import sqlite3

logger = logging.getLogger(__name__)


@deprecated(
    since="0.3.1",
    removal="1.0.0",
    message=(
        "Please see the migration guide at: "
        "https://python.langchain.com/docs/versions/migrating_memory/"
    ),
)
class BaseEntityStore(BaseModel, ABC):
    """Abstract base class for Entity store."""

    @abstractmethod
    def get(self, key: str, default: str | None = None) -> str | None:
        """Get entity value from store."""

    @abstractmethod
    def set(self, key: str, value: str | None) -> None:
        """Set entity value in store."""

    @abstractmethod
    def delete(self, key: str) -> None:
        """Delete entity value from store."""

    @abstractmethod
    def exists(self, key: str) -> bool:
        """Check if entity exists in store."""

    @abstractmethod
    def clear(self) -> None:
        """Delete all entities from store."""

// ... (552 more lines)

Subdomains

Functions

Dependencies

  • abc
  • collections.abc
  • itertools
  • langchain_classic.chains.llm
  • langchain_classic.memory.chat_memory
  • langchain_classic.memory.prompt
  • langchain_classic.memory.utils
  • langchain_community.utilities.redis
  • langchain_core._api
  • langchain_core.language_models
  • langchain_core.messages
  • langchain_core.prompts
  • logging
  • pydantic
  • redis
  • sqlite3
  • typing
  • typing_extensions
  • upstash_redis

Frequently Asked Questions

What does entity.py do?
entity.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in entity.py?
entity.py defines 1 function(s): sqlite3.
What does entity.py depend on?
entity.py imports 19 module(s): abc, collections.abc, itertools, langchain_classic.chains.llm, langchain_classic.memory.chat_memory, langchain_classic.memory.prompt, langchain_classic.memory.utils, langchain_community.utilities.redis, and 11 more.
Where is entity.py in the architecture?
entity.py is located at libs/langchain/langchain_classic/memory/entity.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/langchain/langchain_classic/memory).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free