* 新增 MemoryGatewayConfig 和 MemoryConfig dataclass,用于配置管理。 * 实现 MemoryGatewayUserCredential 和 MemoryGatewayCredentialStore,用于处理用户凭据。 * 创建 MemoryGatewayService,用于管理与 Memory Gateway 的交互。 * 开发用于记忆设置的 JSON 配置文件。 * 增强单元测试,覆盖新功能,包括凭据存储和服务行为。 * 更新 entrypoint 和实例创建脚本,以初始化 Memory Gateway 用户存储。
33 lines
828 B
Python
33 lines
828 B
Python
"""Configuration models for the Memory Gateway layer."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class MemoryGatewayConfig:
|
|
"""Shared non-secret Memory Gateway settings."""
|
|
|
|
base_url: str = ""
|
|
app_id: str = "default"
|
|
project_id: str = "default"
|
|
scope: list[str] = field(
|
|
default_factory=lambda: ["current_chat", "resources", "all_user_memory"]
|
|
)
|
|
top_k: int = 8
|
|
timeout_seconds: float = 10.0
|
|
|
|
@property
|
|
def is_configured(self) -> bool:
|
|
return bool(self.base_url.strip())
|
|
|
|
|
|
@dataclass(slots=True)
|
|
class MemoryConfig:
|
|
"""Curated baseline plus optional Memory Gateway layer."""
|
|
|
|
mode: str = "hybrid"
|
|
explicit: bool = False
|
|
gateway: MemoryGatewayConfig = field(default_factory=MemoryGatewayConfig)
|