vllm.entrypoints.openai.run_batch ¶
BatchRequestInputBody module-attribute ¶
BatchRequestInputBody: TypeAlias = (
ChatCompletionRequest
| EmbeddingRequest
| ScoreRequest
| RerankRequest
| BatchTranscriptionRequest
| BatchTranslationRequest
)
_BAR_FORMAT module-attribute ¶
_BAR_FORMAT = "{desc}: {percentage:3.0f}% Completed | {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}]\n"
BatchProgressTracker ¶
Source code in vllm/entrypoints/openai/run_batch.py
BatchRequestInput ¶
Bases: OpenAIBaseModel
The per-line object of the batch input file.
NOTE: Currently only the /v1/chat/completions endpoint is supported.
Source code in vllm/entrypoints/openai/run_batch.py
check_type_for_url classmethod ¶
check_type_for_url(value: Any, info: ValidationInfo)
Source code in vllm/entrypoints/openai/run_batch.py
BatchRequestOutput ¶
Bases: OpenAIBaseModel
The per-line object of the batch output and error files
Source code in vllm/entrypoints/openai/run_batch.py
BatchResponseData ¶
Bases: OpenAIBaseModel
Source code in vllm/entrypoints/openai/run_batch.py
body class-attribute instance-attribute ¶
body: (
ChatCompletionResponse
| EmbeddingResponse
| ScoreResponse
| RerankResponse
| TranscriptionResponse
| TranscriptionResponseVerbose
| TranslationResponse
| TranslationResponseVerbose
| None
) = None
BatchTranscriptionRequest ¶
Bases: TranscriptionRequest
Batch transcription request that uses file_url instead of file.
This class extends TranscriptionRequest but replaces the file field with file_url to support batch processing from audio files written in JSON format.
Source code in vllm/entrypoints/openai/run_batch.py
file class-attribute instance-attribute ¶
file_url class-attribute instance-attribute ¶
file_url: str = Field(
...,
description="Either a URL of the audio or a data URL with base64 encoded audio data. ",
)
validate_no_file classmethod ¶
validate_no_file(data: Any)
Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/openai/run_batch.py
BatchTranslationRequest ¶
Bases: TranslationRequest
Batch translation request that uses file_url instead of file.
This class extends TranslationRequest but replaces the file field with file_url to support batch processing from audio files written in JSON format.
Source code in vllm/entrypoints/openai/run_batch.py
file class-attribute instance-attribute ¶
file_url class-attribute instance-attribute ¶
file_url: str = Field(
...,
description="Either a URL of the audio or a data URL with base64 encoded audio data. ",
)
validate_no_file classmethod ¶
validate_no_file(data: Any)
Ensure file field is not provided in batch requests.
Source code in vllm/entrypoints/openai/run_batch.py
build_endpoint_registry ¶
build_endpoint_registry(
engine_client: EngineClient,
args: Namespace,
base_model_paths: list[BaseModelPath],
request_logger: RequestLogger | None,
supported_tasks: tuple[SupportedTask, ...],
) -> dict[str, dict[str, Any]]
Build the endpoint registry with all serving objects and handler configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
engine_client | EngineClient | The engine client | required |
args | Namespace | Command line arguments | required |
base_model_paths | list[BaseModelPath] | List of base model paths | required |
request_logger | RequestLogger | None | Optional request logger | required |
supported_tasks | tuple[SupportedTask, ...] | Tuple of supported tasks | required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Any]] | Dictionary mapping endpoint keys to their configurations |
Source code in vllm/entrypoints/openai/run_batch.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | |
download_bytes_from_url async ¶
Download data from a URL or decode from a data URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url | str | Either an HTTP/HTTPS URL or a data URL (data:...;base64,...) | required |
Returns:
| Type | Description |
|---|---|
bytes | Data as bytes |
Source code in vllm/entrypoints/openai/run_batch.py
handle_endpoint_request ¶
handle_endpoint_request(
request: BatchRequestInput,
tracker: BatchProgressTracker,
url_matcher: Callable[[str], bool],
handler_getter: Callable[[], Callable | None],
wrapper_fn: WrapperFn | None = None,
) -> Awaitable[BatchRequestOutput] | None
Generic handler for endpoint requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request | BatchRequestInput | The batch request input | required |
tracker | BatchProgressTracker | Progress tracker for the batch | required |
url_matcher | Callable[[str], bool] | Function that takes a URL and returns True if it matches | required |
handler_getter | Callable[[], Callable | None] | Function that returns the handler function or None | required |
wrapper_fn | WrapperFn | None | Optional function to wrap the handler (e.g., for transcriptions) | None |
Returns:
| Type | Description |
|---|---|
Awaitable[BatchRequestOutput] | None | Awaitable[BatchRequestOutput] if the request was handled, |
Awaitable[BatchRequestOutput] | None | None if URL didn't match |
Source code in vllm/entrypoints/openai/run_batch.py
main async ¶
main(args: Namespace)
Source code in vllm/entrypoints/openai/run_batch.py
make_arg_parser ¶
make_arg_parser(parser: FlexibleArgumentParser)
Source code in vllm/entrypoints/openai/run_batch.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
make_async_error_request_output async ¶
make_async_error_request_output(
request: BatchRequestInput, error_msg: str
) -> BatchRequestOutput
make_error_request_output ¶
make_error_request_output(
request: BatchRequestInput, error_msg: str
) -> BatchRequestOutput
Source code in vllm/entrypoints/openai/run_batch.py
make_transcription_wrapper ¶
Factory function to create a wrapper for transcription/translation handlers. The wrapper converts BatchTranscriptionRequest or BatchTranslationRequest to TranscriptionRequest or TranslationRequest and calls the appropriate handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_translation | bool | If True, process as translation; otherwise process as transcription | required |
Returns:
| Type | Description |
|---|---|
WrapperFn | A function that takes a handler and returns a wrapped handler |
Source code in vllm/entrypoints/openai/run_batch.py
parse_args ¶
read_file async ¶
Source code in vllm/entrypoints/openai/run_batch.py
run_batch async ¶
run_batch(
engine_client: EngineClient, args: Namespace
) -> None
Source code in vllm/entrypoints/openai/run_batch.py
run_request async ¶
run_request(
serving_engine_func: Callable,
request: BatchRequestInput,
tracker: BatchProgressTracker,
) -> BatchRequestOutput
Source code in vllm/entrypoints/openai/run_batch.py
upload_data async ¶
Upload a local file to a URL. output_url: The URL to upload the file to. data_or_file: Either the data to upload or the path to the file to upload. from_file: If True, data_or_file is the path to the file to upload.
Source code in vllm/entrypoints/openai/run_batch.py
validate_run_batch_args ¶
Source code in vllm/entrypoints/openai/run_batch.py
write_file async ¶
write_file(
path_or_url: str,
batch_outputs: list[BatchRequestOutput],
output_tmp_dir: str,
) -> None
Write batch_outputs to a file or upload to a URL. path_or_url: The path or URL to write batch_outputs to. batch_outputs: The list of batch outputs to write. output_tmp_dir: The directory to store the output file before uploading it to the output URL.
Source code in vllm/entrypoints/openai/run_batch.py
write_local_file async ¶
write_local_file(
output_path: str,
batch_outputs: list[BatchRequestOutput],
) -> None
Write the responses to a local file. output_path: The path to write the responses to. batch_outputs: The list of batch outputs to write.