refactor(memory): consolidate write pipeline and rename statement extraction step
- Rename StatementExtractionStep → StatementTemporalExtractionStep and extract_statement.jinja2 → extract_statement_temporal.jinja2 to reflect merged temporal extraction logic - Move extraction_pipeline_orchestrator.py out of steps/ to engine root - Move dedup_step.py into steps/ directory - Introduce WriteMemoryRequest schema to replace positional args in write_memory() - Extract _resolve_and_load_config, _preprocess_files, _write_neo4j, and _invalidate_interest_cache as private helpers in MemoryAgentService - Remove shadow pipeline and simplify NEW_PIPELINE_ENABLED branch - Merge 类型归属/成员隶属/任职服务 relation types into single 归属身份关系 in triplet prompt - Add alias merge logic (别名属于) in deduplication and MERGE_ALIAS_BELONGS_TO Cypher query - Add StorageType, Language, MessageItem enums/models to memory_agent_schema - Reduce AgentMemory_Long_Term.DEFAULT_SCOPE from 6 to 1 - Delete standalone extract_temporal.jinja2 (logic merged into statement step)
This commit is contained in:
@@ -1,9 +1,32 @@
|
||||
from abc import ABC
|
||||
from typing import Optional
|
||||
from enum import Enum
|
||||
from typing import Any, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class StorageType(str, Enum):
|
||||
"""记忆存储后端类型"""
|
||||
NEO4J = "neo4j"
|
||||
RAG = "rag"
|
||||
|
||||
|
||||
class Language(str, Enum): # 没有传递到聚类的celery任务中去,任务会回退失败用默认值,考虑统一语言问题
|
||||
"""支持的语言"""
|
||||
ZH = "zh"
|
||||
EN = "en"
|
||||
|
||||
|
||||
class MessageItem(BaseModel):
|
||||
"""单条消息结构"""
|
||||
role: str
|
||||
content: str
|
||||
files: Optional[list[dict]] = None
|
||||
file_content: Optional[list[Any]] = None
|
||||
|
||||
model_config = {"extra": "allow"}
|
||||
|
||||
|
||||
class UserInput(BaseModel):
|
||||
message: str
|
||||
history: list[dict]
|
||||
@@ -18,6 +41,16 @@ class Write_UserInput(BaseModel):
|
||||
config_id: Optional[str] = None
|
||||
|
||||
|
||||
class WriteMemoryRequest(BaseModel):
|
||||
"""write_memory() 的参数封装"""
|
||||
end_user_id: str
|
||||
messages: list[MessageItem]
|
||||
config_id: Optional[Any] = None
|
||||
storage_type: StorageType = StorageType.NEO4J
|
||||
user_rag_memory_id: str = ""
|
||||
language: Language = Language.ZH
|
||||
|
||||
|
||||
class AgentMemory_Long_Term(ABC):
|
||||
"""长期记忆配置常量"""
|
||||
STORAGE_NEO4J = "neo4j"
|
||||
@@ -25,7 +58,7 @@ class AgentMemory_Long_Term(ABC):
|
||||
STRATEGY_AGGREGATE = "aggregate"
|
||||
STRATEGY_CHUNK = "chunk"
|
||||
STRATEGY_TIME = "time"
|
||||
DEFAULT_SCOPE = 6
|
||||
DEFAULT_SCOPE = 1
|
||||
TIME_SCOPE = 5
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user