mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-25 12:51:14 +00:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
// Public embedding input contract for text and inline multimodal parts.
|
|
|
|
/** Text part passed through embedding providers that support structured input. */
|
|
type EmbeddingInputTextPart = {
|
|
type: "text";
|
|
text: string;
|
|
};
|
|
|
|
/** Inline binary payload encoded for providers with multimodal embedding support. */
|
|
type EmbeddingInputInlineDataPart = {
|
|
type: "inline-data";
|
|
mimeType: string;
|
|
data: string;
|
|
};
|
|
|
|
/** Single structured embedding input part. */
|
|
type EmbeddingInputPart = EmbeddingInputTextPart | EmbeddingInputInlineDataPart;
|
|
|
|
/** Provider-facing input while preserving the plain text fallback. */
|
|
export type EmbeddingInput = {
|
|
text: string;
|
|
parts?: EmbeddingInputPart[];
|
|
};
|
|
|
|
/** Build the common text-only embedding input shape. */
|
|
export function buildTextEmbeddingInput(text: string): EmbeddingInput {
|
|
return { text };
|
|
}
|
|
|
|
/** Return true when a chunk needs structured provider handling, not text splitting. */
|
|
export function hasNonTextEmbeddingParts(input: EmbeddingInput | undefined): boolean {
|
|
if (!input?.parts?.length) {
|
|
return false;
|
|
}
|
|
return input.parts.some((part) => part.type === "inline-data");
|
|
}
|