Compare commits

...

4 Commits

Author SHA1 Message Date
Richard Feldman
8998f53222 Drop unused import 2024-09-25 13:56:58 -04:00
Richard Feldman
d84e1244d4 Simplify http timeout defaults 2024-09-25 13:56:58 -04:00
Richard Feldman
8bb7585cab Improve eval error messages 2024-09-25 13:56:58 -04:00
Richard Feldman
9311505e76 Increase HTTP timeouts for evals 2024-09-25 13:56:58 -04:00
4 changed files with 12 additions and 5 deletions

View File

@@ -108,7 +108,7 @@ fn main() -> Result<()> {
.clone()
.spawn(async move {
if let Err(err) = fetch_evaluation_resources(client, &executor).await {
eprintln!("Error: {}", err);
eprintln!("Error fetching eval resources: {}", err);
exit(1);
}
exit(0);
@@ -118,7 +118,7 @@ fn main() -> Result<()> {
Commands::Run { repo } => {
cx.spawn(|mut cx| async move {
if let Err(err) = run_evaluation(repo, &executor, &mut cx).await {
eprintln!("Error: {}", err);
eprintln!("Error running eval: {}", err);
exit(1);
}
exit(0);
@@ -294,8 +294,8 @@ async fn run_evaluation(
.unwrap();
let node_runtime = NodeRuntime::unavailable();
let evaluations = fs::read(&evaluations_path).expect("failed to read evaluations.json");
let evaluations: Vec<EvaluationProject> = serde_json::from_slice(&evaluations).unwrap();
let evaluations = fs::read(&evaluations_path).expect("failed to read evaluations.json - run `cargo run -p evals --bin eval fetch` to fetch evaluations.json.");
let evaluations: Vec<EvaluationProject> = serde_json::from_slice(&evaluations).expect("evaluations.json was not valid JSON. It may have been corrupted; try deleting it and then running `cargo run -p evals --bin eval fetch` to fetch a new copy.");
let embedding_provider = Arc::new(OpenAiEmbeddingProvider::new(
http_client.clone(),
@@ -322,7 +322,7 @@ async fn run_evaluation(
}
eprint!("\r\x1B[2K");
eprint!(
eprintln!(
"Running evals. {}/{} covered. {}/{} overlapped. {}/{} files captured. Project: {}...",
counts.covered_results,
counts.total_results,

View File

@@ -576,6 +576,7 @@ async fn test_extension_store_with_test_extension(cx: &mut TestAppContext) {
std::env::consts::ARCH
)
});
let builder_client = IsahcHttpClient::new(None, Some(user_agent));
let extension_store = cx.new_model(|cx| {

View File

@@ -9,10 +9,13 @@ pub struct IsahcHttpClient(isahc::HttpClient);
pub use http_client::*;
const DEFAULT_HTTP_TIMEOUT: Duration = Duration::from_secs(60);
impl IsahcHttpClient {
pub fn new(proxy: Option<Uri>, user_agent: Option<String>) -> Arc<IsahcHttpClient> {
let mut builder = isahc::HttpClient::builder()
.connect_timeout(Duration::from_secs(5))
.timeout(DEFAULT_HTTP_TIMEOUT)
.low_speed_timeout(100, Duration::from_secs(5))
.proxy(proxy.clone());
if let Some(agent) = user_agent {

View File

@@ -495,6 +495,8 @@ pub struct OpenAiEmbedding {
pub embedding: Vec<f32>,
}
const HTTP_TIMEOUT: Duration = Duration::from_secs(60);
pub fn embed<'a>(
client: &dyn HttpClient,
api_url: &str,
@@ -512,6 +514,7 @@ pub fn embed<'a>(
let request = HttpRequest::builder()
.method(Method::POST)
.uri(uri)
.timeout(HTTP_TIMEOUT)
.header("Content-Type", "application/json")
.header("Authorization", format!("Bearer {}", api_key))
.body(body)