Skip to content

Add openai and wildcard paths #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/prompt_passage/proxy_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,24 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
_service_auth_key: str | None = None


@app.post("/provider/{provider}/openai/deployments/{model}/chat/completions")
async def chat_proxy_oai_deployment(provider: str, model: str, request: Request) -> Response:
"""Proxy for chat completions to the specified provider with deployment path."""
return await chat_proxy(provider, request)


@app.post("/provider/{provider}/deployments/{model}/chat/completions")
async def chat_proxy_deployment(provider: str, model: str, request: Request) -> Response:
"""Proxy for chat completions to the specified provider with deployment path."""
return await chat_proxy(provider, request)


@app.post("/provider/{provider}/{subpath:path}/chat/completions")
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wildcard path pattern could create ambiguous routing. This endpoint will match URLs that should be handled by more specific endpoints above it. Consider placing this route after all other specific patterns or adding additional constraints to prevent conflicts.

Copilot uses AI. Check for mistakes.

async def chat_proxy_wildcard(provider: str, subpath: str, request: Request) -> Response:
"""Proxy for chat completions to the specified provider with flexible subpath routing."""
return await chat_proxy(provider, request)


@app.post("/provider/{provider}/chat/completions")
async def chat_proxy(provider: str, request: Request) -> Response:
if _service_auth_key is not None:
Expand Down