diff --git a/Cargo.lock b/Cargo.lock index c51efd6..62261ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2995,7 +2995,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vectorize" -version = "0.11.0" +version = "0.11.1" dependencies = [ "anyhow", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 819d3ec..19e92d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vectorize" -version = "0.11.0" +version = "0.11.1" edition = "2021" publish = false diff --git a/Trunk.toml b/Trunk.toml index fea22cb..68d43f2 100644 --- a/Trunk.toml +++ b/Trunk.toml @@ -6,7 +6,7 @@ description = "The simplest way to orchestrate vector search on Postgres." homepage = "https://github.com/tembo-io/pg_vectorize" documentation = "https://github.com/tembo-io/pg_vectorize" categories = ["orchestration", "machine_learning"] -version = "0.11.0" +version = "0.11.1" [build] postgres_version = "15" diff --git a/sql/vectorize--0.11.0--0.11.1.sql b/sql/vectorize--0.11.0--0.11.1.sql new file mode 100644 index 0000000..e69de29 diff --git a/src/transformers/http_handler.rs b/src/transformers/http_handler.rs index 067800e..dcb5f36 100644 --- a/src/transformers/http_handler.rs +++ b/src/transformers/http_handler.rs @@ -94,11 +94,12 @@ pub async fn get_model_info( ) -> Result { let svc_url = get_generic_svc_url()?; let info_url = svc_url.replace("/embeddings", "/info"); + let timeout = EMBEDDING_REQ_TIMEOUT_SEC.get(); let client = reqwest::Client::new(); let mut req = client .get(info_url) .query(&[("model_name", model_name)]) - .timeout(std::time::Duration::from_secs(5)); // model info must always be fast + .timeout(std::time::Duration::from_secs(timeout as u64)); if let Some(key) = api_key { req = req.header("Authorization", format!("Bearer {}", key)); } diff --git a/src/transformers/openai.rs b/src/transformers/openai.rs index 494119f..83b59a3 100644 --- a/src/transformers/openai.rs +++ b/src/transformers/openai.rs @@ -4,7 +4,7 @@ use anyhow::Result; use crate::{ executor::VectorizeMeta, - guc::OPENAI_KEY, + guc::{EMBEDDING_REQ_TIMEOUT_SEC, OPENAI_KEY}, transformers::{ http_handler::handle_response, types::{EmbeddingPayload, EmbeddingRequest, Inputs}, @@ -72,6 +72,7 @@ pub fn trim_inputs(inputs: &[Inputs]) -> Vec { pub fn validate_api_key(key: &str) -> Result<()> { let client = reqwest::Client::new(); + let timeout = EMBEDDING_REQ_TIMEOUT_SEC.get(); let runtime = tokio::runtime::Builder::new_current_thread() .enable_io() .enable_time() @@ -82,7 +83,7 @@ pub fn validate_api_key(key: &str) -> Result<()> { .get("https://api.openai.com/v1/models") .header("Content-Type", "application/json") .header("Authorization", format!("Bearer {}", key)) - .timeout(std::time::Duration::from_secs(5)) // api validation should be fast + .timeout(std::time::Duration::from_secs(timeout as u64)) .send() .await .unwrap_or_else(|e| error!("failed to make Open AI key validation call: {}", e));