Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

feat: +code

莘权 马26c4ed6e2245
diff --git a/metagpt/memory/brain_memory.py b/metagpt/memory/brain_memory.py
index baad76562..3b27c2a94 100644
--- a/metagpt/memory/brain_memory.py
+++ b/metagpt/memory/brain_memory.py
@@ -93,8 +93,8 @@ class BrainMemory(pydantic.BaseModel):
return hashlib.md5(text.encode()).hexdigest()
@staticmethod
- async def loads(redis_key: str) -> "BrainMemory":
- redis = Redis()
+ async def loads(redis_key: str, redis_conf: Dict = None) -> "BrainMemory":
+ redis = Redis(conf=redis_conf)
if not redis.is_valid() or not redis_key:
return BrainMemory()
v = await redis.get(key=redis_key)
@@ -103,8 +103,8 @@ class BrainMemory(pydantic.BaseModel):
return BrainMemory(**data)
return BrainMemory()
- async def dumps(self, redis_key: str, timeout_sec: int = 30 * 60):
- redis = Redis()
+ async def dumps(self, redis_key: str, timeout_sec: int = 30 * 60, redis_conf: Dict = None):
+ redis = Redis(conf=redis_conf)
if not redis.is_valid() or not redis_key:
return False
v = self.json()
diff --git a/metagpt/utils/redis.py b/metagpt/utils/redis.py
index ce9d1bc8e..7d1d88fbd 100644
--- a/metagpt/utils/redis.py
+++ b/metagpt/utils/redis.py
@@ -6,7 +6,7 @@
import json
from datetime import timedelta
from enum import Enum
-from typing import Awaitable, Callable, Optional, Union
+from typing import Awaitable, Callable, Dict, Optional, Union
from redis import asyncio as aioredis
@@ -184,8 +184,8 @@ class RedisManager:
class Redis:
- def __init__(self):
- self._config = CONFIG.REDIS
+ def __init__(self, conf: Dict = None):
+ self._config = conf or CONFIG.REDIS
if not self._config:
return
try: