feat(memory): add session-based chat history and user metadata retrieval
- Add ChatSessionCache to manage chat history per session - Add SEARCH_USER_METADATA cypher query for retrieving user entity metadata - Add "str" mode support to StructResponse for raw text extraction - Add content_str field to MemorySearchResult for pre-formatted content - Fix sandbox URL by removing hardcoded port - Add description field to entity search results - Remove history from UserInput schema, use session_id instead
This commit is contained in:
@@ -1296,6 +1296,7 @@ RETURN e.id AS id,
|
||||
e.name AS name,
|
||||
e.end_user_id AS end_user_id,
|
||||
e.entity_type AS entity_type,
|
||||
e.description AS description,
|
||||
COALESCE(e.activation_value, e.importance_score, 0.5) AS activation_value,
|
||||
COALESCE(e.importance_score, 0.5) AS importance_score,
|
||||
e.last_access_time AS last_access_time,
|
||||
@@ -1479,6 +1480,21 @@ ORDER BY score DESC
|
||||
LIMIT $limit
|
||||
"""
|
||||
|
||||
SEARCH_USER_METADATA = """
|
||||
MATCH (n:ExtractedEntity)
|
||||
WHERE (n.end_user_id = $end_user_id AND n.entity_type ='用户')
|
||||
RETURN n.description AS description,
|
||||
n.aliases AS aliases,
|
||||
n.anchors AS anchors,
|
||||
n.beliefs_or_stances AS beliefs_or_stances,
|
||||
n.core_facts AS core_facts,
|
||||
n.events AS events,
|
||||
n.goals AS goals,
|
||||
n.interests AS interests,
|
||||
n.relations AS relations,
|
||||
n.traits AS traits
|
||||
"""
|
||||
|
||||
FULLTEXT_QUERY_CYPHER_MAPPING = {
|
||||
Neo4jNodeType.STATEMENT: SEARCH_STATEMENTS_BY_KEYWORD,
|
||||
Neo4jNodeType.EXTRACTEDENTITY: SEARCH_ENTITIES_BY_NAME_OR_ALIAS,
|
||||
|
||||
Reference in New Issue
Block a user