mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-11-22 04:36:32 +00:00
Early return if time budget is already exceeded
This commit is contained in:
@@ -77,6 +77,12 @@ impl CohereService {
|
|||||||
query: Option<&str>,
|
query: Option<&str>,
|
||||||
time_budget: TimeBudget,
|
time_budget: TimeBudget,
|
||||||
) -> Result<SearchResult, ResponseError> {
|
) -> 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
|
// Extract user context from personalization
|
||||||
let user_context = personalize.user_context.as_str();
|
let user_context = personalize.user_context.as_str();
|
||||||
|
|
||||||
@@ -146,6 +152,7 @@ impl CohereService {
|
|||||||
warn!("Cohere rerank attempt #{} failed: {}", attempt, retry.error);
|
warn!("Cohere rerank attempt #{} failed: {}", attempt, retry.error);
|
||||||
|
|
||||||
if time_budget.exceeded() {
|
if time_budget.exceeded() {
|
||||||
|
warn!("Could not rerank due to deadline");
|
||||||
return Err(PersonalizationError::DeadlineExceeded);
|
return Err(PersonalizationError::DeadlineExceeded);
|
||||||
} else {
|
} else {
|
||||||
match retry.into_duration(attempt) {
|
match retry.into_duration(attempt) {
|
||||||
|
|||||||
Reference in New Issue
Block a user