[fix]Fix the memory interface to use end_user_id.
This commit is contained in:
@@ -122,10 +122,10 @@ def validate_confidence_threshold(threshold: float) -> None:
|
|||||||
raise ValueError("confidence_threshold must be between 0.0 and 1.0")
|
raise ValueError("confidence_threshold must be between 0.0 and 1.0")
|
||||||
|
|
||||||
|
|
||||||
@router.get("/preferences/{user_id}", response_model=ApiResponse)
|
@router.get("/preferences/{end_user_id}", response_model=ApiResponse)
|
||||||
@cur_workspace_access_guard()
|
@cur_workspace_access_guard()
|
||||||
async def get_preference_tags(
|
async def get_preference_tags(
|
||||||
user_id: str,
|
end_user_id: str,
|
||||||
confidence_threshold: float = Query(0.5, ge=0.0, le=1.0, description="Minimum confidence threshold"),
|
confidence_threshold: float = Query(0.5, ge=0.0, le=1.0, description="Minimum confidence threshold"),
|
||||||
tag_category: Optional[str] = Query(None, description="Filter by tag category"),
|
tag_category: Optional[str] = Query(None, description="Filter by tag category"),
|
||||||
start_date: Optional[datetime] = Query(None, description="Filter start date"),
|
start_date: Optional[datetime] = Query(None, description="Filter start date"),
|
||||||
@@ -137,7 +137,7 @@ async def get_preference_tags(
|
|||||||
Get user preference tags from cache.
|
Get user preference tags from cache.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user_id: Target user ID
|
end_user_id: Target end user ID
|
||||||
confidence_threshold: Minimum confidence score (0.0-1.0)
|
confidence_threshold: Minimum confidence score (0.0-1.0)
|
||||||
tag_category: Optional category filter
|
tag_category: Optional category filter
|
||||||
start_date: Optional start date filter
|
start_date: Optional start date filter
|
||||||
@@ -146,20 +146,20 @@ async def get_preference_tags(
|
|||||||
Returns:
|
Returns:
|
||||||
List of preference tags from cache
|
List of preference tags from cache
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Preference tags requested for user: {user_id} (from cache)")
|
api_logger.info(f"Preference tags requested for user: {end_user_id} (from cache)")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Validate inputs
|
# Validate inputs
|
||||||
validate_user_id(user_id)
|
validate_user_id(end_user_id)
|
||||||
|
|
||||||
# Create service with user-specific config
|
# Create service with user-specific config
|
||||||
service = ImplicitMemoryService(db=db, end_user_id=user_id)
|
service = ImplicitMemoryService(db=db, end_user_id=end_user_id)
|
||||||
|
|
||||||
# Get cached profile
|
# Get cached profile
|
||||||
cached_profile = await service.get_cached_profile(end_user_id=user_id, db=db)
|
cached_profile = await service.get_cached_profile(end_user_id=end_user_id, db=db)
|
||||||
|
|
||||||
if cached_profile is None:
|
if cached_profile is None:
|
||||||
api_logger.info(f"用户 {user_id} 的画像缓存不存在或已过期")
|
api_logger.info(f"用户 {end_user_id} 的画像缓存不存在或已过期")
|
||||||
return fail(
|
return fail(
|
||||||
BizCode.NOT_FOUND,
|
BizCode.NOT_FOUND,
|
||||||
"画像缓存不存在或已过期,请右上角刷新生成新画像",
|
"画像缓存不存在或已过期,请右上角刷新生成新画像",
|
||||||
@@ -192,17 +192,17 @@ async def get_preference_tags(
|
|||||||
|
|
||||||
filtered_preferences.append(pref)
|
filtered_preferences.append(pref)
|
||||||
|
|
||||||
api_logger.info(f"Retrieved {len(filtered_preferences)} preference tags for user: {user_id} (from cache)")
|
api_logger.info(f"Retrieved {len(filtered_preferences)} preference tags for user: {end_user_id} (from cache)")
|
||||||
return success(data=filtered_preferences, msg="偏好标签获取成功(缓存)")
|
return success(data=filtered_preferences, msg="偏好标签获取成功(缓存)")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return handle_implicit_memory_error(e, "偏好标签获取", user_id)
|
return handle_implicit_memory_error(e, "偏好标签获取", end_user_id)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/portrait/{user_id}", response_model=ApiResponse)
|
@router.get("/portrait/{end_user_id}", response_model=ApiResponse)
|
||||||
@cur_workspace_access_guard()
|
@cur_workspace_access_guard()
|
||||||
async def get_dimension_portrait(
|
async def get_dimension_portrait(
|
||||||
user_id: str,
|
end_user_id: str,
|
||||||
include_history: bool = Query(False, description="Include historical trends"),
|
include_history: bool = Query(False, description="Include historical trends"),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
current_user: User = Depends(get_current_user)
|
current_user: User = Depends(get_current_user)
|
||||||
@@ -211,26 +211,26 @@ async def get_dimension_portrait(
|
|||||||
Get user's four-dimension personality portrait from cache.
|
Get user's four-dimension personality portrait from cache.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user_id: Target user ID
|
end_user_id: Target end user ID
|
||||||
include_history: Whether to include historical trend data (ignored for cached data)
|
include_history: Whether to include historical trend data (ignored for cached data)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Four-dimension personality portrait from cache
|
Four-dimension personality portrait from cache
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Dimension portrait requested for user: {user_id} (from cache)")
|
api_logger.info(f"Dimension portrait requested for user: {end_user_id} (from cache)")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Validate inputs
|
# Validate inputs
|
||||||
validate_user_id(user_id)
|
validate_user_id(end_user_id)
|
||||||
|
|
||||||
# Create service with user-specific config
|
# Create service with user-specific config
|
||||||
service = ImplicitMemoryService(db=db, end_user_id=user_id)
|
service = ImplicitMemoryService(db=db, end_user_id=end_user_id)
|
||||||
|
|
||||||
# Get cached profile
|
# Get cached profile
|
||||||
cached_profile = await service.get_cached_profile(end_user_id=user_id, db=db)
|
cached_profile = await service.get_cached_profile(end_user_id=end_user_id, db=db)
|
||||||
|
|
||||||
if cached_profile is None:
|
if cached_profile is None:
|
||||||
api_logger.info(f"用户 {user_id} 的画像缓存不存在或已过期")
|
api_logger.info(f"用户 {end_user_id} 的画像缓存不存在或已过期")
|
||||||
return fail(
|
return fail(
|
||||||
BizCode.NOT_FOUND,
|
BizCode.NOT_FOUND,
|
||||||
"画像缓存不存在或已过期,请右上角刷新生成新画像",
|
"画像缓存不存在或已过期,请右上角刷新生成新画像",
|
||||||
@@ -240,17 +240,17 @@ async def get_dimension_portrait(
|
|||||||
# Extract portrait from cache
|
# Extract portrait from cache
|
||||||
portrait = cached_profile.get("portrait", {})
|
portrait = cached_profile.get("portrait", {})
|
||||||
|
|
||||||
api_logger.info(f"Dimension portrait retrieved for user: {user_id} (from cache)")
|
api_logger.info(f"Dimension portrait retrieved for user: {end_user_id} (from cache)")
|
||||||
return success(data=portrait, msg="四维画像获取成功(缓存)")
|
return success(data=portrait, msg="四维画像获取成功(缓存)")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return handle_implicit_memory_error(e, "四维画像获取", user_id)
|
return handle_implicit_memory_error(e, "四维画像获取", end_user_id)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/interest-areas/{user_id}", response_model=ApiResponse)
|
@router.get("/interest-areas/{end_user_id}", response_model=ApiResponse)
|
||||||
@cur_workspace_access_guard()
|
@cur_workspace_access_guard()
|
||||||
async def get_interest_area_distribution(
|
async def get_interest_area_distribution(
|
||||||
user_id: str,
|
end_user_id: str,
|
||||||
include_trends: bool = Query(False, description="Include trend analysis"),
|
include_trends: bool = Query(False, description="Include trend analysis"),
|
||||||
db: Session = Depends(get_db),
|
db: Session = Depends(get_db),
|
||||||
current_user: User = Depends(get_current_user)
|
current_user: User = Depends(get_current_user)
|
||||||
@@ -259,26 +259,26 @@ async def get_interest_area_distribution(
|
|||||||
Get user's interest area distribution from cache.
|
Get user's interest area distribution from cache.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user_id: Target user ID
|
end_user_id: Target end user ID
|
||||||
include_trends: Whether to include trend analysis data (ignored for cached data)
|
include_trends: Whether to include trend analysis data (ignored for cached data)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Interest area distribution from cache
|
Interest area distribution from cache
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Interest area distribution requested for user: {user_id} (from cache)")
|
api_logger.info(f"Interest area distribution requested for user: {end_user_id} (from cache)")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Validate inputs
|
# Validate inputs
|
||||||
validate_user_id(user_id)
|
validate_user_id(end_user_id)
|
||||||
|
|
||||||
# Create service with user-specific config
|
# Create service with user-specific config
|
||||||
service = ImplicitMemoryService(db=db, end_user_id=user_id)
|
service = ImplicitMemoryService(db=db, end_user_id=end_user_id)
|
||||||
|
|
||||||
# Get cached profile
|
# Get cached profile
|
||||||
cached_profile = await service.get_cached_profile(end_user_id=user_id, db=db)
|
cached_profile = await service.get_cached_profile(end_user_id=end_user_id, db=db)
|
||||||
|
|
||||||
if cached_profile is None:
|
if cached_profile is None:
|
||||||
api_logger.info(f"用户 {user_id} 的画像缓存不存在或已过期")
|
api_logger.info(f"用户 {end_user_id} 的画像缓存不存在或已过期")
|
||||||
return fail(
|
return fail(
|
||||||
BizCode.NOT_FOUND,
|
BizCode.NOT_FOUND,
|
||||||
"画像缓存不存在或已过期,请右上角刷新生成新画像",
|
"画像缓存不存在或已过期,请右上角刷新生成新画像",
|
||||||
@@ -288,17 +288,17 @@ async def get_interest_area_distribution(
|
|||||||
# Extract interest areas from cache
|
# Extract interest areas from cache
|
||||||
interest_areas = cached_profile.get("interest_areas", {})
|
interest_areas = cached_profile.get("interest_areas", {})
|
||||||
|
|
||||||
api_logger.info(f"Interest area distribution retrieved for user: {user_id} (from cache)")
|
api_logger.info(f"Interest area distribution retrieved for user: {end_user_id} (from cache)")
|
||||||
return success(data=interest_areas, msg="兴趣领域分布获取成功(缓存)")
|
return success(data=interest_areas, msg="兴趣领域分布获取成功(缓存)")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return handle_implicit_memory_error(e, "兴趣领域分布获取", user_id)
|
return handle_implicit_memory_error(e, "兴趣领域分布获取", end_user_id)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/habits/{user_id}", response_model=ApiResponse)
|
@router.get("/habits/{end_user_id}", response_model=ApiResponse)
|
||||||
@cur_workspace_access_guard()
|
@cur_workspace_access_guard()
|
||||||
async def get_behavior_habits(
|
async def get_behavior_habits(
|
||||||
user_id: str,
|
end_user_id: str,
|
||||||
confidence_level: Optional[str] = Query(None, regex="^(high|medium|low)$", description="Filter by confidence level"),
|
confidence_level: Optional[str] = Query(None, regex="^(high|medium|low)$", description="Filter by confidence level"),
|
||||||
frequency_pattern: Optional[str] = Query(None, regex="^(daily|weekly|monthly|seasonal|occasional|event_triggered)$", description="Filter by frequency pattern"),
|
frequency_pattern: Optional[str] = Query(None, regex="^(daily|weekly|monthly|seasonal|occasional|event_triggered)$", description="Filter by frequency pattern"),
|
||||||
time_period: Optional[str] = Query(None, regex="^(current|past)$", description="Filter by time period"),
|
time_period: Optional[str] = Query(None, regex="^(current|past)$", description="Filter by time period"),
|
||||||
@@ -309,7 +309,7 @@ async def get_behavior_habits(
|
|||||||
Get user's behavioral habits from cache.
|
Get user's behavioral habits from cache.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user_id: Target user ID
|
end_user_id: Target end user ID
|
||||||
confidence_level: Filter by confidence level (high, medium, low)
|
confidence_level: Filter by confidence level (high, medium, low)
|
||||||
frequency_pattern: Filter by frequency pattern (daily, weekly, monthly, seasonal, occasional, event_triggered)
|
frequency_pattern: Filter by frequency pattern (daily, weekly, monthly, seasonal, occasional, event_triggered)
|
||||||
time_period: Filter by time period (current, past)
|
time_period: Filter by time period (current, past)
|
||||||
@@ -317,20 +317,20 @@ async def get_behavior_habits(
|
|||||||
Returns:
|
Returns:
|
||||||
List of behavioral habits from cache
|
List of behavioral habits from cache
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Behavior habits requested for user: {user_id} (from cache)")
|
api_logger.info(f"Behavior habits requested for user: {end_user_id} (from cache)")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Validate inputs
|
# Validate inputs
|
||||||
validate_user_id(user_id)
|
validate_user_id(end_user_id)
|
||||||
|
|
||||||
# Create service with user-specific config
|
# Create service with user-specific config
|
||||||
service = ImplicitMemoryService(db=db, end_user_id=user_id)
|
service = ImplicitMemoryService(db=db, end_user_id=end_user_id)
|
||||||
|
|
||||||
# Get cached profile
|
# Get cached profile
|
||||||
cached_profile = await service.get_cached_profile(end_user_id=user_id, db=db)
|
cached_profile = await service.get_cached_profile(end_user_id=end_user_id, db=db)
|
||||||
|
|
||||||
if cached_profile is None:
|
if cached_profile is None:
|
||||||
api_logger.info(f"用户 {user_id} 的画像缓存不存在或已过期")
|
api_logger.info(f"用户 {end_user_id} 的画像缓存不存在或已过期")
|
||||||
return fail(
|
return fail(
|
||||||
BizCode.NOT_FOUND,
|
BizCode.NOT_FOUND,
|
||||||
"画像缓存不存在或已过期,请右上角刷新生成新画像",
|
"画像缓存不存在或已过期,请右上角刷新生成新画像",
|
||||||
@@ -368,11 +368,11 @@ async def get_behavior_habits(
|
|||||||
|
|
||||||
filtered_habits.append(habit)
|
filtered_habits.append(habit)
|
||||||
|
|
||||||
api_logger.info(f"Retrieved {len(filtered_habits)} behavior habits for user: {user_id} (from cache)")
|
api_logger.info(f"Retrieved {len(filtered_habits)} behavior habits for user: {end_user_id} (from cache)")
|
||||||
return success(data=filtered_habits, msg="行为习惯获取成功(缓存)")
|
return success(data=filtered_habits, msg="行为习惯获取成功(缓存)")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return handle_implicit_memory_error(e, "行为习惯获取", user_id)
|
return handle_implicit_memory_error(e, "行为习惯获取", end_user_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,27 +27,27 @@ router = APIRouter(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/count", response_model=ApiResponse)
|
@router.get("/{end_user_id}/count", response_model=ApiResponse)
|
||||||
def get_memory_count(
|
def get_memory_count(
|
||||||
group_id: uuid.UUID,
|
end_user_id: uuid.UUID,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""Retrieve perceptual memory statistics for a user group.
|
"""Retrieve perceptual memory statistics for a user group.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
group_id: ID of the user group (usually end_user_id in this context)
|
end_user_id: ID of the user group (usually end_user_id in this context)
|
||||||
current_user: Current authenticated user
|
current_user: Current authenticated user
|
||||||
db: Database session
|
db: Database session
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
ApiResponse: Response containing memory count statistics
|
ApiResponse: Response containing memory count statistics
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Fetching perceptual memory statistics: user={current_user.username}, group_id={group_id}")
|
api_logger.info(f"Fetching perceptual memory statistics: user={current_user.username}, end_user_id={end_user_id}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service = MemoryPerceptualService(db)
|
service = MemoryPerceptualService(db)
|
||||||
count_stats = service.get_memory_count(group_id)
|
count_stats = service.get_memory_count(end_user_id)
|
||||||
|
|
||||||
api_logger.info(f"Memory statistics fetched successfully: total={count_stats.get('total', 0)}")
|
api_logger.info(f"Memory statistics fetched successfully: total={count_stats.get('total', 0)}")
|
||||||
|
|
||||||
@@ -57,37 +57,37 @@ def get_memory_count(
|
|||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(f"Failed to fetch memory statistics: group_id={group_id}, error={str(e)}")
|
api_logger.error(f"Failed to fetch memory statistics: end_user_id={end_user_id}, error={str(e)}")
|
||||||
return fail(
|
return fail(
|
||||||
code=BizCode.INTERNAL_ERROR,
|
code=BizCode.INTERNAL_ERROR,
|
||||||
msg="Failed to fetch memory statistics",
|
msg="Failed to fetch memory statistics",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/last_visual", response_model=ApiResponse)
|
@router.get("/{end_user_id}/last_visual", response_model=ApiResponse)
|
||||||
def get_last_visual_memory(
|
def get_last_visual_memory(
|
||||||
group_id: uuid.UUID,
|
end_user_id: uuid.UUID,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""Retrieve the most recent VISION-type memory for a user.
|
"""Retrieve the most recent VISION-type memory for a user.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
group_id: ID of the user group
|
end_user_id: ID of the user group
|
||||||
current_user: Current authenticated user
|
current_user: Current authenticated user
|
||||||
db: Database session
|
db: Database session
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
ApiResponse: Metadata of the latest visual memory
|
ApiResponse: Metadata of the latest visual memory
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Fetching latest visual memory: user={current_user.username}, group_id={group_id}")
|
api_logger.info(f"Fetching latest visual memory: user={current_user.username}, end_user_id={end_user_id}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service = MemoryPerceptualService(db)
|
service = MemoryPerceptualService(db)
|
||||||
visual_memory = service.get_latest_visual_memory(group_id)
|
visual_memory = service.get_latest_visual_memory(end_user_id)
|
||||||
|
|
||||||
if visual_memory is None:
|
if visual_memory is None:
|
||||||
api_logger.info(f"No visual memory found: group_id={group_id}")
|
api_logger.info(f"No visual memory found: end_user_id={end_user_id}")
|
||||||
return success(
|
return success(
|
||||||
data=None,
|
data=None,
|
||||||
msg="No visual memory available"
|
msg="No visual memory available"
|
||||||
@@ -101,37 +101,37 @@ def get_last_visual_memory(
|
|||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(f"Failed to fetch latest visual memory: group_id={group_id}, error={str(e)}")
|
api_logger.error(f"Failed to fetch latest visual memory: end_user_id={end_user_id}, error={str(e)}")
|
||||||
return fail(
|
return fail(
|
||||||
code=BizCode.INTERNAL_ERROR,
|
code=BizCode.INTERNAL_ERROR,
|
||||||
msg="Failed to fetch latest visual memory",
|
msg="Failed to fetch latest visual memory",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/last_listen", response_model=ApiResponse)
|
@router.get("/{end_user_id}/last_listen", response_model=ApiResponse)
|
||||||
def get_last_memory_listen(
|
def get_last_memory_listen(
|
||||||
group_id: uuid.UUID,
|
end_user_id: uuid.UUID,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""Retrieve the most recent AUDIO-type memory for a user.
|
"""Retrieve the most recent AUDIO-type memory for a user.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
group_id: ID of the user group
|
end_user_id: ID of the user group
|
||||||
current_user: Current authenticated user
|
current_user: Current authenticated user
|
||||||
db: Database session
|
db: Database session
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
ApiResponse: Metadata of the latest audio memory
|
ApiResponse: Metadata of the latest audio memory
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Fetching latest audio memory: user={current_user.username}, group_id={group_id}")
|
api_logger.info(f"Fetching latest audio memory: user={current_user.username}, end_user_id={end_user_id}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service = MemoryPerceptualService(db)
|
service = MemoryPerceptualService(db)
|
||||||
audio_memory = service.get_latest_audio_memory(group_id)
|
audio_memory = service.get_latest_audio_memory(end_user_id)
|
||||||
|
|
||||||
if audio_memory is None:
|
if audio_memory is None:
|
||||||
api_logger.info(f"No audio memory found: group_id={group_id}")
|
api_logger.info(f"No audio memory found: end_user_id={end_user_id}")
|
||||||
return success(
|
return success(
|
||||||
data=None,
|
data=None,
|
||||||
msg="No audio memory available"
|
msg="No audio memory available"
|
||||||
@@ -145,38 +145,38 @@ def get_last_memory_listen(
|
|||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(f"Failed to fetch latest audio memory: group_id={group_id}, error={str(e)}")
|
api_logger.error(f"Failed to fetch latest audio memory: end_user_id={end_user_id}, error={str(e)}")
|
||||||
return fail(
|
return fail(
|
||||||
code=BizCode.INTERNAL_ERROR,
|
code=BizCode.INTERNAL_ERROR,
|
||||||
msg="Failed to fetch latest audio memory",
|
msg="Failed to fetch latest audio memory",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/last_text", response_model=ApiResponse)
|
@router.get("/{end_user_id}/last_text", response_model=ApiResponse)
|
||||||
def get_last_text_memory(
|
def get_last_text_memory(
|
||||||
group_id: uuid.UUID,
|
end_user_id: uuid.UUID,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""Retrieve the most recent TEXT-type memory for a user.
|
"""Retrieve the most recent TEXT-type memory for a user.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
group_id: ID of the user group
|
end_user_id: ID of the user group
|
||||||
current_user: Current authenticated user
|
current_user: Current authenticated user
|
||||||
db: Database session
|
db: Database session
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
ApiResponse: Metadata of the latest text memory
|
ApiResponse: Metadata of the latest text memory
|
||||||
"""
|
"""
|
||||||
api_logger.info(f"Fetching latest text memory: user={current_user.username}, group_id={group_id}")
|
api_logger.info(f"Fetching latest text memory: user={current_user.username}, end_user_id={end_user_id}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 调用服务层获取最近的文本记忆
|
# 调用服务层获取最近的文本记忆
|
||||||
service = MemoryPerceptualService(db)
|
service = MemoryPerceptualService(db)
|
||||||
text_memory = service.get_latest_text_memory(group_id)
|
text_memory = service.get_latest_text_memory(end_user_id)
|
||||||
|
|
||||||
if text_memory is None:
|
if text_memory is None:
|
||||||
api_logger.info(f"No text memory found: group_id={group_id}")
|
api_logger.info(f"No text memory found: end_user_id={end_user_id}")
|
||||||
return success(
|
return success(
|
||||||
data=None,
|
data=None,
|
||||||
msg="No text memory available"
|
msg="No text memory available"
|
||||||
@@ -190,16 +190,16 @@ def get_last_text_memory(
|
|||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(f"Failed to fetch latest text memory: group_id={group_id}, error={str(e)}")
|
api_logger.error(f"Failed to fetch latest text memory: end_user_id={end_user_id}, error={str(e)}")
|
||||||
return fail(
|
return fail(
|
||||||
code=BizCode.INTERNAL_ERROR,
|
code=BizCode.INTERNAL_ERROR,
|
||||||
msg="Failed to fetch latest text memory",
|
msg="Failed to fetch latest text memory",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/timeline", response_model=ApiResponse)
|
@router.get("/{end_user_id}/timeline", response_model=ApiResponse)
|
||||||
def get_memory_time_line(
|
def get_memory_time_line(
|
||||||
group_id: uuid.UUID,
|
end_user_id: uuid.UUID,
|
||||||
perceptual_type: Optional[PerceptualType] = Query(None, description="感知类型过滤"),
|
perceptual_type: Optional[PerceptualType] = Query(None, description="感知类型过滤"),
|
||||||
page: int = Query(1, ge=1, description="页码"),
|
page: int = Query(1, ge=1, description="页码"),
|
||||||
page_size: int = Query(10, ge=1, le=100, description="每页大小"),
|
page_size: int = Query(10, ge=1, le=100, description="每页大小"),
|
||||||
@@ -209,7 +209,7 @@ def get_memory_time_line(
|
|||||||
"""Retrieve a timeline of perceptual memories for a user group.
|
"""Retrieve a timeline of perceptual memories for a user group.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
group_id: ID of the user group
|
end_user_id: ID of the user group
|
||||||
perceptual_type: Optional filter for perceptual type
|
perceptual_type: Optional filter for perceptual type
|
||||||
page: Page number for pagination
|
page: Page number for pagination
|
||||||
page_size: Number of items per page
|
page_size: Number of items per page
|
||||||
@@ -221,7 +221,7 @@ def get_memory_time_line(
|
|||||||
"""
|
"""
|
||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"Fetching perceptual memory timeline: user={current_user.username}, "
|
f"Fetching perceptual memory timeline: user={current_user.username}, "
|
||||||
f"group_id={group_id}, type={perceptual_type}, page={page}"
|
f"end_user_id={end_user_id}, type={perceptual_type}, page={page}"
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -232,7 +232,7 @@ def get_memory_time_line(
|
|||||||
)
|
)
|
||||||
|
|
||||||
service = MemoryPerceptualService(db)
|
service = MemoryPerceptualService(db)
|
||||||
timeline_data = service.get_time_line(group_id, query)
|
timeline_data = service.get_time_line(end_user_id, query)
|
||||||
|
|
||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"Perceptual memory timeline retrieved successfully: total={timeline_data.total}, "
|
f"Perceptual memory timeline retrieved successfully: total={timeline_data.total}, "
|
||||||
@@ -246,7 +246,7 @@ def get_memory_time_line(
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(
|
api_logger.error(
|
||||||
f"Failed to fetch perceptual memory timeline: group_id={group_id}, "
|
f"Failed to fetch perceptual memory timeline: end_user_id={end_user_id}, "
|
||||||
f"error={str(e)}"
|
f"error={str(e)}"
|
||||||
)
|
)
|
||||||
return fail(
|
return fail(
|
||||||
|
|||||||
@@ -20,18 +20,18 @@ router = APIRouter(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/count", response_model=ApiResponse)
|
@router.get("/{end_user_id}/count", response_model=ApiResponse)
|
||||||
def get_memory_count(
|
def get_memory_count(
|
||||||
group_id: uuid.UUID,
|
end_user_id: uuid.UUID,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/conversations", response_model=ApiResponse)
|
@router.get("/{end_user_id}/conversations", response_model=ApiResponse)
|
||||||
def get_conversations(
|
def get_conversations(
|
||||||
group_id: uuid.UUID,
|
end_user_id: uuid.UUID,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
@@ -39,7 +39,7 @@ def get_conversations(
|
|||||||
Retrieve all conversations for the current user in a specific group.
|
Retrieve all conversations for the current user in a specific group.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
group_id (UUID): The group identifier.
|
end_user_id (UUID): The group identifier.
|
||||||
current_user (User, optional): The authenticated user.
|
current_user (User, optional): The authenticated user.
|
||||||
db (Session, optional): SQLAlchemy session.
|
db (Session, optional): SQLAlchemy session.
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ def get_conversations(
|
|||||||
"""
|
"""
|
||||||
conversation_service = ConversationService(db)
|
conversation_service = ConversationService(db)
|
||||||
conversations = conversation_service.get_user_conversations(
|
conversations = conversation_service.get_user_conversations(
|
||||||
group_id
|
end_user_id
|
||||||
)
|
)
|
||||||
return success(data=[
|
return success(data=[
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ def get_conversations(
|
|||||||
], msg="get conversations success")
|
], msg="get conversations success")
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/messages", response_model=ApiResponse)
|
@router.get("/{end_user_id}/messages", response_model=ApiResponse)
|
||||||
def get_messages(
|
def get_messages(
|
||||||
conversation_id: uuid.UUID,
|
conversation_id: uuid.UUID,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
@@ -100,7 +100,7 @@ def get_messages(
|
|||||||
return success(data=messages, msg="get conversation history success")
|
return success(data=messages, msg="get conversation history success")
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{group_id}/detail", response_model=ApiResponse)
|
@router.get("/{end_user_id}/detail", response_model=ApiResponse)
|
||||||
async def get_conversation_detail(
|
async def get_conversation_detail(
|
||||||
conversation_id: uuid.UUID,
|
conversation_id: uuid.UUID,
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class PerceptualType(IntEnum):
|
|||||||
CONVERSATION = 4
|
CONVERSATION = 4
|
||||||
|
|
||||||
|
|
||||||
class FileStorageType(IntEnum):
|
class FileStorageService(IntEnum):
|
||||||
LOCAL = 1
|
LOCAL = 1
|
||||||
REMOTE = 2
|
REMOTE = 2
|
||||||
|
|
||||||
|
|||||||
@@ -41,48 +41,48 @@ class MemoryConfigRepository:
|
|||||||
|
|
||||||
# Dialogue count by group
|
# Dialogue count by group
|
||||||
SEARCH_FOR_DIALOGUE = """
|
SEARCH_FOR_DIALOGUE = """
|
||||||
MATCH (n:Dialogue) WHERE n.group_id = $group_id RETURN COUNT(n) AS num
|
MATCH (n:Dialogue) WHERE n.end_user_id = $end_user_id RETURN COUNT(n) AS num
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Chunk count by group
|
# Chunk count by group
|
||||||
SEARCH_FOR_CHUNK = """
|
SEARCH_FOR_CHUNK = """
|
||||||
MATCH (n:Chunk) WHERE n.group_id = $group_id RETURN COUNT(n) AS num
|
MATCH (n:Chunk) WHERE n.end_user_id = $end_user_id RETURN COUNT(n) AS num
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Statement count by group
|
# Statement count by group
|
||||||
SEARCH_FOR_STATEMENT = """
|
SEARCH_FOR_STATEMENT = """
|
||||||
MATCH (n:Statement) WHERE n.group_id = $group_id RETURN COUNT(n) AS num
|
MATCH (n:Statement) WHERE n.end_user_id = $end_user_id RETURN COUNT(n) AS num
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# ExtractedEntity count by group
|
# ExtractedEntity count by group
|
||||||
SEARCH_FOR_ENTITY = """
|
SEARCH_FOR_ENTITY = """
|
||||||
MATCH (n:ExtractedEntity) WHERE n.group_id = $group_id RETURN COUNT(n) AS num
|
MATCH (n:ExtractedEntity) WHERE n.end_user_id = $end_user_id RETURN COUNT(n) AS num
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# All counts by label and total
|
# All counts by label and total
|
||||||
SEARCH_FOR_ALL = """
|
SEARCH_FOR_ALL = """
|
||||||
OPTIONAL MATCH (n:Dialogue) WHERE n.group_id = $group_id RETURN 'Dialogue' AS Label, COUNT(n) AS Count
|
OPTIONAL MATCH (n:Dialogue) WHERE n.end_user_id = $end_user_id RETURN 'Dialogue' AS Label, COUNT(n) AS Count
|
||||||
UNION ALL
|
UNION ALL
|
||||||
OPTIONAL MATCH (n:Chunk) WHERE n.group_id = $group_id RETURN 'Chunk' AS Label, COUNT(n) AS Count
|
OPTIONAL MATCH (n:Chunk) WHERE n.end_user_id = $end_user_id RETURN 'Chunk' AS Label, COUNT(n) AS Count
|
||||||
UNION ALL
|
UNION ALL
|
||||||
OPTIONAL MATCH (n:Statement) WHERE n.group_id = $group_id RETURN 'Statement' AS Label, COUNT(n) AS Count
|
OPTIONAL MATCH (n:Statement) WHERE n.end_user_id = $end_user_id RETURN 'Statement' AS Label, COUNT(n) AS Count
|
||||||
UNION ALL
|
UNION ALL
|
||||||
OPTIONAL MATCH (n:ExtractedEntity) WHERE n.group_id = $group_id RETURN 'ExtractedEntity' AS Label, COUNT(n) AS Count
|
OPTIONAL MATCH (n:ExtractedEntity) WHERE n.end_user_id = $end_user_id RETURN 'ExtractedEntity' AS Label, COUNT(n) AS Count
|
||||||
UNION ALL
|
UNION ALL
|
||||||
OPTIONAL MATCH (n) WHERE n.group_id = $group_id RETURN 'ALL' AS Label, COUNT(n) AS Count
|
OPTIONAL MATCH (n) WHERE n.end_user_id = $end_user_id RETURN 'ALL' AS Label, COUNT(n) AS Count
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Extracted entity details within group/app/user
|
# Extracted entity details within group/app/user
|
||||||
SEARCH_FOR_DETIALS = """
|
SEARCH_FOR_DETIALS = """
|
||||||
MATCH (n:ExtractedEntity)
|
MATCH (n:ExtractedEntity)
|
||||||
WHERE n.group_id = $group_id
|
WHERE n.end_user_id = $end_user_id
|
||||||
RETURN n.entity_idx AS entity_idx,
|
RETURN n.entity_idx AS entity_idx,
|
||||||
n.connect_strength AS connect_strength,
|
n.connect_strength AS connect_strength,
|
||||||
n.description AS description,
|
n.description AS description,
|
||||||
n.entity_type AS entity_type,
|
n.entity_type AS entity_type,
|
||||||
n.name AS name,
|
n.name AS name,
|
||||||
COALESCE(n.fact_summary, '') AS fact_summary,
|
COALESCE(n.fact_summary, '') AS fact_summary,
|
||||||
n.group_id AS group_id,
|
n.end_user_id AS end_user_id,
|
||||||
n.apply_id AS apply_id,
|
n.apply_id AS apply_id,
|
||||||
n.user_id AS user_id,
|
n.user_id AS user_id,
|
||||||
n.id AS id
|
n.id AS id
|
||||||
@@ -91,9 +91,9 @@ class MemoryConfigRepository:
|
|||||||
# Edges between extracted entities within group/app/user
|
# Edges between extracted entities within group/app/user
|
||||||
SEARCH_FOR_EDGES = """
|
SEARCH_FOR_EDGES = """
|
||||||
MATCH (n:ExtractedEntity)-[r]->(m:ExtractedEntity)
|
MATCH (n:ExtractedEntity)-[r]->(m:ExtractedEntity)
|
||||||
WHERE n.group_id = $group_id
|
WHERE n.end_user_id = $end_user_id
|
||||||
RETURN
|
RETURN
|
||||||
r.group_id AS group_id,
|
r.end_user_id AS end_user_id,
|
||||||
r.apply_id AS apply_id,
|
r.apply_id AS apply_id,
|
||||||
r.user_id AS user_id,
|
r.user_id AS user_id,
|
||||||
elementId(r) AS rel_id,
|
elementId(r) AS rel_id,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from sqlalchemy import and_, desc
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app.core.logging_config import get_db_logger
|
from app.core.logging_config import get_db_logger
|
||||||
from app.models.memory_perceptual_model import MemoryPerceptualModel, PerceptualType, FileStorageType
|
from app.models.memory_perceptual_model import MemoryPerceptualModel, PerceptualType, FileStorageService
|
||||||
from app.schemas.memory_perceptual_schema import PerceptualQuerySchema
|
from app.schemas.memory_perceptual_schema import PerceptualQuerySchema
|
||||||
|
|
||||||
db_logger = get_db_logger()
|
db_logger = get_db_logger()
|
||||||
@@ -28,7 +28,7 @@ class MemoryPerceptualRepository:
|
|||||||
file_ext: str,
|
file_ext: str,
|
||||||
summary: Optional[str] = None,
|
summary: Optional[str] = None,
|
||||||
meta_data: Optional[dict] = None,
|
meta_data: Optional[dict] = None,
|
||||||
storage_service: FileStorageType = FileStorageType.LOCAL
|
storage_service: FileStorageService = FileStorageService.LOCAL
|
||||||
|
|
||||||
) -> MemoryPerceptualModel:
|
) -> MemoryPerceptualModel:
|
||||||
|
|
||||||
|
|||||||
@@ -700,7 +700,7 @@ MATCH (ms:MemorySummary {id: e.summary_id, run_id: e.run_id})
|
|||||||
MATCH (c:Chunk {id: e.chunk_id, run_id: e.run_id})
|
MATCH (c:Chunk {id: e.chunk_id, run_id: e.run_id})
|
||||||
MATCH (c)-[:CONTAINS]->(s:Statement {run_id: e.run_id})
|
MATCH (c)-[:CONTAINS]->(s:Statement {run_id: e.run_id})
|
||||||
MERGE (ms)-[r:DERIVED_FROM_STATEMENT]->(s)
|
MERGE (ms)-[r:DERIVED_FROM_STATEMENT]->(s)
|
||||||
SET r.group_id = e.group_id,
|
SET r.end_user_id = e.end_user_id,
|
||||||
r.run_id = e.run_id,
|
r.run_id = e.run_id,
|
||||||
r.created_at = e.created_at,
|
r.created_at = e.created_at,
|
||||||
r.expired_at = e.expired_at
|
r.expired_at = e.expired_at
|
||||||
@@ -729,7 +729,7 @@ FOREACH (rel IN CASE WHEN r IS NOT NULL THEN [r] ELSE [] END |
|
|||||||
source_statement_id: rel.source_statement_id,
|
source_statement_id: rel.source_statement_id,
|
||||||
valid_at: rel.valid_at,
|
valid_at: rel.valid_at,
|
||||||
invalid_at: rel.invalid_at,
|
invalid_at: rel.invalid_at,
|
||||||
group_id: rel.group_id,
|
end_user_id: rel.end_user_id,
|
||||||
user_id: rel.user_id,
|
user_id: rel.user_id,
|
||||||
apply_id: rel.apply_id,
|
apply_id: rel.apply_id,
|
||||||
run_id: rel.run_id,
|
run_id: rel.run_id,
|
||||||
@@ -751,7 +751,7 @@ FOREACH (rel IN CASE WHEN r IS NOT NULL THEN [r] ELSE [] END |
|
|||||||
source_statement_id: rel.source_statement_id,
|
source_statement_id: rel.source_statement_id,
|
||||||
valid_at: rel.valid_at,
|
valid_at: rel.valid_at,
|
||||||
invalid_at: rel.invalid_at,
|
invalid_at: rel.invalid_at,
|
||||||
group_id: rel.group_id,
|
end_user_id: rel.end_user_id,
|
||||||
user_id: rel.user_id,
|
user_id: rel.user_id,
|
||||||
apply_id: rel.apply_id,
|
apply_id: rel.apply_id,
|
||||||
run_id: rel.run_id,
|
run_id: rel.run_id,
|
||||||
|
|||||||
@@ -180,6 +180,6 @@ class DialogRepository(BaseNeo4jRepository[DialogueNode]):
|
|||||||
List[DialogueNode]: 对话列表
|
List[DialogueNode]: 对话列表
|
||||||
"""
|
"""
|
||||||
return await self.find(
|
return await self.find(
|
||||||
{"config_id": config_id, "group_id": group_id},
|
{"config_id": config_id, "end_user_id": end_user_id},
|
||||||
limit=limit
|
limit=limit
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class EmotionRepository:
|
|||||||
try:
|
try:
|
||||||
results = await self.connector.execute_query(
|
results = await self.connector.execute_query(
|
||||||
query,
|
query,
|
||||||
group_id=group_id,
|
end_user_id=end_user_id,
|
||||||
start_date=start_date
|
start_date=start_date
|
||||||
)
|
)
|
||||||
formatted_results = [
|
formatted_results = [
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class MemorySummaryRepository(BaseNeo4jRepository):
|
|||||||
"""
|
"""
|
||||||
# Build keyword search conditions
|
# Build keyword search conditions
|
||||||
keyword_conditions = []
|
keyword_conditions = []
|
||||||
params = {"group_id": group_id, "limit": limit}
|
params = {"end_user_id": group_id, "limit": limit}
|
||||||
|
|
||||||
for i, keyword in enumerate(keywords):
|
for i, keyword in enumerate(keywords):
|
||||||
keyword_conditions.append(f"toLower(n.content) CONTAINS toLower($keyword_{i})")
|
keyword_conditions.append(f"toLower(n.content) CONTAINS toLower($keyword_{i})")
|
||||||
@@ -243,7 +243,7 @@ class MemorySummaryRepository(BaseNeo4jRepository):
|
|||||||
|
|
||||||
query = f"""
|
query = f"""
|
||||||
MATCH (n:{self.node_label})
|
MATCH (n:{self.node_label})
|
||||||
WHERE n.group_id = $group_id
|
WHERE n.end_user_id = $end_user_id
|
||||||
AND ({keyword_filter})
|
AND ({keyword_filter})
|
||||||
RETURN n
|
RETURN n
|
||||||
ORDER BY n.created_at DESC
|
ORDER BY n.created_at DESC
|
||||||
@@ -264,10 +264,10 @@ class MemorySummaryRepository(BaseNeo4jRepository):
|
|||||||
"""
|
"""
|
||||||
query = f"""
|
query = f"""
|
||||||
MATCH (n:{self.node_label})
|
MATCH (n:{self.node_label})
|
||||||
WHERE n.group_id = $group_id
|
WHERE n.end_user_id = $end_user_id
|
||||||
RETURN count(n) as count
|
RETURN count(n) as count
|
||||||
"""
|
"""
|
||||||
|
|
||||||
results = await self.connector.execute_query(query, group_id=group_id)
|
results = await self.connector.execute_query(query, end_user_id=group_id)
|
||||||
return results[0]['count'] if results else 0
|
return results[0]['count'] if results else 0
|
||||||
|
|
||||||
@@ -4,7 +4,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from app.models.memory_perceptual_model import PerceptualType, FileStorageType
|
from app.models.memory_perceptual_model import PerceptualType, FileStorageService
|
||||||
|
|
||||||
|
|
||||||
class PerceptualFilter(BaseModel):
|
class PerceptualFilter(BaseModel):
|
||||||
@@ -38,12 +38,14 @@ class PerceptualMemoryItem(BaseModel):
|
|||||||
"""感知记忆项"""
|
"""感知记忆项"""
|
||||||
id: uuid.UUID = Field(..., description="Unique memory ID")
|
id: uuid.UUID = Field(..., description="Unique memory ID")
|
||||||
perceptual_type: PerceptualType = Field(..., description="Type of perception, e.g., text, audio, or video")
|
perceptual_type: PerceptualType = Field(..., description="Type of perception, e.g., text, audio, or video")
|
||||||
|
storage_service: FileStorageService = Field(..., description="Storage service for file")
|
||||||
file_path: str = Field(..., description="File path in the storage service")
|
file_path: str = Field(..., description="File path in the storage service")
|
||||||
file_ext: str = Field(..., description="File extension")
|
|
||||||
file_name: str = Field(..., description="File name")
|
file_name: str = Field(..., description="File name")
|
||||||
|
file_ext: str = Field(..., description="File extension")
|
||||||
summary: Optional[str] = Field(None, description="summary")
|
summary: Optional[str] = Field(None, description="summary")
|
||||||
storage_type: FileStorageType = Field(..., description="Storage type for file")
|
meta_data: str = Field(...,description="")
|
||||||
created_time: int = Field(..., description="create time")
|
created_time: int = Field(..., description="create time")
|
||||||
|
|
||||||
topic: str = Field(..., description="topic")
|
topic: str = Field(..., description="topic")
|
||||||
domain: str = Field(..., description="domain")
|
domain: str = Field(..., description="domain")
|
||||||
keywords: list[str] = Field(..., description="keywords")
|
keywords: list[str] = Field(..., description="keywords")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
所有的内容是放错误地方了,应该放在models
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Any, Optional, List, Dict, Literal, Union
|
from typing import Any, Optional, List, Dict, Literal, Union
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from sqlalchemy.orm import Session
|
|||||||
from app.core.error_codes import BizCode
|
from app.core.error_codes import BizCode
|
||||||
from app.core.exceptions import BusinessException
|
from app.core.exceptions import BusinessException
|
||||||
from app.core.logging_config import get_business_logger
|
from app.core.logging_config import get_business_logger
|
||||||
from app.models.memory_perceptual_model import PerceptualType, FileStorageType
|
from app.models.memory_perceptual_model import PerceptualType, FileStorageService
|
||||||
from app.repositories.memory_perceptual_repository import MemoryPerceptualRepository
|
from app.repositories.memory_perceptual_repository import MemoryPerceptualRepository
|
||||||
from app.schemas.memory_perceptual_schema import (
|
from app.schemas.memory_perceptual_schema import (
|
||||||
PerceptualQuerySchema,
|
PerceptualQuerySchema,
|
||||||
@@ -92,15 +92,17 @@ class MemoryPerceptualService:
|
|||||||
|
|
||||||
result = {
|
result = {
|
||||||
"id": str(memory.id),
|
"id": str(memory.id),
|
||||||
|
"perceptual_type": perceptual_type,
|
||||||
"file_name": memory.file_name,
|
"file_name": memory.file_name,
|
||||||
"file_path": memory.file_path,
|
"file_path": memory.file_path,
|
||||||
"storage_type": memory.storage_service,
|
"file_ext": memory.file_ext,
|
||||||
|
"storage_service": memory.storage_service,
|
||||||
|
"meta_data": memory.meta_data,
|
||||||
"summary": memory.summary,
|
"summary": memory.summary,
|
||||||
"keywords": content.keywords,
|
"keywords": content.keywords,
|
||||||
"topic": content.topic,
|
"topic": content.topic,
|
||||||
"domain": content.domain,
|
"domain": content.domain,
|
||||||
"created_time": int(memory.created_time.timestamp()*1000),
|
"created_time": int(memory.created_time.timestamp()*1000),
|
||||||
**detail
|
|
||||||
}
|
}
|
||||||
|
|
||||||
business_logger.info(
|
business_logger.info(
|
||||||
@@ -150,7 +152,7 @@ class MemoryPerceptualService:
|
|||||||
domain=content.domain,
|
domain=content.domain,
|
||||||
keywords=content.keywords,
|
keywords=content.keywords,
|
||||||
created_time=int(memory.created_time.timestamp()*1000),
|
created_time=int(memory.created_time.timestamp()*1000),
|
||||||
storage_type=FileStorageType(memory.storage_service),
|
storage_service=FileStorageService(memory.storage_service),
|
||||||
)
|
)
|
||||||
memory_items.append(memory_item)
|
memory_items.append(memory_item)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user