mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +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,
|
||||
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"]
|
||||
if research_mode.upper() not in valid_modes:
|
||||
if normalized_mode not in valid_modes:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=f"research_mode must be one of: {', '.join(valid_modes)}"
|
||||
)
|
||||
|
||||
return research_mode.upper()
|
||||
return normalized_mode
|
||||
|
||||
|
||||
def validate_search_mode(search_mode: Any) -> str:
|
||||
|
|
@ -254,15 +259,20 @@ def validate_search_mode(search_mode: Any) -> str:
|
|||
status_code=400,
|
||||
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"]
|
||||
if search_mode.upper() not in valid_modes:
|
||||
if normalized_mode not in valid_modes:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=f"search_mode must be one of: {', '.join(valid_modes)}"
|
||||
)
|
||||
|
||||
return search_mode.upper()
|
||||
return normalized_mode
|
||||
|
||||
|
||||
def validate_messages(messages: Any) -> list[dict]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue