-
Notifications
You must be signed in to change notification settings - Fork 149
Realtime transcription endpoint #713
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
Open
ushaket
wants to merge
12
commits into
vllm-project:main
Choose a base branch
from
ushaket:uris/realtime-transcription-endpoint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7ca668d
initial commit
ushaket ac586d2
missing files
ushaket 9493739
lint
ushaket 8fee38a
Update src/guidellm/backends/openai/openai_common.py
ushaket f60beea
Update src/guidellm/backends/openai/openai_common.py
ushaket 5892e14
CR
ushaket 55cd581
CR
ushaket fc4ee66
CR
ushaket bc76810
CR
ushaket d60797e
remove redundant test
ushaket 62755f8
lint
ushaket 5330324
CR
ushaket File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| """Shared helpers for OpenAI-compatible HTTP and WebSocket backends.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| __all__ = [ | ||
| "FALLBACK_TIMEOUT", | ||
| "build_headers", | ||
| "resolve_validate_kwargs", | ||
| ] | ||
|
|
||
| # NOTE: This value is taken from httpx's default | ||
| FALLBACK_TIMEOUT = 5.0 | ||
|
|
||
|
|
||
| def build_headers( | ||
| api_key: str | None, | ||
| existing_headers: dict[str, str] | None = None, | ||
| ) -> dict[str, str] | None: | ||
| """ | ||
| Build headers with bearer authentication for OpenAI-compatible requests. | ||
|
|
||
| Merges the Authorization bearer token (if ``api_key`` is set) with any | ||
| existing headers. User-provided headers take precedence over the bearer token. | ||
|
|
||
| :param api_key: Optional API key for Bearer authentication | ||
| :param existing_headers: Optional headers to merge in | ||
| :return: Headers dict, or ``None`` if there are no headers to send | ||
| """ | ||
| headers: dict[str, str] = {} | ||
| if api_key: | ||
| headers["Authorization"] = f"Bearer {api_key}" | ||
| if existing_headers: | ||
| headers = {**headers, **existing_headers} | ||
| return headers or None | ||
|
|
||
|
|
||
| def resolve_validate_kwargs( | ||
| validate_backend: bool | str | dict[str, Any], | ||
| target: str, | ||
| api_routes: dict[str, str], | ||
| ) -> dict[str, Any] | None: | ||
| """ | ||
| Build ``httpx`` request keyword arguments from backend validation settings. | ||
|
|
||
| ``validate_backend`` may be ``False``/equivalent (skip validation), ``True`` | ||
| (default ``GET`` against the ``/health`` route key), a route key present in | ||
| ``api_routes`` (resolved to ``{target}/{path}``), a full URL string, or a | ||
| ``dict`` that includes ``url`` and optionally ``method`` (default ``GET``). | ||
|
|
||
| :return: Keyword arguments suitable for ``httpx.AsyncClient.request``, or | ||
| ``None`` when validation is turned off. | ||
| """ | ||
| raw = validate_backend | ||
| if not raw: | ||
| return None | ||
|
|
||
| if raw is True: | ||
| raw = "/health" | ||
|
|
||
| if isinstance(raw, str): | ||
| url = f"{target}/{api_routes[raw]}" if raw in api_routes else raw | ||
| request_kwargs: dict[str, Any] = {"method": "GET", "url": url} | ||
| elif isinstance(raw, dict): | ||
| request_kwargs = raw | ||
| else: | ||
| request_kwargs = raw | ||
|
|
||
| if not isinstance(request_kwargs, dict) or "url" not in request_kwargs: | ||
| raise ValueError( | ||
| "validate_backend must be a boolean, string, or dictionary and contain " | ||
| f"a target URL. Got: {request_kwargs}" | ||
| ) | ||
|
|
||
| if "method" not in request_kwargs: | ||
| request_kwargs["method"] = "GET" | ||
|
|
||
| return request_kwargs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to
common.py