mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-14 15:25:17 +02:00
feat: +code
This commit is contained in:
parent
41e90b4f48
commit
26c4ed6e22
2 changed files with 7 additions and 7 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue