Merged via squash. Prepared head SHA: a994c07190a2062322f459c928b6cd74f9803d88 Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com> Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com> Reviewed-by: @gumadeiras
35 lines
825 B
TypeScript
35 lines
825 B
TypeScript
export type EmbeddingInputTextPart = {
|
|
type: "text";
|
|
text: string;
|
|
};
|
|
|
|
export type EmbeddingInputInlineDataPart = {
|
|
type: "inline-data";
|
|
mimeType: string;
|
|
data: string;
|
|
};
|
|
|
|
export type EmbeddingInputPart = EmbeddingInputTextPart | EmbeddingInputInlineDataPart;
|
|
|
|
export type EmbeddingInput = {
|
|
text: string;
|
|
parts?: EmbeddingInputPart[];
|
|
};
|
|
|
|
export function buildTextEmbeddingInput(text: string): EmbeddingInput {
|
|
return { text };
|
|
}
|
|
|
|
export function isInlineDataEmbeddingInputPart(
|
|
part: EmbeddingInputPart,
|
|
): part is EmbeddingInputInlineDataPart {
|
|
return part.type === "inline-data";
|
|
}
|
|
|
|
export function hasNonTextEmbeddingParts(input: EmbeddingInput | undefined): boolean {
|
|
if (!input?.parts?.length) {
|
|
return false;
|
|
}
|
|
return input.parts.some((part) => isInlineDataEmbeddingInputPart(part));
|
|
}
|