mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-14 22:52:15 +02:00
fix trim mode values before validating
This commit is contained in:
parent
d1f21a8dc6
commit
a13a0594b8
1 changed files with 18 additions and 8 deletions
|
|
@ -222,15 +222,20 @@ def validate_research_mode(research_mode: Any) -> str:
|
||||||
status_code=400,
|
status_code=400,
|
||||||
detail="research_mode must be a string"
|
detail="research_mode must be a string"
|
||||||
)
|
)
|
||||||
|
normalized_mode = research_mode.strip().upper()
|
||||||
|
if not normalized_mode:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail="research_mode cannot be empty"
|
||||||
|
)
|
||||||
|
|
||||||
valid_modes = ["GENERAL", "DEEP", "DEEPER", "QNA"]
|
valid_modes = ["GENERAL", "DEEP", "DEEPER", "QNA"]
|
||||||
if research_mode.upper() not in valid_modes:
|
if normalized_mode not in valid_modes:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
detail=f"research_mode must be one of: {', '.join(valid_modes)}"
|
detail=f"research_mode must be one of: {', '.join(valid_modes)}"
|
||||||
)
|
)
|
||||||
|
return normalized_mode
|
||||||
return research_mode.upper()
|
|
||||||
|
|
||||||
|
|
||||||
def validate_search_mode(search_mode: Any) -> str:
|
def validate_search_mode(search_mode: Any) -> str:
|
||||||
|
|
@ -254,15 +259,20 @@ def validate_search_mode(search_mode: Any) -> str:
|
||||||
status_code=400,
|
status_code=400,
|
||||||
detail="search_mode must be a string"
|
detail="search_mode must be a string"
|
||||||
)
|
)
|
||||||
|
normalized_mode = search_mode.strip().upper()
|
||||||
|
if not normalized_mode:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail="search_mode cannot be empty"
|
||||||
|
)
|
||||||
|
|
||||||
valid_modes = ["CHUNKS", "DOCUMENTS"]
|
valid_modes = ["CHUNKS", "DOCUMENTS"]
|
||||||
if search_mode.upper() not in valid_modes:
|
if normalized_mode not in valid_modes:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
detail=f"search_mode must be one of: {', '.join(valid_modes)}"
|
detail=f"search_mode must be one of: {', '.join(valid_modes)}"
|
||||||
)
|
)
|
||||||
|
return normalized_mode
|
||||||
return search_mode.upper()
|
|
||||||
|
|
||||||
|
|
||||||
def validate_messages(messages: Any) -> list[dict]:
|
def validate_messages(messages: Any) -> list[dict]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue