0ef5fcb1c5
Security / Dependency audit (pip-audit) (push) Has been cancelled
Security / CodeQL (javascript-typescript) (push) Has been cancelled
Security / CodeQL (python) (push) Has been cancelled
Security / Secret scan (gitleaks) (push) Has been cancelled
rust / test (ubuntu) (push) Has been cancelled
rust / simulator e2e (macos-latest) (push) Has been cancelled
rust / simulator e2e (ubuntu-latest) (push) Has been cancelled
rust / simulator e2e (windows-latest) (push) Has been cancelled
rust / wheels (aarch64-apple-darwin) (push) Has been cancelled
rust / wheels (x86_64-unknown-linux-gnu) (push) Has been cancelled
rust / wheels (x86_64-apple-darwin) (push) Has been cancelled
rust / audit (push) Has been cancelled
rust / parity (nightly, allowed to fail during Phase 0) (push) Has been cancelled
CI / commitlint (push) Has been skipped
Dev Containers / validate (.devcontainer/devcontainer.json, default) (push) Failing after 0s
Dev Containers / validate (.devcontainer/memory-stack/devcontainer.json, memory-stack) (push) Failing after 0s
Dev Containers / validate-worktree (push) Failing after 0s
CI / changes (push) Failing after 4s
Deploy Documentation / validate (push) Has been skipped
Deploy Documentation / deploy (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, claude) (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, codex) (push) Failing after 1s
Install Native E2E / install-native (ubuntu-latest) (push) Failing after 1s
OpenCode Plugin / typecheck + build + test (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, copilot) (push) Failing after 1s
Release Please / release-please (push) Failing after 1s
Wrap E2E / docker-wrap-e2e (push) Failing after 1s
Wrap Native E2E / wrap-native (ubuntu-latest) (push) Failing after 1s
Init E2E / docker-init-e2e (push) Failing after 4s
Merge Conflicts / merge-conflicts (push) Failing after 4s
CI / lint (push) Has been cancelled
CI / build-wheel (push) Has been cancelled
CI / build-wheel-windows (push) Has been cancelled
CI / prefetch-model (push) Has been cancelled
CI / test-dashboard-ui (push) Has been cancelled
CI / test (1) (push) Has been cancelled
CI / test (2) (push) Has been cancelled
CI / test (3) (push) Has been cancelled
CI / test (4) (push) Has been cancelled
CI / test-extras (push) Has been cancelled
CI / test-agno (push) Has been cancelled
CI / build (push) Has been cancelled
CI / workflow-validation (push) Has been cancelled
CI / docker-native-e2e (push) Has been cancelled
CI / windows-native-wrapper (push) Has been cancelled
CI / macos-native-wrapper (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / promote-latest (push) Has been cancelled
Init Native E2E / init-native (macos-latest, claude) (push) Has been cancelled
Init Native E2E / init-native (macos-latest, codex) (push) Has been cancelled
Init Native E2E / init-native (macos-latest, copilot) (push) Has been cancelled
Install Native E2E / install-native (macos-latest) (push) Has been cancelled
Wrap Native E2E / wrap-native (macos-latest) (push) Has been cancelled
164 lines
4.8 KiB
Python
164 lines
4.8 KiB
Python
from __future__ import annotations
|
|
|
|
from headroom.providers.route_specs import (
|
|
ANTHROPIC_BATCH_ROUTES,
|
|
ANTHROPIC_HANDLER_ROUTES,
|
|
ANTHROPIC_PASSTHROUGH_ROUTES,
|
|
CLOUDCODE_HANDLER_ROUTES,
|
|
GEMINI_BATCH_ROUTES,
|
|
GEMINI_HANDLER_ROUTES,
|
|
GEMINI_PASSTHROUGH_ROUTES,
|
|
OPENAI_BATCH_ROUTES,
|
|
OPENAI_HANDLER_ROUTES,
|
|
OPENAI_PASSTHROUGH_ROUTES,
|
|
PROVIDER_HANDLER_ROUTES,
|
|
PROVIDER_PASSTHROUGH_ROUTES,
|
|
ProviderHandlerRoute,
|
|
ProviderPassthroughRoute,
|
|
)
|
|
|
|
|
|
def test_provider_passthrough_route_specs_are_unique() -> None:
|
|
route_keys = {(spec.method, spec.path) for spec in PROVIDER_PASSTHROUGH_ROUTES}
|
|
|
|
assert len(route_keys) == len(PROVIDER_PASSTHROUGH_ROUTES)
|
|
|
|
|
|
def test_provider_handler_route_specs_are_unique() -> None:
|
|
route_keys = {(spec.method, spec.path) for spec in PROVIDER_HANDLER_ROUTES}
|
|
|
|
assert len(route_keys) == len(PROVIDER_HANDLER_ROUTES)
|
|
|
|
|
|
def test_openai_passthrough_routes_model_endpoint_intent() -> None:
|
|
assert OPENAI_PASSTHROUGH_ROUTES == (
|
|
ProviderPassthroughRoute("POST", "/v1/embeddings", "openai", "embeddings"),
|
|
ProviderPassthroughRoute("POST", "/v1/moderations", "openai", "moderations"),
|
|
ProviderPassthroughRoute(
|
|
"POST",
|
|
"/v1/audio/transcriptions",
|
|
"openai",
|
|
"audio/transcriptions",
|
|
),
|
|
ProviderPassthroughRoute("POST", "/v1/audio/speech", "openai", "audio/speech"),
|
|
)
|
|
|
|
|
|
def test_anthropic_passthrough_routes_model_endpoint_intent() -> None:
|
|
assert ANTHROPIC_PASSTHROUGH_ROUTES == (
|
|
ProviderPassthroughRoute(
|
|
"POST",
|
|
"/v1/messages/count_tokens",
|
|
"anthropic",
|
|
"count_tokens",
|
|
),
|
|
)
|
|
|
|
|
|
def test_gemini_passthrough_routes_model_endpoint_intent() -> None:
|
|
assert (
|
|
ProviderPassthroughRoute(
|
|
"POST",
|
|
"/v1beta/models/{model}:batchEmbedContents",
|
|
"gemini",
|
|
"batchEmbedContents",
|
|
)
|
|
in GEMINI_PASSTHROUGH_ROUTES
|
|
)
|
|
assert (
|
|
ProviderPassthroughRoute(
|
|
"DELETE",
|
|
"/v1beta/cachedContents/{cache_id}",
|
|
"gemini",
|
|
"cachedContents",
|
|
)
|
|
in GEMINI_PASSTHROUGH_ROUTES
|
|
)
|
|
|
|
|
|
def test_direct_handler_routes_model_endpoint_intent() -> None:
|
|
assert ANTHROPIC_HANDLER_ROUTES == (
|
|
ProviderHandlerRoute("POST", "/v1/messages", "handle_anthropic_messages"),
|
|
)
|
|
assert OPENAI_HANDLER_ROUTES == (
|
|
ProviderHandlerRoute("POST", "/v1/chat/completions", "handle_openai_chat"),
|
|
)
|
|
assert GEMINI_HANDLER_ROUTES == (
|
|
ProviderHandlerRoute(
|
|
"POST",
|
|
"/v1beta/models/{model}:generateContent",
|
|
"handle_gemini_generate_content",
|
|
"model",
|
|
),
|
|
ProviderHandlerRoute(
|
|
"POST",
|
|
"/v1beta/models/{model}:streamGenerateContent",
|
|
"handle_gemini_stream_generate_content",
|
|
"model",
|
|
),
|
|
ProviderHandlerRoute(
|
|
"POST",
|
|
"/v1beta/models/{model}:countTokens",
|
|
"handle_gemini_count_tokens",
|
|
"model",
|
|
),
|
|
)
|
|
assert CLOUDCODE_HANDLER_ROUTES == (
|
|
ProviderHandlerRoute(
|
|
"POST",
|
|
"/v1internal:streamGenerateContent",
|
|
"handle_google_cloudcode_stream",
|
|
),
|
|
ProviderHandlerRoute(
|
|
"POST",
|
|
"/v1/v1internal:streamGenerateContent",
|
|
"handle_google_cloudcode_stream",
|
|
),
|
|
)
|
|
|
|
|
|
def test_batch_handler_routes_model_endpoint_intent() -> None:
|
|
assert ANTHROPIC_BATCH_ROUTES[0] == ProviderHandlerRoute(
|
|
"POST",
|
|
"/v1/messages/batches",
|
|
"handle_anthropic_batch_create",
|
|
)
|
|
assert (
|
|
ProviderHandlerRoute(
|
|
"GET",
|
|
"/v1/messages/batches/{batch_id}/results",
|
|
"handle_anthropic_batch_results",
|
|
"batch_id",
|
|
)
|
|
in ANTHROPIC_BATCH_ROUTES
|
|
)
|
|
assert OPENAI_BATCH_ROUTES == (
|
|
ProviderHandlerRoute("POST", "/v1/batches", "handle_batch_create"),
|
|
ProviderHandlerRoute("GET", "/v1/batches", "handle_batch_list"),
|
|
ProviderHandlerRoute("GET", "/v1/batches/{batch_id}", "handle_batch_get", "batch_id"),
|
|
ProviderHandlerRoute(
|
|
"POST",
|
|
"/v1/batches/{batch_id}/cancel",
|
|
"handle_batch_cancel",
|
|
"batch_id",
|
|
),
|
|
)
|
|
assert (
|
|
ProviderHandlerRoute(
|
|
"POST",
|
|
"/v1beta/models/{model}:batchGenerateContent",
|
|
"handle_google_batch_create",
|
|
"model",
|
|
)
|
|
in GEMINI_BATCH_ROUTES
|
|
)
|
|
assert (
|
|
ProviderHandlerRoute(
|
|
"DELETE",
|
|
"/v1beta/batches/{batch_name}",
|
|
"handle_google_batch_passthrough",
|
|
"batch_name",
|
|
)
|
|
in GEMINI_BATCH_ROUTES
|
|
)
|