mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-05 08:07:05 +00:00
* refactor(python-bridge): split non-streaming bridge modules * refactor(python-bridge): bring shared function tracing into route layer * feat(dev): list Python route functions and call sites * feat(dev): list Rust route functions and call sites * docs(dev): record OCR parity gaps across Python and Rust * feat(dev): list executed SDK calls with runtime tracing * feat(dev): report Python vs Rust SDK pipeline steps in one CLI * feat(dev): side-by-side pipeline step report in compare CLI * fix(dev): drop invalid Final annotations in compare cell loop * feat(dev): blue python-only and yellow rust-only steps in compare CLI * feat(dev): vertical layout with section spacing in compare CLI * fix(dev): validate SDK trace stages across sync and async routes * refactor(rust): align SDK route call structure with Python * refactor(python-bridge): share sync and async route call wrappers * refactor(dev): split compare CLI into fixtures, runtime, and report modules * fix(ci): run SDK trace tests and satisfy test lint
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Final
|
|
|
|
import pytest
|
|
|
|
from tests.sdk_function_trace.runtime import (
|
|
TraceFailed,
|
|
TraceSkipped,
|
|
attempt_trace,
|
|
run_trace,
|
|
trace_diff,
|
|
)
|
|
from tests.sdk_function_trace.steps import pipeline_issues, pipeline_steps
|
|
|
|
|
|
def test_sync_messages_records_the_known_python_limitation() -> None:
|
|
result: Final = attempt_trace("messages", engine="python", asynchronous=False)
|
|
|
|
assert isinstance(result, TraceSkipped)
|
|
assert result.reason == "ValueError: anthropic_messages_handler is not implemented for sync calls"
|
|
|
|
|
|
def test_unexpected_call_failure_is_not_skipped() -> None:
|
|
result: Final = attempt_trace("unknown", engine="python", asynchronous=False)
|
|
|
|
assert isinstance(result, TraceFailed)
|
|
assert result.reason == "ValueError: Unknown route: unknown"
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("route", "asynchronous"),
|
|
(("chat_completions", False), ("chat_completions", True), ("messages", True), ("ocr", False), ("ocr", True)),
|
|
)
|
|
def test_compiled_routes_match_python_steps(route: str, asynchronous: bool) -> None:
|
|
from litellm.rust_bridge import get_native_bridge
|
|
|
|
if get_native_bridge() is None:
|
|
pytest.skip("build the native bridge to run executed route parity")
|
|
python: Final = pipeline_steps(route, "python", run_trace(route, engine="python", asynchronous=asynchronous))
|
|
rust: Final = pipeline_steps(route, "rust", run_trace(route, engine="rust", asynchronous=asynchronous))
|
|
|
|
assert pipeline_issues(route, "python", python) == ()
|
|
assert pipeline_issues(route, "rust", rust) == ()
|
|
assert trace_diff(python, rust).matches
|
|
if route != "messages":
|
|
assert python == rust
|