__init__() — langchain Function Reference
Architecture documentation for the __init__() function in entity.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d11783a0_d6d8_0a95_fa5a_83d372212579["__init__()"] 65c1d19b_b721_7b61_7b71_c0d54a3a49e7["UpstashRedisEntityStore"] d11783a0_d6d8_0a95_fa5a_83d372212579 -->|defined in| 65c1d19b_b721_7b61_7b71_c0d54a3a49e7 style d11783a0_d6d8_0a95_fa5a_83d372212579 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/memory/entity.py lines 111–155
def __init__(
self,
session_id: str = "default",
url: str = "",
token: str = "",
key_prefix: str = "memory_store",
ttl: int | None = 60 * 60 * 24,
recall_ttl: int | None = 60 * 60 * 24 * 3,
*args: Any,
**kwargs: Any,
):
"""Initializes the RedisEntityStore.
Args:
session_id: Unique identifier for the session.
url: URL of the Redis server.
token: Authentication token for the Redis server.
key_prefix: Prefix for keys in the Redis store.
ttl: Time-to-live for keys in seconds (default 1 day).
recall_ttl: Time-to-live extension for keys when recalled (default 3 days).
*args: Additional positional arguments.
**kwargs: Additional keyword arguments.
"""
try:
from upstash_redis import Redis
except ImportError as e:
msg = (
"Could not import upstash_redis python package. "
"Please install it with `pip install upstash_redis`."
)
raise ImportError(msg) from e
super().__init__(*args, **kwargs)
try:
self.redis_client = Redis(url=url, token=token)
except Exception as exc:
error_msg = "Upstash Redis instance could not be initiated"
logger.exception(error_msg)
raise RuntimeError(error_msg) from exc
self.session_id = session_id
self.key_prefix = key_prefix
self.ttl = ttl
self.recall_ttl = recall_ttl or ttl
Domain
Subdomains
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/memory/entity.py.
Where is __init__() defined?
__init__() is defined in libs/langchain/langchain_classic/memory/entity.py at line 111.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free