Skip to content

API Reference parrot.clients.vllm.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.clients.vllm.models

View source

Pydantic models for vLLM client integration.

This module provides configuration and request/response models for the vLLMClient, supporting vLLM-specific features like guided decoding, LoRA adapters, and batch processing.

Class VLLMBatchRequest

Batch request model for vLLM batch processing.

Represents a single request within a batch, containing the prompt and optional parameters for generation.

Fields:

Field Type Default Description
prompt str The input prompt or messages
model Optional[str] None Model identifier (optional, uses default if not specified)
temperature float 0.7 Sampling temperature
max_tokens Optional[int] None Maximum tokens to generate
guided_json Optional[Dict[str, Any]] None Optional JSON schema constraint
guided_regex Optional[str] None Optional regex constraint
guided_choice Optional[List[str]] None Optional choice constraint
lora_adapter Optional[str] None Optional LoRA adapter name
sampling_params Optional[VLLMSamplingParams] None Optional extended sampling parameters

Class VLLMBatchResponse

Batch response model for vLLM batch processing.

Contains the results of a batch processing operation, including individual responses and aggregate statistics.

Fields:

Field Type Default Description
responses List[Optional[str]] List of generated text responses
errors Dict[int, str] List of errors for failed requests (indexed by position)
total_requests int 0 Total number of requests in the batch
successful int 0 Number of successful completions
failed int 0 Number of failed requests
total_tokens int 0 Total tokens used across all requests

Class VLLMConfig

Configuration for vLLM client.

Fields:

Field Type Default Description
base_url str 'http://localhost:8000/v1' vLLM server base URL (default: http://localhost:8000/v1)
api_key Optional[str] None Optional API key for authentication
timeout int 120 Request timeout in seconds

Class VLLMGuidedParams

Guided decoding parameters for constrained generation.

vLLM supports constraining output to specific patterns using JSON schemas, regular expressions, or predefined choices. Only one constraint type can be active at a time.

Fields:

Field Type Default Description
guided_json Optional[Dict[str, Any]] None JSON schema for constrained output
guided_regex Optional[str] None Regular expression pattern to match
guided_choice Optional[List[str]] None List of valid output choices
guided_grammar Optional[str] None BNF grammar for constrained output

Method VLLMGuidedParams.check_mutually_exclusive

Ensure only one guided constraint is specified.

check_mutually_exclusive() -> VLLMGuidedParams

Returns: VLLMGuidedParams

Method VLLMGuidedParams.to_extra_body

Convert to vLLM extra_body format.

to_extra_body() -> Dict[str, Any]

Returns: Dict[str, Any] — Dict with the active guided constraint

Class VLLMLoRARequest

LoRA adapter configuration for vLLM requests.

vLLM supports dynamically loading and switching between LoRA adapters at request time, enabling fine-tuned behavior without reloading models.

Fields:

Field Type Default Description
lora_name str Name of the LoRA adapter to use
lora_int_id Optional[int] None Optional integer ID for the LoRA adapter
lora_local_path Optional[str] None Optional local path to LoRA adapter weights

Method VLLMLoRARequest.to_extra_body

Convert to vLLM lora_request format.

to_extra_body() -> Dict[str, Any]

Returns: Dict[str, Any] — Dict with LoRA request configuration

Class VLLMSamplingParams

Extended sampling parameters for vLLM.

These parameters extend the standard OpenAI-compatible sampling with vLLM-specific options for fine-grained control.

Fields:

Field Type Default Description
top_k int -1 Top-k sampling (-1 to disable)
min_p float 0.0 Minimum probability threshold (0.0 to 1.0)
repetition_penalty float 1.0 Penalty for repeated tokens (>1.0 to discourage)
length_penalty float 1.0 Length penalty for beam search
presence_penalty float 0.0 Penalty for new tokens based on presence
frequency_penalty float 0.0 Penalty for new tokens based on frequency

Method VLLMSamplingParams.to_extra_body

Convert to vLLM extra_body format.

Only includes non-default values to minimize request payload.

to_extra_body() -> Dict[str, Any]

Returns: Dict[str, Any] — Dict with vLLM-specific sampling parameters

Class VLLMServerInfo

vLLM server information model.

Contains metadata about the running vLLM server instance.

Fields:

Field Type Default Description
version Optional[str] None vLLM version string
model_id Optional[str] None Currently loaded model identifier
gpu_memory_utilization Optional[float] None GPU memory utilization (0.0 to 1.0)
max_model_len Optional[int] None Maximum model context length
tensor_parallel_size Optional[int] None Number of GPUs for tensor parallelism

Function pydantic_to_guided_json

Convert a Pydantic model class to vLLM guided_json schema.

This helper enables structured output by converting Pydantic models to JSON schemas that vLLM can use for constrained generation.

pydantic_to_guided_json(model: Type[BaseModel]) -> Dict[str, Any]

Parameter Type Default Description
model Type[BaseModel] A Pydantic BaseModel class (not an instance)

Returns: Dict[str, Any] — JSON schema dict compatible with vLLM's guided_json parameter

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally