refac: web search error handling

This commit is contained in:
Timothy Jaeryang Baek 2025-10-07 12:15:24 -05:00
parent 7d205b1711
commit 53e98620bf

View file

@ -201,9 +201,13 @@ def get_rf(
eos = getattr(cfg, "eos_token_id", None) eos = getattr(cfg, "eos_token_id", None)
if eos is not None: if eos is not None:
cfg.pad_token_id = eos cfg.pad_token_id = eos
log.debug(f"Missing pad_token_id detected; set to eos_token_id={eos}") log.debug(
f"Missing pad_token_id detected; set to eos_token_id={eos}"
)
else: else:
log.warning("Neither pad_token_id nor eos_token_id present in model config") log.warning(
"Neither pad_token_id nor eos_token_id present in model config"
)
except Exception as e2: except Exception as e2:
log.warning(f"Failed to adjust pad_token_id on CrossEncoder: {e2}") log.warning(f"Failed to adjust pad_token_id on CrossEncoder: {e2}")
@ -2064,6 +2068,12 @@ async def process_web_search(
detail=ERROR_MESSAGES.WEB_SEARCH_ERROR(e), detail=ERROR_MESSAGES.WEB_SEARCH_ERROR(e),
) )
if len(urls) == 0:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=ERROR_MESSAGES.DEFAULT("No results found from web search"),
)
try: try:
if request.app.state.config.BYPASS_WEB_SEARCH_WEB_LOADER: if request.app.state.config.BYPASS_WEB_SEARCH_WEB_LOADER:
search_results = [ search_results = [