Skip to content

Commit

Permalink
use same timeout on all calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckHend committed Feb 26, 2024
1 parent 0103b2a commit d116c9f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vectorize"
version = "0.11.0"
version = "0.11.1"
edition = "2021"
publish = false

Expand Down
2 changes: 1 addition & 1 deletion Trunk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Empty file.
3 changes: 2 additions & 1 deletion src/transformers/http_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ pub async fn get_model_info(
) -> Result<TransformerMetadata> {
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));
}
Expand Down
5 changes: 3 additions & 2 deletions src/transformers/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -72,6 +72,7 @@ pub fn trim_inputs(inputs: &[Inputs]) -> Vec<String> {

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()
Expand All @@ -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));
Expand Down

0 comments on commit d116c9f

Please sign in to comment.