mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-02 01:28:38 +00:00
* refactor(messages): take the provider client from the injected HTTP pool The messages route kept its own process-wide reqwest client, so it ignored ssl_verify, CA bundles, client certs, proxies and every other setting that litellm-http resolves. The machine now takes the HttpClientPool and the call's HttpClientConfig, as OCR does, and the bridge passes its shared pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(http): hand out an owned Client and move chat, audio and OIDC onto the pool HttpClientPool now returns litellm_http::Client, a newtype only crates/http can build, so every provider client carries the resolved TLS, proxy and timeout settings. Chat completions and audio transcription drop their process-wide reqwest clients and take the pool and call config like messages; their 600s ceiling moves to the request. OidcResolver takes its client instead of building one, and the bridge hands it the pooled one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(secrets): build Google, Azure and CyberArk manager clients from the pool The native secret managers built bare reqwest clients, so they ignored the host's TLS and proxy settings. load_native_manager now takes the pool and the host config and hands each manager a pooled client. CyberArk's CYBERARK_SSL_VERIFY and CYBERARK_CLIENT_CERT/KEY become an override on the host config instead of a hand-built client. To express a certificate and key in separate files, HttpClientConfig::client_certificate is now a ClientIdentity that is either one PEM or a split pair. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(clippy): only crates/http may build a reqwest client Fence reqwest::Client, ClientBuilder and the TLS builder methods with disallowed-types and disallowed-methods so new code takes a litellm_http::Client from the pool. crates/http is exempt as the one place clients are built, and testkit as a dev-only installer. Tests move to litellm_http::Client::plain_for_test or a pooled client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(secrets-cyberark): keep verifying certificates when the host disables it Python hands CyberArk its own ssl_verify, which wins over the global setting, so CYBERARK_SSL_VERIFY unset or true still verifies even when the host sets ssl_verify false. The pooled client copied the host's Disabled and would send the API key unverified; fall back to the built-in roots instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(python-bridge): treat a missing litellm package as no host HTTP settings Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Yujong Lee <yujong@berri.ai> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
90 lines
2.5 KiB
Rust
90 lines
2.5 KiB
Rust
use std::sync::Arc;
|
|
|
|
use azure_core::http::{ClientOptions, Transport};
|
|
use litellm_cache::{BaseCache, ExactCacheContext, JsonCodec};
|
|
use litellm_cache_azure_blob::{AzureBlobCache, ReqwestTransport};
|
|
use rstest::{fixture, rstest};
|
|
use serde_json::{Value, json};
|
|
use tokio::runtime::Handle;
|
|
use wiremock::{
|
|
Mock, MockServer, ResponseTemplate,
|
|
matchers::{body_json, header, method, path, query_param},
|
|
};
|
|
|
|
#[fixture]
|
|
async fn server() -> MockServer {
|
|
let server = MockServer::start().await;
|
|
Mock::given(method("PUT"))
|
|
.and(path("/litellm-cache"))
|
|
.and(query_param("restype", "container"))
|
|
.respond_with(ResponseTemplate::new(201))
|
|
.expect(1)
|
|
.mount(&server)
|
|
.await;
|
|
server
|
|
}
|
|
|
|
async fn connect(server: &MockServer) -> AzureBlobCache<JsonCodec<Value>> {
|
|
AzureBlobCache::connect_with_options(
|
|
&server.uri(),
|
|
"litellm-cache",
|
|
None,
|
|
ClientOptions {
|
|
transport: Some(Transport::new(Arc::new(ReqwestTransport(
|
|
litellm_http::Client::plain_for_test(),
|
|
)))),
|
|
..ClientOptions::default()
|
|
},
|
|
JsonCodec::new(),
|
|
Handle::current(),
|
|
)
|
|
.await
|
|
.unwrap()
|
|
}
|
|
|
|
#[rstest]
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
async fn uploads_go_through_the_host_client(#[future(awt)] server: MockServer) {
|
|
Mock::given(method("PUT"))
|
|
.and(path("/litellm-cache/key"))
|
|
.and(header("if-none-match", "*"))
|
|
.and(body_json(json!({"answer": 1})))
|
|
.respond_with(ResponseTemplate::new(201))
|
|
.expect(1)
|
|
.mount(&server)
|
|
.await;
|
|
connect(&server)
|
|
.await
|
|
.set_cache("key", json!({"answer": 1}), &ExactCacheContext::default())
|
|
.unwrap();
|
|
}
|
|
|
|
#[rstest]
|
|
#[case::hit(
|
|
ResponseTemplate::new(200).set_body_json(json!({"answer": 2})),
|
|
Some(json!({"answer": 2}))
|
|
)]
|
|
#[case::blob_not_found(
|
|
ResponseTemplate::new(404).insert_header("x-ms-error-code", "BlobNotFound"),
|
|
None
|
|
)]
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
async fn downloads_map_the_host_client_response(
|
|
#[future(awt)] server: MockServer,
|
|
#[case] response: ResponseTemplate,
|
|
#[case] expected: Option<Value>,
|
|
) {
|
|
Mock::given(method("GET"))
|
|
.and(path("/litellm-cache/key"))
|
|
.respond_with(response)
|
|
.mount(&server)
|
|
.await;
|
|
assert_eq!(
|
|
connect(&server)
|
|
.await
|
|
.async_get_cache("key", &ExactCacheContext::default())
|
|
.await
|
|
.unwrap(),
|
|
expected
|
|
);
|
|
}
|