config_config替换成memory_config
This commit is contained in:
@@ -53,7 +53,7 @@ async def get_emotion_tags(
|
|||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"用户 {current_user.username} 请求获取情绪标签统计",
|
f"用户 {current_user.username} 请求获取情绪标签统计",
|
||||||
extra={
|
extra={
|
||||||
"group_id": request.group_id,
|
"end_user_id": request.end_user_id,
|
||||||
"emotion_type": request.emotion_type,
|
"emotion_type": request.emotion_type,
|
||||||
"start_date": request.start_date,
|
"start_date": request.start_date,
|
||||||
"end_date": request.end_date,
|
"end_date": request.end_date,
|
||||||
@@ -63,7 +63,7 @@ async def get_emotion_tags(
|
|||||||
|
|
||||||
# 调用服务层
|
# 调用服务层
|
||||||
data = await emotion_service.get_emotion_tags(
|
data = await emotion_service.get_emotion_tags(
|
||||||
end_user_id=request.group_id,
|
end_user_id=request.end_user_id,
|
||||||
emotion_type=request.emotion_type,
|
emotion_type=request.emotion_type,
|
||||||
start_date=request.start_date,
|
start_date=request.start_date,
|
||||||
end_date=request.end_date,
|
end_date=request.end_date,
|
||||||
@@ -73,7 +73,7 @@ async def get_emotion_tags(
|
|||||||
api_logger.info(
|
api_logger.info(
|
||||||
"情绪标签统计获取成功",
|
"情绪标签统计获取成功",
|
||||||
extra={
|
extra={
|
||||||
"group_id": request.group_id,
|
"end_user_id": request.end_user_id,
|
||||||
"total_count": data.get("total_count", 0),
|
"total_count": data.get("total_count", 0),
|
||||||
"tags_count": len(data.get("tags", []))
|
"tags_count": len(data.get("tags", []))
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ async def get_emotion_tags(
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(
|
api_logger.error(
|
||||||
f"获取情绪标签统计失败: {str(e)}",
|
f"获取情绪标签统计失败: {str(e)}",
|
||||||
extra={"group_id": request.group_id},
|
extra={"end_user_id": request.end_user_id},
|
||||||
exc_info=True
|
exc_info=True
|
||||||
)
|
)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
@@ -105,7 +105,7 @@ async def get_emotion_wordcloud(
|
|||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"用户 {current_user.username} 请求获取情绪词云数据",
|
f"用户 {current_user.username} 请求获取情绪词云数据",
|
||||||
extra={
|
extra={
|
||||||
"group_id": request.group_id,
|
"end_user_id": request.end_user_id,
|
||||||
"emotion_type": request.emotion_type,
|
"emotion_type": request.emotion_type,
|
||||||
"limit": request.limit
|
"limit": request.limit
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ async def get_emotion_wordcloud(
|
|||||||
|
|
||||||
# 调用服务层
|
# 调用服务层
|
||||||
data = await emotion_service.get_emotion_wordcloud(
|
data = await emotion_service.get_emotion_wordcloud(
|
||||||
end_user_id=request.group_id,
|
end_user_id=request.end_user_id,
|
||||||
emotion_type=request.emotion_type,
|
emotion_type=request.emotion_type,
|
||||||
limit=request.limit
|
limit=request.limit
|
||||||
)
|
)
|
||||||
@@ -121,7 +121,7 @@ async def get_emotion_wordcloud(
|
|||||||
api_logger.info(
|
api_logger.info(
|
||||||
"情绪词云数据获取成功",
|
"情绪词云数据获取成功",
|
||||||
extra={
|
extra={
|
||||||
"group_id": request.group_id,
|
"end_user_id": request.end_user_id,
|
||||||
"total_keywords": data.get("total_keywords", 0)
|
"total_keywords": data.get("total_keywords", 0)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -131,7 +131,7 @@ async def get_emotion_wordcloud(
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(
|
api_logger.error(
|
||||||
f"获取情绪词云数据失败: {str(e)}",
|
f"获取情绪词云数据失败: {str(e)}",
|
||||||
extra={"group_id": request.group_id},
|
extra={"end_user_id": request.end_user_id},
|
||||||
exc_info=True
|
exc_info=True
|
||||||
)
|
)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
@@ -159,21 +159,21 @@ async def get_emotion_health(
|
|||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"用户 {current_user.username} 请求获取情绪健康指数",
|
f"用户 {current_user.username} 请求获取情绪健康指数",
|
||||||
extra={
|
extra={
|
||||||
"group_id": request.group_id,
|
"end_user_id": request.end_user_id,
|
||||||
"time_range": request.time_range
|
"time_range": request.time_range
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# 调用服务层
|
# 调用服务层
|
||||||
data = await emotion_service.calculate_emotion_health_index(
|
data = await emotion_service.calculate_emotion_health_index(
|
||||||
end_user_id=request.group_id,
|
end_user_id=request.end_user_id,
|
||||||
time_range=request.time_range
|
time_range=request.time_range
|
||||||
)
|
)
|
||||||
|
|
||||||
api_logger.info(
|
api_logger.info(
|
||||||
"情绪健康指数获取成功",
|
"情绪健康指数获取成功",
|
||||||
extra={
|
extra={
|
||||||
"group_id": request.group_id,
|
"end_user_id": request.end_user_id,
|
||||||
"health_score": data.get("health_score", 0),
|
"health_score": data.get("health_score", 0),
|
||||||
"level": data.get("level", "未知")
|
"level": data.get("level", "未知")
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ async def get_emotion_health(
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(
|
api_logger.error(
|
||||||
f"获取情绪健康指数失败: {str(e)}",
|
f"获取情绪健康指数失败: {str(e)}",
|
||||||
extra={"group_id": request.group_id},
|
extra={"end_user_id": request.end_user_id},
|
||||||
exc_info=True
|
exc_info=True
|
||||||
)
|
)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
@@ -206,7 +206,7 @@ async def get_emotion_suggestions(
|
|||||||
"""获取个性化情绪建议(从缓存读取)
|
"""获取个性化情绪建议(从缓存读取)
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
request: 包含 group_id 和可选的 config_id
|
request: 包含 end_user_id 和可选的 config_id
|
||||||
db: 数据库会话
|
db: 数据库会话
|
||||||
current_user: 当前用户
|
current_user: 当前用户
|
||||||
|
|
||||||
@@ -217,22 +217,22 @@ async def get_emotion_suggestions(
|
|||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"用户 {current_user.username} 请求获取个性化情绪建议(缓存)",
|
f"用户 {current_user.username} 请求获取个性化情绪建议(缓存)",
|
||||||
extra={
|
extra={
|
||||||
"group_id": request.group_id,
|
"end_user_id": request.end_user_id,
|
||||||
"config_id": request.config_id
|
"config_id": request.config_id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# 从缓存获取建议
|
# 从缓存获取建议
|
||||||
data = await emotion_service.get_cached_suggestions(
|
data = await emotion_service.get_cached_suggestions(
|
||||||
end_user_id=request.group_id,
|
end_user_id=request.end_user_id,
|
||||||
db=db
|
db=db
|
||||||
)
|
)
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
# 缓存不存在或已过期
|
# 缓存不存在或已过期
|
||||||
api_logger.info(
|
api_logger.info(
|
||||||
f"用户 {request.group_id} 的建议缓存不存在或已过期",
|
f"用户 {request.end_user_id} 的建议缓存不存在或已过期",
|
||||||
extra={"group_id": request.group_id}
|
extra={"end_user_id": request.end_user_id}
|
||||||
)
|
)
|
||||||
return fail(
|
return fail(
|
||||||
BizCode.NOT_FOUND,
|
BizCode.NOT_FOUND,
|
||||||
@@ -243,7 +243,7 @@ async def get_emotion_suggestions(
|
|||||||
api_logger.info(
|
api_logger.info(
|
||||||
"个性化建议获取成功(缓存)",
|
"个性化建议获取成功(缓存)",
|
||||||
extra={
|
extra={
|
||||||
"group_id": request.group_id,
|
"end_user_id": request.end_user_id,
|
||||||
"suggestions_count": len(data.get("suggestions", []))
|
"suggestions_count": len(data.get("suggestions", []))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -253,7 +253,7 @@ async def get_emotion_suggestions(
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
api_logger.error(
|
api_logger.error(
|
||||||
f"获取个性化建议失败: {str(e)}",
|
f"获取个性化建议失败: {str(e)}",
|
||||||
extra={"group_id": request.group_id},
|
extra={"end_user_id": request.end_user_id},
|
||||||
exc_info=True
|
exc_info=True
|
||||||
)
|
)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from pydantic import BaseModel, Field
|
|||||||
|
|
||||||
class EmotionTagsRequest(BaseModel):
|
class EmotionTagsRequest(BaseModel):
|
||||||
"""获取情绪标签统计请求"""
|
"""获取情绪标签统计请求"""
|
||||||
group_id: str = Field(..., description="组ID")
|
end_user_id: str = Field(..., description="组ID")
|
||||||
emotion_type: Optional[str] = Field(None, description="情绪类型过滤(joy/sadness/anger/fear/surprise/neutral)")
|
emotion_type: Optional[str] = Field(None, description="情绪类型过滤(joy/sadness/anger/fear/surprise/neutral)")
|
||||||
start_date: Optional[str] = Field(None, description="开始日期(ISO格式,如:2024-01-01)")
|
start_date: Optional[str] = Field(None, description="开始日期(ISO格式,如:2024-01-01)")
|
||||||
end_date: Optional[str] = Field(None, description="结束日期(ISO格式,如:2024-12-31)")
|
end_date: Optional[str] = Field(None, description="结束日期(ISO格式,如:2024-12-31)")
|
||||||
@@ -14,14 +14,14 @@ class EmotionTagsRequest(BaseModel):
|
|||||||
|
|
||||||
class EmotionWordcloudRequest(BaseModel):
|
class EmotionWordcloudRequest(BaseModel):
|
||||||
"""获取情绪词云数据请求"""
|
"""获取情绪词云数据请求"""
|
||||||
group_id: str = Field(..., description="组ID")
|
end_user_id: str = Field(..., description="组ID")
|
||||||
emotion_type: Optional[str] = Field(None, description="情绪类型过滤(joy/sadness/anger/fear/surprise/neutral)")
|
emotion_type: Optional[str] = Field(None, description="情绪类型过滤(joy/sadness/anger/fear/surprise/neutral)")
|
||||||
limit: int = Field(50, ge=1, le=200, description="返回词语数量")
|
limit: int = Field(50, ge=1, le=200, description="返回词语数量")
|
||||||
|
|
||||||
|
|
||||||
class EmotionHealthRequest(BaseModel):
|
class EmotionHealthRequest(BaseModel):
|
||||||
"""获取情绪健康指数请求"""
|
"""获取情绪健康指数请求"""
|
||||||
group_id: str = Field(..., description="组ID")
|
end_user_id: str = Field(..., description="组ID")
|
||||||
time_range: str = Field("30d", description="时间范围(7d/30d/90d)")
|
time_range: str = Field("30d", description="时间范围(7d/30d/90d)")
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ class EmotionHealthRequest(BaseModel):
|
|||||||
|
|
||||||
class EmotionSuggestionsRequest(BaseModel):
|
class EmotionSuggestionsRequest(BaseModel):
|
||||||
"""获取个性化情绪建议请求"""
|
"""获取个性化情绪建议请求"""
|
||||||
group_id: str = Field(..., description="组ID")
|
end_user_id: str = Field(..., description="组ID")
|
||||||
config_id: Optional[int] = Field(None, description="配置ID(用于指定LLM模型)")
|
config_id: Optional[int] = Field(None, description="配置ID(用于指定LLM模型)")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4465
api/uv.lock
generated
4465
api/uv.lock
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user