mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-27 01:36:29 +02:00
add context mixin
This commit is contained in:
parent
9a42a14c91
commit
33db023e94
1 changed files with 18 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue