|
|
@@ -1,5 +1,5 @@
|
|
|
from fastapi import APIRouter, HTTPException
|
|
|
-from pydantic import BaseModel
|
|
|
+from pydantic import BaseModel, ConfigDict
|
|
|
from typing import Optional
|
|
|
from app.graphs.chat_graph import create_chat_graph
|
|
|
from app.graphs.analysis_graph import create_analysis_graph
|
|
|
@@ -16,6 +16,8 @@ class DifyMessage(BaseModel):
|
|
|
content: str
|
|
|
|
|
|
class DifyChatRequest(BaseModel):
|
|
|
+ # 前端 userId/conversationId 可能为数字,允许 int/float 自动转 str,避免 422
|
|
|
+ model_config = ConfigDict(coerce_numbers_to_str=True)
|
|
|
query: str = ""
|
|
|
user: str = "anonymous"
|
|
|
conversation_id: str = ""
|
|
|
@@ -26,10 +28,13 @@ class DifyChatRequest(BaseModel):
|
|
|
bot_name: str = "AI管家"
|
|
|
|
|
|
class DifyAnalysisRequest(BaseModel):
|
|
|
+ # 前端 userId 可能为数字,允许 int/float 自动转 str,避免 422
|
|
|
+ model_config = ConfigDict(coerce_numbers_to_str=True)
|
|
|
report_id: Optional[int] = None
|
|
|
user_id: Optional[str] = None
|
|
|
focus: Optional[str] = None
|
|
|
messages: list[DifyMessage] = []
|
|
|
+ inputs: dict = {}
|
|
|
|
|
|
class DifyChoice(BaseModel):
|
|
|
index: int
|