Files
letta-server/letta/helpers/singleton.py
Andy Li 80f6e97ca9 feat: otel metrics and expanded collecting (#2647)
(passed tests in last run)
2025-06-05 17:20:14 -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