Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api-report/genai-node.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,9 @@ export interface EmbedContentBatch {
// @public
export interface EmbedContentConfig {
abortSignal?: AbortSignal;
audioTrackExtraction?: boolean;
autoTruncate?: boolean;
documentOcr?: boolean;
httpOptions?: HttpOptions;
mimeType?: string;
outputDimensionality?: number;
Expand Down
2 changes: 2 additions & 0 deletions api-report/genai-web.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,9 @@ export interface EmbedContentBatch {
// @public
export interface EmbedContentConfig {
abortSignal?: AbortSignal;
audioTrackExtraction?: boolean;
autoTruncate?: boolean;
documentOcr?: boolean;
httpOptions?: HttpOptions;
mimeType?: string;
outputDimensionality?: number;
Expand Down
2 changes: 2 additions & 0 deletions api-report/genai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,9 @@ export interface EmbedContentBatch {
// @public
export interface EmbedContentConfig {
abortSignal?: AbortSignal;
audioTrackExtraction?: boolean;
autoTruncate?: boolean;
documentOcr?: boolean;
httpOptions?: HttpOptions;
mimeType?: string;
outputDimensionality?: number;
Expand Down
12 changes: 12 additions & 0 deletions src/converters/_batches_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,18 @@ export function embedContentConfigToMldev(
throw new Error('autoTruncate parameter is not supported in Gemini API.');
}

if (common.getValueByPath(fromObject, ['documentOcr']) !== undefined) {
throw new Error('documentOcr parameter is not supported in Gemini API.');
}

if (
common.getValueByPath(fromObject, ['audioTrackExtraction']) !== undefined
) {
throw new Error(
'audioTrackExtraction parameter is not supported in Gemini API.',
);
}

return toObject;
}

Expand Down
68 changes: 64 additions & 4 deletions src/converters/_models_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,18 @@ export function embedContentConfigToMldev(
throw new Error('autoTruncate parameter is not supported in Gemini API.');
}

if (common.getValueByPath(fromObject, ['documentOcr']) !== undefined) {
throw new Error('documentOcr parameter is not supported in Gemini API.');
}

if (
common.getValueByPath(fromObject, ['audioTrackExtraction']) !== undefined
) {
throw new Error(
'audioTrackExtraction parameter is not supported in Gemini API.',
);
}

return toObject;
}

Expand Down Expand Up @@ -940,7 +952,11 @@ export function embedContentConfigToVertex(
} else if (discriminatorTaskType === 'EMBED_CONTENT') {
const fromTaskType = common.getValueByPath(fromObject, ['taskType']);
if (parentObject !== undefined && fromTaskType != null) {
common.setValueByPath(parentObject, ['taskType'], fromTaskType);
common.setValueByPath(
parentObject,
['embedContentConfig', 'taskType'],
fromTaskType,
);
}
}

Expand All @@ -958,7 +974,11 @@ export function embedContentConfigToVertex(
} else if (discriminatorTitle === 'EMBED_CONTENT') {
const fromTitle = common.getValueByPath(fromObject, ['title']);
if (parentObject !== undefined && fromTitle != null) {
common.setValueByPath(parentObject, ['title'], fromTitle);
common.setValueByPath(
parentObject,
['embedContentConfig', 'title'],
fromTitle,
);
}
}

Expand Down Expand Up @@ -986,7 +1006,7 @@ export function embedContentConfigToVertex(
if (parentObject !== undefined && fromOutputDimensionality != null) {
common.setValueByPath(
parentObject,
['outputDimensionality'],
['embedContentConfig', 'outputDimensionality'],
fromOutputDimensionality,
);
}
Expand Down Expand Up @@ -1031,7 +1051,47 @@ export function embedContentConfigToVertex(
'autoTruncate',
]);
if (parentObject !== undefined && fromAutoTruncate != null) {
common.setValueByPath(parentObject, ['autoTruncate'], fromAutoTruncate);
common.setValueByPath(
parentObject,
['embedContentConfig', 'autoTruncate'],
fromAutoTruncate,
);
}
}

let discriminatorDocumentOcr = common.getValueByPath(rootObject, [
'embeddingApiType',
]);
if (discriminatorDocumentOcr === undefined) {
discriminatorDocumentOcr = 'PREDICT';
}
if (discriminatorDocumentOcr === 'EMBED_CONTENT') {
const fromDocumentOcr = common.getValueByPath(fromObject, ['documentOcr']);
if (parentObject !== undefined && fromDocumentOcr != null) {
common.setValueByPath(
parentObject,
['embedContentConfig', 'documentOcr'],
fromDocumentOcr,
);
}
}

let discriminatorAudioTrackExtraction = common.getValueByPath(rootObject, [
'embeddingApiType',
]);
if (discriminatorAudioTrackExtraction === undefined) {
discriminatorAudioTrackExtraction = 'PREDICT';
}
if (discriminatorAudioTrackExtraction === 'EMBED_CONTENT') {
const fromAudioTrackExtraction = common.getValueByPath(fromObject, [
'audioTrackExtraction',
]);
if (parentObject !== undefined && fromAudioTrackExtraction != null) {
common.setValueByPath(
parentObject,
['embedContentConfig', 'audioTrackExtraction'],
fromAudioTrackExtraction,
);
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3659,6 +3659,14 @@ export declare interface EmbedContentConfig {
will lead to an INVALID_ARGUMENT error, similar to other text APIs.
*/
autoTruncate?: boolean;
/** Vertex API only. Whether to enable OCR for document content.
Only applicable to Gemini Embedding 2 models.
*/
documentOcr?: boolean;
/** Vertex API only. Whether to extract audio from video content.
Only applicable to Gemini Embedding 2 models.
*/
audioTrackExtraction?: boolean;
}

/** Parameters for the _embed_content method. */
Expand Down
Loading