Return timeout early for backlogged embedding requests.

This commit is contained in:
Kishore Nallan 2023-07-18 21:12:50 +05:30
parent 9d7d01f60b
commit 7c55daf07c

View File

@ -1240,6 +1240,14 @@ Option<nlohmann::json> Collection::search(std::string raw_query,
if(!embedder_op.ok()) {
return Option<nlohmann::json>(400, embedder_op.error());
}
auto remote_embedding_timeout_us = remote_embedding_timeout_ms * 1000;
if((std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch()).count() - search_begin_us) > remote_embedding_timeout_us) {
std::string error = "Request timed out.";
return Option<nlohmann::json>(500, error);
}
auto embedder = embedder_op.get();
if(embedder->is_remote()) {