mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-12 03:48:56 +00:00
* feat(dev): seed linked tracing and spend fixtures * chore(dev): use OpenAI model in tracing config * chore(dev): align tracing credentials with UI E2E * fix(dev): update fixture seeder query scope * feat(dev): seed linked tracing and spend fixtures * chore(dev): use OpenAI model in tracing config * chore(dev): align tracing credentials with UI E2E * fix(dev): update fixture seeder query scope * wip * wip * wip * chore(trace): checkpoint ongoing Rust migration * refactor(trace): group Python bridge under trace package * refactor(traces): read span conventions through a Convention trait Each span format (Claude Code, LangSmith, OpenInference, gen_ai) now lives under normalize/convention/ as a unit struct implementing Convention, owning both its detection and its extraction. Precedence is one ordered registry instead of an if-chain in mod.rs that reached into each module differently. The modules now share one way to read attributes: present() for the first non-empty key and Payload for a text that also reports the key it consumed, replacing three different idioms and the &mut Vec threaded through payload readers. Instrumentation::adjust returns a new Extraction instead of mutating one, with each SDK rule as its own function, and the LangChain middleware suffix list exists once. * feat(trace): export Rust-owned wire schemas and enforce contract bounds * fix(trace): bound quoted counts in ClickHouse wire schemas * feat(trace): generate Python wire contracts with datamodel-code-generator * test(trace): validate migrated callers and generated contracts at the native boundary * refactor(traces): rename normalization convention to format * fix(traces): reconcile spend evidence and preserve unknown costs * feat(traces): normalize additional telemetry formats * test(traces): cover captured normalization fixtures * refactor(traces): isolate SDK normalization rules * feat(tracing): seed all trace exports for local dashboard * fix(clickhouse): preserve custom LiteLLM request metadata * docs(traces): define normalization module boundaries * docs(traces): define resolution and OTLP boundaries * fix(ui): normalize nullable trace message names * refactor(traces): split resolver modules and cover resolution behavior * test(traces): replace normalization snapshots with behavior assertions * fix(ui): align dashboard API contracts with generated types * refactor(traces): type normalization and storage boundaries * fix(traces): seed captured SDK spend and preserve provider identities * wip * test(traces): verify guide discovery and content ordering --------- Co-authored-by: Yujong Lee <yujong@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
140 lines
4.4 KiB
Rust
140 lines
4.4 KiB
Rust
mod cache;
|
|
mod callable;
|
|
mod coercion;
|
|
mod credentials;
|
|
mod diagnostics;
|
|
mod errors;
|
|
mod execution;
|
|
mod http;
|
|
mod lifecycle;
|
|
mod logger;
|
|
mod marshal;
|
|
mod preflight;
|
|
mod python_settings;
|
|
mod routes;
|
|
mod secrets;
|
|
mod tokenizer;
|
|
|
|
#[pymodule(gil_used = true)]
|
|
mod _native {
|
|
use crate::cache::ResolvedCache;
|
|
#[cfg(feature = "panic-test")]
|
|
#[pymodule_export]
|
|
use crate::diagnostics::_panic_for_test;
|
|
#[pymodule_export]
|
|
use crate::diagnostics::{gil_stats, process_state_started, reserve_process_for_forking};
|
|
#[pymodule_export]
|
|
use crate::errors::{RustBridgeDeclined, RustUpstreamError};
|
|
#[pymodule_export]
|
|
use crate::logger::NativeDiagnosticProcessor;
|
|
#[pymodule_export]
|
|
use crate::routes::audio_transcription::{atranscription, transcription};
|
|
#[pymodule_export]
|
|
use crate::routes::chat_completions::{
|
|
achat_completions, acompletion, chat_completions, completion,
|
|
};
|
|
#[pymodule_export]
|
|
use crate::routes::embeddings::{aembedding, embedding};
|
|
#[pymodule_export]
|
|
use crate::routes::messages::{amessages, messages};
|
|
#[pymodule_export]
|
|
use crate::routes::ocr::{aocr, ocr, ocr_health_check_document, ocr_passthrough_response};
|
|
#[pymodule_export]
|
|
use crate::routes::responses::{ResponsesWebSocketConnection, aresponses, responses};
|
|
#[pymodule_export]
|
|
use crate::routes::token_counter::TokenCounter;
|
|
#[pymodule_export]
|
|
use crate::routes::traces::{
|
|
NativeTraceConfig, NativeTraceStorage, trace_encode_error, trace_span_rows,
|
|
};
|
|
#[cfg(feature = "huggingface")]
|
|
#[pymodule_export]
|
|
use crate::tokenizer::HuggingFaceEncoding;
|
|
#[pymodule_export]
|
|
use crate::tokenizer::Tokenizer;
|
|
#[pymodule_export]
|
|
use litellm_host_python::{ForkedAfterNativeRuntimeStarted, ProcessReservedForForking};
|
|
use pyo3::{prelude::*, types::PyModule};
|
|
|
|
#[pymodule_init]
|
|
fn init(module: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
let py = module.py();
|
|
let dict = module.dict();
|
|
dict.set_item(
|
|
"NativeCacheHandle",
|
|
py.get_type::<crate::cache::NativeCacheHandle>(),
|
|
)?;
|
|
dict.set_item("_ResponseCacheRuntime", py.get_type::<ResolvedCache>())?;
|
|
dict.set_item(
|
|
"_SecretManagerRuntime",
|
|
py.get_type::<crate::secrets::runtime::NativeSecretManager>(),
|
|
)
|
|
}
|
|
}
|
|
|
|
use pyo3::prelude::*;
|
|
|
|
#[cfg(test)]
|
|
pub(crate) fn native_module(py: Python<'_>) -> Bound<'_, PyModule> {
|
|
pyo3::wrap_pymodule!(_native)(py).into_bound(py)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[rstest::rstest]
|
|
fn module_registration_preserves_the_public_surface() {
|
|
Python::initialize();
|
|
Python::attach(|py| {
|
|
let mut expected = vec![
|
|
"NativeCacheHandle",
|
|
"RustBridgeDeclined",
|
|
"RustUpstreamError",
|
|
"ForkedAfterNativeRuntimeStarted",
|
|
"ProcessReservedForForking",
|
|
"ocr",
|
|
"aocr",
|
|
"ocr_health_check_document",
|
|
"ocr_passthrough_response",
|
|
"embedding",
|
|
"aembedding",
|
|
"transcription",
|
|
"atranscription",
|
|
"messages",
|
|
"amessages",
|
|
"chat_completions",
|
|
"achat_completions",
|
|
"completion",
|
|
"acompletion",
|
|
"responses",
|
|
"aresponses",
|
|
"ResponsesWebSocketConnection",
|
|
"NativeDiagnosticProcessor",
|
|
"NativeTraceConfig",
|
|
"NativeTraceStorage",
|
|
"trace_encode_error",
|
|
"trace_span_rows",
|
|
"TokenCounter",
|
|
"Tokenizer",
|
|
"gil_stats",
|
|
"process_state_started",
|
|
"reserve_process_for_forking",
|
|
];
|
|
#[cfg(feature = "huggingface")]
|
|
expected.push("HuggingFaceEncoding");
|
|
expected.sort_unstable();
|
|
|
|
let mut public_names: Vec<String> = native_module(py)
|
|
.dict()
|
|
.keys()
|
|
.extract::<Vec<String>>()
|
|
.expect("module names should be strings")
|
|
.into_iter()
|
|
.filter(|name| !name.starts_with('_'))
|
|
.collect();
|
|
public_names.sort_unstable();
|
|
assert_eq!(public_names, expected);
|
|
});
|
|
}
|
|
}
|