add context mixin

This commit is contained in:
geekan 2024-01-09 16:32:38 +08:00
parent 9a42a14c91
commit 33db023e94

View file

@ -103,5 +103,23 @@ class Context(LLMMixin, BaseModel):
# return llm
class ContextMixin:
"""Mixin class for configurable objects"""
_context: Optional[Context] = None
def __init__(self, context: Optional[Context] = None):
self._context = context
def set_context(self, context: Optional[Context] = None):
"""Set parent context"""
self._context = context
@property
def context(self):
"""Get config"""
return self._context
# Global context, not in Env
context = Context()