mirror of
https://github.com/BerriAI/litellm.git
synced 2026-12-02 01:28:38 +00:00
* refactor(rust): rename litellm-core to litellm-inference Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * refactor(rust): expose inference base API for format crates Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(rust): move shared inference test helpers behind test-support 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: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
35 lines
1 KiB
Rust
35 lines
1 KiB
Rust
use std::time::Duration;
|
|
|
|
use litellm_http::outbound::OutboundRequest;
|
|
use litellm_llms::base_llm::auth::Authenticated;
|
|
use serde_json::Value;
|
|
|
|
#[tracing::instrument(
|
|
name = "litellm.provider.send",
|
|
level = "debug",
|
|
skip_all,
|
|
fields(status)
|
|
)]
|
|
pub async fn send(
|
|
request: OutboundRequest,
|
|
client: &litellm_http::Client,
|
|
) -> Result<reqwest::Response, reqwest::Error> {
|
|
request.send(client).await.inspect(|response| {
|
|
tracing::Span::current().record("status", response.status().as_u16());
|
|
})
|
|
}
|
|
|
|
/// Header credentials are already in `headers`; SigV4 is applied here, over the
|
|
/// bytes that are sent.
|
|
pub fn outbound_request(
|
|
authenticated: Authenticated,
|
|
url: String,
|
|
body: &Value,
|
|
timeout: Option<Duration>,
|
|
) -> Result<OutboundRequest, litellm_http::Error> {
|
|
let Authenticated { headers, signer } = authenticated;
|
|
match signer {
|
|
None => OutboundRequest::json(url, headers, body, timeout),
|
|
Some(signer) => OutboundRequest::signed_json(url, headers, body, timeout, &signer),
|
|
}
|
|
}
|