prompt_embeds_parts
The prompt_embeds chat content part, extended to carry a content identifier hash.
vLLM's part carries base64 tensor bytes and nothing else:
Protopia Output Protection additionally accepts an id, so a client that has uploaded embeddings once can reference them on later turns instead of
re-sending them:
This module only reads and classifies parts. Resolving an identifier, answering a miss and rewriting a part for vLLM all belong to the caller.
Classes:
| Name | Description |
|---|---|
MalformedPromptEmbedsPartError |
Raised when a content part claims to carry prompt embeddings but cannot be acted on. |
PromptEmbedsPart |
One |
Functions:
| Name | Description |
|---|---|
iter_prompt_embeds_parts |
Find and classify every |
Attributes:
| Name | Type | Description |
|---|---|---|
PROMPT_EMBEDS_PART_TYPE |
Final[str]
|
Value of a content part's |
PROMPT_EMBEDS_PART_TYPE
module-attribute
¶
Value of a content part's type that marks it as carrying prompt embeddings.
MalformedPromptEmbedsPartError
¶
Bases: ValueError
Raised when a content part claims to carry prompt embeddings but cannot be acted on.
PromptEmbedsPart
dataclass
¶
One prompt_embeds content part, located within a request body and classified.
Attributes:
| Name | Type | Description |
|---|---|---|
has_data |
bool
|
Whether the part carries base64 tensor bytes of its own. |
identifier |
str | None
|
The content identifier the part references, or |
needs_resolving |
bool
|
Whether this part references embeddings it does not carry, and so has to be looked up. |
part |
dict[str, object]
|
The part itself, so a caller holding this can rewrite it in place. |
has_data
instance-attribute
¶
has_data: bool
Whether the part carries base64 tensor bytes of its own.
identifier
instance-attribute
¶
identifier: str | None
The content identifier the part references, or None for a plain vLLM part.
iter_prompt_embeds_parts
¶
Find and classify every prompt_embeds content part in a chat completion request body.
Anything that is not shaped like a chat request is ignored rather than rejected, this runs ahead of vLLM's own validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
object
|
The decoded JSON request body. |
required |
Returns:
| Type | Description |
|---|---|
list[PromptEmbedsPart]
|
Every |
Raises:
| Type | Description |
|---|---|
MalformedPromptEmbedsPartError
|
If any such part cannot be acted on. |