[changes] 1.Use structured logs;
2.Align the type and default value of "end_user_id" with the semantic meaning of "required".
This commit is contained in:
@@ -664,7 +664,7 @@ async def get_knowledge_type_stats_api(
|
|||||||
|
|
||||||
@router.get("/analytics/interest_distribution/by_user", response_model=ApiResponse)
|
@router.get("/analytics/interest_distribution/by_user", response_model=ApiResponse)
|
||||||
async def get_interest_distribution_by_user_api(
|
async def get_interest_distribution_by_user_api(
|
||||||
end_user_id: Optional[str] = Query(None, description="用户ID(必填)"),
|
end_user_id: str = Query(..., description="用户ID(必填)"),
|
||||||
limit: int = Query(5, le=5, description="返回兴趣标签数量限制,最多5个"),
|
limit: int = Query(5, le=5, description="返回兴趣标签数量限制,最多5个"),
|
||||||
language_type: str = Header(default=None, alias="X-Language-Type"),
|
language_type: str = Header(default=None, alias="X-Language-Type"),
|
||||||
current_user: User = Depends(get_current_user),
|
current_user: User = Depends(get_current_user),
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
from app.core.memory.utils.llm.llm_utils import MemoryClientFactory
|
from app.core.memory.utils.llm.llm_utils import MemoryClientFactory
|
||||||
from app.db import get_db_context
|
from app.db import get_db_context
|
||||||
from app.repositories.neo4j.neo4j_connector import Neo4jConnector
|
from app.repositories.neo4j.neo4j_connector import Neo4jConnector
|
||||||
@@ -89,7 +92,7 @@ async def filter_tags_with_llm(tags: List[str], end_user_id: str) -> List[str]:
|
|||||||
return structured_response.meaningful_tags
|
return structured_response.meaningful_tags
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"LLM筛选过程中发生错误: {e}")
|
logger.error(f"LLM筛选过程中发生错误: {e}", exc_info=True)
|
||||||
# 在LLM失败时返回原始标签,确保流程继续
|
# 在LLM失败时返回原始标签,确保流程继续
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
@@ -153,7 +156,7 @@ async def filter_interests_with_llm(tags: List[str], end_user_id: str, language:
|
|||||||
return structured_response.interest_tags
|
return structured_response.interest_tags
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"兴趣标签LLM筛选过程中发生错误: {e}")
|
logger.error(f"兴趣标签LLM筛选过程中发生错误: {e}", exc_info=True)
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user