mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-30 01:08:33 +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>
68 lines
2.1 KiB
Rust
68 lines
2.1 KiB
Rust
use litellm_traces::query::guide::{Example, QueryGuide, Section};
|
|
use rstest::rstest;
|
|
|
|
#[rstest]
|
|
#[case::empty(false)]
|
|
#[case::supplied(true)]
|
|
fn guide_preserves_supplied_content_and_order(#[case] populated: bool) {
|
|
let sql = "SELECT 'quotes', '<&>', '{{ sql }}', '{% block %}'\nFROM supplied_table\nLIMIT 7";
|
|
let sections = [
|
|
Section {
|
|
title: "First section",
|
|
body: "Backend content <&> {{ untouched }}",
|
|
},
|
|
Section {
|
|
title: "Second section",
|
|
body: "Second body",
|
|
},
|
|
];
|
|
let examples = [
|
|
Example {
|
|
name: "First example".into(),
|
|
sql: sql.into(),
|
|
},
|
|
Example {
|
|
name: "Second example".into(),
|
|
sql: "SELECT 2".into(),
|
|
},
|
|
];
|
|
let gotchas = ["First gotcha <&>".into(), "Second gotcha".into()];
|
|
let guide = QueryGuide {
|
|
sections: if populated { §ions } else { &[] },
|
|
examples: if populated { &examples } else { &[] },
|
|
gotchas: if populated { &gotchas } else { &[] },
|
|
}
|
|
.render()
|
|
.unwrap();
|
|
assert!(guide.starts_with("Trace SQL query guide\n\n"));
|
|
assert!(guide.contains("POST /v1/traces/query"));
|
|
assert!(guide.contains("GET /v1/traces/query/help"));
|
|
if !populated {
|
|
assert!(!guide.contains(sections[0].title));
|
|
assert!(!guide.contains(&examples[0].name));
|
|
assert!(!guide.contains(&gotchas[0]));
|
|
return;
|
|
}
|
|
let contents = [
|
|
sections[0].title,
|
|
sections[0].body,
|
|
sections[1].title,
|
|
sections[1].body,
|
|
"Endpoints",
|
|
"Examples",
|
|
&examples[0].name,
|
|
sql,
|
|
&examples[1].name,
|
|
&examples[1].sql,
|
|
"Gotchas",
|
|
&gotchas[0],
|
|
&gotchas[1],
|
|
];
|
|
let positions = contents.map(|text| guide.find(text).expect(text));
|
|
assert!(positions.windows(2).all(|pair| pair[0] < pair[1]));
|
|
assert!(guide.contains(&format!(
|
|
"{}\n\n{}\n\n",
|
|
sections[0].title, sections[0].body
|
|
)));
|
|
assert!(guide.contains(&format!("{}\n{}\n\n", examples[0].name, sql)));
|
|
}
|