Files
letta-server/letta/helpers/singleton.py
Kian Jones b8e9a80d93 merge this (#4759)
* wait I forgot to comit locally

* cp the entire core directory and then rm the .git subdir
2025-09-17 15:47:40 -07:00

16 lines
370 B
Python

# TODO (cliandy): consolidate with decorators later
from functools import wraps
def singleton(cls):
"""Decorator to make a class a Singleton class."""
instances = {}
@wraps(cls)
def get_instance(*args, **kwargs):
if cls not in instances:
instances[cls] = cls(*args, **kwargs)
return instances[cls]
return get_instance