mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
refactor(rust): extract inference-testing crate (#44873)
Move the shared test helpers out of litellm-inference's test-support feature into a publish = false litellm-inference-testing crate used only as a dev dependency by the format crates. Also drop the dead src/constants.rs (OPENAI_DEFAULT_API_BASE had no users) and declare the litellm-http/litellm-llms test-support features on the crates that actually use them instead of relying on feature unification through litellm-inference's dev-dependencies. Co-authored-by: Yujong Lee <yujong@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
eb385cca3e
commit
878ba39e7c
27 changed files with 54 additions and 32 deletions
16
litellm-rust/Cargo.lock
generated
16
litellm-rust/Cargo.lock
generated
|
|
@ -4013,7 +4013,6 @@ dependencies = [
|
|||
"litellm-framer",
|
||||
"litellm-host",
|
||||
"litellm-http",
|
||||
"litellm-inference",
|
||||
"litellm-llms",
|
||||
"litellm-secrets",
|
||||
"litellm-tracing",
|
||||
|
|
@ -4042,6 +4041,7 @@ dependencies = [
|
|||
"litellm-host-native",
|
||||
"litellm-http",
|
||||
"litellm-inference",
|
||||
"litellm-inference-testing",
|
||||
"litellm-llms",
|
||||
"litellm-llms-types",
|
||||
"litellm-secrets",
|
||||
|
|
@ -4068,6 +4068,7 @@ dependencies = [
|
|||
"litellm-host-native",
|
||||
"litellm-http",
|
||||
"litellm-inference",
|
||||
"litellm-inference-testing",
|
||||
"litellm-llms",
|
||||
"litellm-llms-types",
|
||||
"litellm-secrets",
|
||||
|
|
@ -4096,6 +4097,7 @@ dependencies = [
|
|||
"litellm-host-native",
|
||||
"litellm-http",
|
||||
"litellm-inference",
|
||||
"litellm-inference-testing",
|
||||
"litellm-llms",
|
||||
"litellm-llms-types",
|
||||
"litellm-secrets",
|
||||
|
|
@ -4125,6 +4127,7 @@ dependencies = [
|
|||
"litellm-host-native",
|
||||
"litellm-http",
|
||||
"litellm-inference",
|
||||
"litellm-inference-testing",
|
||||
"litellm-llms",
|
||||
"litellm-llms-types",
|
||||
"litellm-secrets",
|
||||
|
|
@ -4138,6 +4141,16 @@ dependencies = [
|
|||
"wiremock",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "litellm-inference-testing"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"litellm-http",
|
||||
"litellm-inference",
|
||||
"litellm-secrets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "litellm-inference-transcription"
|
||||
version = "0.1.0"
|
||||
|
|
@ -4147,6 +4160,7 @@ dependencies = [
|
|||
"litellm-core-utils",
|
||||
"litellm-http",
|
||||
"litellm-inference",
|
||||
"litellm-inference-testing",
|
||||
"litellm-llms",
|
||||
"litellm-secrets",
|
||||
"litellm-tracing",
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ litellm-inference-responses = { path = "crates/inference-responses" }
|
|||
litellm-inference-messages = { path = "crates/inference-messages" }
|
||||
litellm-inference-chat = { path = "crates/inference-chat" }
|
||||
litellm-inference-ocr = { path = "crates/inference-ocr" }
|
||||
litellm-inference-testing = { path = "crates/inference-testing" }
|
||||
litellm-gateway-mcp = { path = "crates/gateway-mcp" }
|
||||
litellm-gateway = { path = "crates/gateway" }
|
||||
litellm-gateway-inference = { path = "crates/gateway-inference" }
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ tracing.workspace = true
|
|||
[dev-dependencies]
|
||||
litellm-cache-memory.workspace = true
|
||||
litellm-host-native.workspace = true
|
||||
litellm-inference = { workspace = true, features = ["test-support"] }
|
||||
litellm-http = { workspace = true, features = ["test-support"] }
|
||||
litellm-inference-testing.workspace = true
|
||||
litellm-tracing.workspace = true
|
||||
rstest.workspace = true
|
||||
tokio.workspace = true
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use litellm_inference::test_support::{http_config, no_secrets, provider_http, resources};
|
||||
use litellm_inference_testing::{http_config, no_secrets, provider_http, resources};
|
||||
use serde_json::Value;
|
||||
use wiremock::{Mock, MockServer, Request, ResponseTemplate, matchers::any};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ tracing.workspace = true
|
|||
[dev-dependencies]
|
||||
litellm-cache-memory.workspace = true
|
||||
litellm-host-native.workspace = true
|
||||
litellm-inference = { workspace = true, features = ["test-support"] }
|
||||
litellm-http = { workspace = true, features = ["test-support"] }
|
||||
litellm-inference-testing.workspace = true
|
||||
rstest.workspace = true
|
||||
tokio.workspace = true
|
||||
wiremock.workspace = true
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ use litellm_host::{
|
|||
interceptors::{ExecutionFacts, RequestContext, ResultSource, WireRequest},
|
||||
lifecycle::CallEvent,
|
||||
};
|
||||
use litellm_inference::test_support::{RecordingSecrets, no_secrets};
|
||||
use litellm_inference_messages::{MessagesCallResponse, route::Messages};
|
||||
use litellm_inference_testing::{RecordingSecrets, no_secrets};
|
||||
use litellm_llms::base_llm::messages::context::MessagesModelCapabilities as AnthropicModelCapabilities;
|
||||
use rstest::rstest;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ use std::{
|
|||
};
|
||||
|
||||
use litellm_http::{HttpSettings, Resolution};
|
||||
use litellm_inference::test_support::RecordingSecrets;
|
||||
use litellm_inference_messages::{
|
||||
Error, MessagesCall, MessagesShaping,
|
||||
route::{Messages, MessagesMachine, MessagesOutput},
|
||||
};
|
||||
use litellm_inference_testing::RecordingSecrets;
|
||||
use litellm_llms_types::formats::messages::{MessagesRequest, MessagesResponse};
|
||||
use litellm_secrets::source::SecretSource;
|
||||
use rstest::fixture;
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ use litellm_host::{
|
|||
lifecycle::ExecutionEvent,
|
||||
};
|
||||
use litellm_http::transport::Error as TransportError;
|
||||
use litellm_inference::test_support::{
|
||||
use litellm_inference_messages::{MessagesCallResponse, messages_body};
|
||||
use litellm_inference_testing::{
|
||||
RecordingSecrets, http_config, no_secrets, provider_http, resources,
|
||||
};
|
||||
use litellm_inference_messages::{MessagesCallResponse, messages_body};
|
||||
use rstest::rstest;
|
||||
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use litellm_inference::test_support::RecordingSecrets;
|
||||
use litellm_inference_testing::RecordingSecrets;
|
||||
use rstest::rstest;
|
||||
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ use std::{
|
|||
|
||||
use bytes::Bytes;
|
||||
use futures_util::{StreamExt, TryStreamExt};
|
||||
use litellm_inference::test_support::{RecordingSecrets, no_secrets};
|
||||
use litellm_inference_messages::{
|
||||
MessagesCallResponse,
|
||||
route::{Messages, MessagesStreamHead},
|
||||
};
|
||||
use litellm_inference_testing::{RecordingSecrets, no_secrets};
|
||||
use litellm_tracing::{Logger, Metadata, Record, Sink};
|
||||
use rstest::rstest;
|
||||
use tokio::{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use litellm_inference::test_support::{http_config, provider_http, resources};
|
||||
use litellm_inference_testing::{http_config, provider_http, resources};
|
||||
use litellm_secrets::source::SecretSource;
|
||||
use serde_json::Value;
|
||||
use wiremock::{Mock, MockServer, Request, ResponseTemplate, matchers::any};
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ litellm-auth-aws.workspace = true
|
|||
litellm-auth-gcp.workspace = true
|
||||
litellm-host-native.workspace = true
|
||||
litellm-http = { workspace = true, features = ["test-support"] }
|
||||
litellm-inference = { workspace = true, features = ["test-support"] }
|
||||
litellm-inference-testing.workspace = true
|
||||
litellm-llms = { workspace = true, features = ["test-support"] }
|
||||
rand.workspace = true
|
||||
rstest.workspace = true
|
||||
time.workspace = true
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use base64::Engine;
|
||||
use litellm_host::interceptors::WireRequest;
|
||||
use litellm_inference::test_support::{http_config, no_secrets, resources};
|
||||
use litellm_inference_ocr::types::OcrDocumentInput;
|
||||
use litellm_inference_testing::{http_config, no_secrets, resources};
|
||||
use rstest::rstest;
|
||||
use wiremock::{Mock, matchers::any};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use litellm_host::{
|
|||
interceptors::{RequestContext, WireRequest},
|
||||
lifecycle::CallEvent,
|
||||
};
|
||||
use litellm_inference::test_support::{http_config, no_secrets, resources};
|
||||
use litellm_inference_ocr::{
|
||||
OcrRoute,
|
||||
document::prepare_document,
|
||||
|
|
@ -10,6 +9,7 @@ use litellm_inference_ocr::{
|
|||
types::{LiteLLMOcrRequest, OcrDocumentInput},
|
||||
wire::{OcrWireRequest, decode_request},
|
||||
};
|
||||
use litellm_inference_testing::{http_config, no_secrets, resources};
|
||||
use litellm_llms::base_llm::ocr::{error::Error, settings::OcrSettings};
|
||||
use litellm_llms_types::formats::ocr::{LiteLLMOcrResponse, OcrDocument};
|
||||
use serde_json::{Map, Value, json};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use litellm_http::{HttpSettings, Resolution};
|
||||
use litellm_inference::test_support::{RecordingSecrets, http_config, no_secrets, resources};
|
||||
use litellm_inference_testing::{RecordingSecrets, http_config, no_secrets, resources};
|
||||
use litellm_llms::{
|
||||
base_llm::ocr::transformation::{BaseOcrConfig, OCR_RESPONSE_MAX_BYTES},
|
||||
mistral::ocr::transformation::MistralOcrConfig,
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ use litellm_auth_gcp::{
|
|||
};
|
||||
use litellm_http::{HttpSettings, Resolution};
|
||||
use litellm_inference::resources::CoreResources;
|
||||
use litellm_inference::test_support::{RecordingSecrets, http_pool};
|
||||
use litellm_inference_ocr::wire::{OcrWireRequest, decode_request};
|
||||
use litellm_inference_testing::{RecordingSecrets, http_pool};
|
||||
use litellm_llms::base_llm::ocr::settings::OcrSettings;
|
||||
use rstest::{fixture, rstest};
|
||||
use serde_json::json;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ tracing.workspace = true
|
|||
litellm-cache.workspace = true
|
||||
litellm-cache-memory.workspace = true
|
||||
litellm-host-native.workspace = true
|
||||
litellm-inference = { workspace = true, features = ["test-support"] }
|
||||
litellm-inference-testing.workspace = true
|
||||
litellm-tracing.workspace = true
|
||||
rstest.workspace = true
|
||||
wiremock.workspace = true
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ use std::sync::Arc;
|
|||
|
||||
use futures_util::TryStreamExt;
|
||||
use litellm_host::{call::HostedCompletion, lifecycle::CallEvent};
|
||||
use litellm_inference::test_support::{RecordingSecrets, no_secrets};
|
||||
use litellm_inference_responses::{
|
||||
route::Responses,
|
||||
types::{ResponsesCall, ResponsesOutput},
|
||||
};
|
||||
use litellm_inference_testing::{RecordingSecrets, no_secrets};
|
||||
use rstest::{fixture, rstest};
|
||||
use serde_json::json;
|
||||
use wiremock::ResponseTemplate;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use litellm_inference::test_support::{http_config, provider_http, resources};
|
||||
use litellm_inference_testing::{http_config, provider_http, resources};
|
||||
use litellm_secrets::source::SecretSource;
|
||||
use serde_json::Value;
|
||||
use wiremock::{Mock, MockServer, Request, ResponseTemplate, matchers::any};
|
||||
|
|
|
|||
13
litellm-rust/crates/inference-testing/Cargo.toml
Normal file
13
litellm-rust/crates/inference-testing/Cargo.toml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "litellm-inference-testing"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
futures-util.workspace = true
|
||||
litellm-http.workspace = true
|
||||
litellm-inference.workspace = true
|
||||
litellm-secrets.workspace = true
|
||||
|
|
@ -7,7 +7,7 @@ use litellm_http::{
|
|||
};
|
||||
use litellm_secrets::{SecretValue, source::SecretSource};
|
||||
|
||||
use crate::resources::CoreResources;
|
||||
use litellm_inference::resources::CoreResources;
|
||||
|
||||
pub fn http_pool() -> HttpClientPool {
|
||||
HttpClientPool::new(Arc::new(PublicDnsResolver))
|
||||
|
|
@ -32,7 +32,6 @@ pub fn http_config() -> HttpClientConfig {
|
|||
Resolution::from(&HttpSettings::default()).config
|
||||
}
|
||||
|
||||
/// A secret source that answers from a fixed table and records every name it was asked for.
|
||||
pub struct RecordingSecrets {
|
||||
values: Vec<(String, String)>,
|
||||
fails: bool,
|
||||
|
|
@ -17,7 +17,7 @@ serde_json.workspace = true
|
|||
tracing.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
litellm-inference = { workspace = true, features = ["test-support"] }
|
||||
litellm-inference-testing.workspace = true
|
||||
litellm-tracing.workspace = true
|
||||
rstest.workspace = true
|
||||
tokio.workspace = true
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use litellm_inference::test_support::{http_config, no_secrets, provider_http, resources};
|
||||
use litellm_inference_testing::{http_config, no_secrets, provider_http, resources};
|
||||
use serde_json::Value;
|
||||
use wiremock::{Mock, MockServer, Request, ResponseTemplate, matchers::any};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
- `RouteError` (`src/error.rs`), `CallOptions` (`src/lib.rs`), `CallContext` (`src/context.rs`)
|
||||
- diagnostic spans (`src/diagnostic.rs`), outbound send and signing (`src/outbound.rs`), provider resolution (`src/provider.rs`), `CoreResources` (`src/resources.rs`)
|
||||
- response caching (`src/caching.rs`): `Cachable`, `StreamCachable`, `CacheRequest`, `CallCache`, `execute_unary`, `execute_streaming`, stream capture
|
||||
- shared test helpers behind the `test-support` feature (`src/test_support.rs`)
|
||||
- Shared test helpers belong in litellm-inference-testing, used only as a dev dependency
|
||||
- Nothing here names an API format; format-specific code, constants, tests and test builders live in their `inference-<fmt>` crate
|
||||
- Never depend on an `inference-*` crate from here
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ edition.workspace = true
|
|||
license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[features]
|
||||
test-support = []
|
||||
|
||||
[dependencies]
|
||||
litellm-cache.workspace = true
|
||||
litellm-cache-response.workspace = true
|
||||
|
|
@ -32,7 +29,6 @@ time.workspace = true
|
|||
url.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
litellm-inference = { workspace = true, features = ["test-support"] }
|
||||
litellm-cache-memory.workspace = true
|
||||
litellm-http = { workspace = true, features = ["test-support"] }
|
||||
litellm-llms = { workspace = true, features = ["test-support"] }
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
pub const OPENAI_DEFAULT_API_BASE: &str = "https://api.openai.com";
|
||||
|
|
@ -2,13 +2,10 @@ pub mod context;
|
|||
pub mod diagnostic;
|
||||
|
||||
pub mod caching;
|
||||
pub mod constants;
|
||||
pub mod error;
|
||||
pub mod outbound;
|
||||
pub mod provider;
|
||||
pub mod resources;
|
||||
#[cfg(feature = "test-support")]
|
||||
pub mod test_support;
|
||||
|
||||
pub use error::RouteError;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue