Early return if time budget is already exceeded

This commit is contained in:
ManyTheFish
2025-11-06 11:40:01 +01:00
parent fe1e4814fa
commit 5f69a43846

View File

@@ -77,6 +77,12 @@ impl CohereService {
query: Option<&str>,
time_budget: TimeBudget,
) -> Result<SearchResult, ResponseError> {
if time_budget.exceeded() {
warn!("Could not rerank due to deadline");
// If the deadline is exceeded, return the original search result instead of an error
return Ok(search_result);
}
// Extract user context from personalization
let user_context = personalize.user_context.as_str();
@@ -146,6 +152,7 @@ impl CohereService {
warn!("Cohere rerank attempt #{} failed: {}", attempt, retry.error);
if time_budget.exceeded() {
warn!("Could not rerank due to deadline");
return Err(PersonalizationError::DeadlineExceeded);
} else {
match retry.into_duration(attempt) {