assistant: Remove low_speed_timeout
(#20681)
This removes the `low_speed_timeout` setting from all providers as a response to issue #19509. Reason being that the original `low_speed_timeout` was only as part of #9913 because users wanted to _get rid of timeouts_. They wanted to bump the default timeout from 5sec to a lot more. Then, in the meantime, the meaning of `low_speed_timeout` changed in #19055 and was changed to a normal `timeout`, which is a different thing and breaks slower LLMs that don't reply with a complete response in the configured timeout. So we figured: let's remove the whole thing and replace it with a default _connect_ timeout to make sure that we can connect to a server in 10s, but then give the server as long as it wants to complete its response. Closes #19509 Release Notes: - Removed the `low_speed_timeout` setting from LLM provider settings, since it was only used to _increase_ the timeout to give LLMs more time, but since we don't have any other use for it, we simply remove the setting to give LLMs as long as they need. --------- Co-authored-by: Antonio <antonio@zed.dev> Co-authored-by: Peter Tripp <peter@zed.dev>
This commit is contained in:
parent
c9546070ac
commit
aee01f2c50
19 changed files with 109 additions and 345 deletions
|
@ -1,9 +1,9 @@
|
|||
use std::{any::type_name, mem, pin::Pin, sync::OnceLock, task::Poll};
|
||||
use std::{any::type_name, mem, pin::Pin, sync::OnceLock, task::Poll, time::Duration};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use futures::{AsyncRead, TryStreamExt as _};
|
||||
use http_client::{http, ReadTimeout, RedirectPolicy};
|
||||
use http_client::{http, RedirectPolicy};
|
||||
use reqwest::{
|
||||
header::{HeaderMap, HeaderValue},
|
||||
redirect,
|
||||
|
@ -20,9 +20,14 @@ pub struct ReqwestClient {
|
|||
}
|
||||
|
||||
impl ReqwestClient {
|
||||
pub fn new() -> Self {
|
||||
fn builder() -> reqwest::ClientBuilder {
|
||||
reqwest::Client::builder()
|
||||
.use_rustls_tls()
|
||||
.connect_timeout(Duration::from_secs(10))
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
Self::builder()
|
||||
.build()
|
||||
.expect("Failed to initialize HTTP client")
|
||||
.into()
|
||||
|
@ -31,19 +36,14 @@ impl ReqwestClient {
|
|||
pub fn user_agent(agent: &str) -> anyhow::Result<Self> {
|
||||
let mut map = HeaderMap::new();
|
||||
map.insert(http::header::USER_AGENT, HeaderValue::from_str(agent)?);
|
||||
let client = reqwest::Client::builder()
|
||||
.default_headers(map)
|
||||
.use_rustls_tls()
|
||||
.build()?;
|
||||
let client = Self::builder().default_headers(map).build()?;
|
||||
Ok(client.into())
|
||||
}
|
||||
|
||||
pub fn proxy_and_user_agent(proxy: Option<http::Uri>, agent: &str) -> anyhow::Result<Self> {
|
||||
let mut map = HeaderMap::new();
|
||||
map.insert(http::header::USER_AGENT, HeaderValue::from_str(agent)?);
|
||||
let mut client = reqwest::Client::builder()
|
||||
.use_rustls_tls()
|
||||
.default_headers(map);
|
||||
let mut client = Self::builder().default_headers(map);
|
||||
if let Some(proxy) = proxy.clone().and_then(|proxy_uri| {
|
||||
reqwest::Proxy::all(proxy_uri.to_string())
|
||||
.inspect_err(|e| log::error!("Failed to parse proxy URI {}: {}", proxy_uri, e))
|
||||
|
@ -204,9 +204,6 @@ impl http_client::HttpClient for ReqwestClient {
|
|||
RedirectPolicy::FollowAll => redirect::Policy::limited(100),
|
||||
});
|
||||
}
|
||||
if let Some(ReadTimeout(timeout)) = parts.extensions.get::<ReadTimeout>() {
|
||||
request = request.timeout(*timeout);
|
||||
}
|
||||
let request = request.body(match body.0 {
|
||||
http_client::Inner::Empty => reqwest::Body::default(),
|
||||
http_client::Inner::Bytes(cursor) => cursor.into_inner().into(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue