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

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: 1 addition & 1 deletion js/plugins/google-genai/src/common/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
Part as GeminiPart,
Schema,
SchemaType,
} from './types';
} from './types.js';

export function toGeminiTool(tool: ToolDefinition): FunctionDeclaration {
const declaration: FunctionDeclaration = {
Expand Down
2 changes: 1 addition & 1 deletion js/plugins/google-genai/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
GenerateContentStreamResult,
Part,
isObject,
} from './types';
} from './types.js';

/**
* Safely extracts the error message from the error.
Expand Down
6 changes: 3 additions & 3 deletions js/plugins/google-genai/src/googleai/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import {
z,
} from 'genkit';
import { embedderRef } from 'genkit/embedder';
import { embedContent } from './client';
import { embedContent } from './client.js';
import {
EmbedContentRequest,
GoogleAIPluginOptions,
Model,
TaskTypeSchema,
} from './types';
} from './types.js';
import {
calculateApiKey,
checkApiKey,
checkModelName,
extractVersion,
} from './utils';
} from './utils.js';

export const EmbeddingConfigSchema = z
.object({
Expand Down
8 changes: 4 additions & 4 deletions js/plugins/google-genai/src/googleai/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ import {
toGeminiMessage,
toGeminiSystemInstruction,
toGeminiTool,
} from '../common/converters';
} from '../common/converters.js';
import {
generateContent,
generateContentStream,
getGoogleAIUrl,
} from './client';
} from './client.js';
import {
ClientOptions,
Content as GeminiMessage,
Expand All @@ -57,14 +57,14 @@ import {
SafetySetting,
Tool,
ToolConfig,
} from './types';
} from './types.js';
import {
calculateApiKey,
checkApiKey,
checkModelName,
cleanSchema,
extractVersion,
} from './utils';
} from './utils.js';

/**
* See https://ai.google.dev/gemini-api/docs/safety-settings#safety-filters.
Expand Down
2 changes: 1 addition & 1 deletion js/plugins/google-genai/src/googleai/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
TaskTypeSchema,
Tool,
ToolConfig,
} from '../common/types';
} from '../common/types.js';

// This makes it easier to import all types from one place.
export {
Expand Down
4 changes: 2 additions & 2 deletions js/plugins/google-genai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export {
type GeminiTtsConfig,
type GoogleAIPluginOptions,
type ImagenConfig,
} from './googleai';
export { vertexAI } from './vertexai';
} from './googleai/index.js';
export { vertexAI } from './vertexai/index.js';
11 changes: 7 additions & 4 deletions js/plugins/google-genai/src/vertexai/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
*/

import { GoogleAuth } from 'google-auth-library';
import { extractErrMsg, processStream } from '../common/utils';
import { getGenkitClientHeader } from '../common/utils.js';
import {
extractErrMsg,
getGenkitClientHeader,
processStream,
} from '../common/utils.js';
import {
ClientOptions,
EmbedContentRequest,
Expand All @@ -33,8 +36,8 @@ import {
VeoOperation,
VeoOperationRequest,
VeoPredictRequest,
} from './types';
import { calculateApiKey, checkSupportedResourceMethod } from './utils';
} from './types.js';
import { calculateApiKey, checkSupportedResourceMethod } from './utils.js';

export async function listModels(
clientOptions: ClientOptions
Expand Down
14 changes: 7 additions & 7 deletions js/plugins/google-genai/src/vertexai/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import {
ImagenPredictResponse,
ImagenPrediction,
SafetySetting,
} from '../common/types';
import { SafetySettingsSchema } from './gemini';
import { ImagenConfigSchemaType } from './imagen';
import { LyriaConfigSchemaType } from './lyria';
} from '../common/types.js';
import { SafetySettingsSchema } from './gemini.js';
import { ImagenConfigSchemaType } from './imagen.js';
import { LyriaConfigSchemaType } from './lyria.js';
import {
LyriaInstance,
LyriaParameters,
Expand All @@ -47,14 +47,14 @@ import {
VeoOperation,
VeoOperationRequest,
VeoPredictRequest,
} from './types';
} from './types.js';
import {
checkSupportedMimeType,
extractMedia,
extractMimeType,
extractText,
} from './utils';
import { VeoConfigSchemaType } from './veo';
} from './utils.js';
import { VeoConfigSchemaType } from './veo.js';

export function toGeminiSafetySettings(
genkitSettings?: z.infer<typeof SafetySettingsSchema>[]
Expand Down
6 changes: 3 additions & 3 deletions js/plugins/google-genai/src/vertexai/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
type EmbedderAction,
type EmbedderReference,
} from 'genkit/embedder';
import { embedContent } from './client';
import { embedContent } from './client.js';
import {
ClientOptions,
EmbedContentRequest,
Expand All @@ -32,8 +32,8 @@ import {
VertexPluginOptions,
isMultimodalEmbeddingPrediction,
isObject,
} from './types';
import { checkModelName, extractVersion } from './utils';
} from './types.js';
import { checkModelName, extractVersion } from './utils.js';

export const EmbeddingConfigSchema = z
.object({
Expand Down
10 changes: 5 additions & 5 deletions js/plugins/google-genai/src/vertexai/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ import {
toGeminiMessage,
toGeminiSystemInstruction,
toGeminiTool,
} from '../common/converters';
} from '../common/converters.js';
import {
generateContent,
generateContentStream,
getVertexAIUrl,
} from './client';
import { toGeminiLabels, toGeminiSafetySettings } from './converters';
} from './client.js';
import { toGeminiLabels, toGeminiSafetySettings } from './converters.js';
import {
ClientOptions,
Content,
Expand All @@ -57,14 +57,14 @@ import {
Tool,
ToolConfig,
VertexPluginOptions,
} from './types';
} from './types.js';
import {
calculateApiKey,
checkModelName,
cleanSchema,
extractVersion,
modelName,
} from './utils';
} from './utils.js';

export const SafetySettingsSchema = z.object({
category: z.enum([
Expand Down
6 changes: 3 additions & 3 deletions js/plugins/google-genai/src/vertexai/imagen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
ModelReference,
modelRef,
} from 'genkit/model';
import { imagenPredict } from './client';
import { fromImagenResponse, toImagenPredictRequest } from './converters';
import { imagenPredict } from './client.js';
import { fromImagenResponse, toImagenPredictRequest } from './converters.js';
import { ClientOptions, Model, VertexPluginOptions } from './types.js';
import { checkModelName, extractVersion, modelName } from './utils';
import { checkModelName, extractVersion, modelName } from './utils.js';

/**
* See https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/imagen-api.
Expand Down
8 changes: 4 additions & 4 deletions js/plugins/google-genai/src/vertexai/lyria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import {
z,
} from 'genkit';
import { ModelAction, ModelInfo } from 'genkit/model';
import { lyriaPredict } from './client';
import { fromLyriaResponse, toLyriaPredictRequest } from './converters';
import { ClientOptions, Model, VertexPluginOptions } from './types';
import { checkModelName, extractVersion } from './utils';
import { lyriaPredict } from './client.js';
import { fromLyriaResponse, toLyriaPredictRequest } from './converters.js';
import { ClientOptions, Model, VertexPluginOptions } from './types.js';
import { checkModelName, extractVersion } from './utils.js';

export const LyriaConfigSchema = z
.object({
Expand Down
2 changes: 1 addition & 1 deletion js/plugins/google-genai/src/vertexai/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
isGoogleSearchRetrievalTool,
isObject,
isRetrievalTool,
} from '../common/types';
} from '../common/types.js';

// This makes it easier to import all types from one place
export {
Expand Down
2 changes: 1 addition & 1 deletion js/plugins/google-genai/src/vertexai/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
GlobalClientOptions,
RegionalClientOptions,
VertexPluginOptions,
} from './types';
} from './types.js';

export {
checkModelName,
Expand Down
8 changes: 4 additions & 4 deletions js/plugins/google-genai/src/vertexai/veo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import {
type Genkit,
} from 'genkit';
import { BackgroundModelAction, ModelInfo } from 'genkit/model';
import { veoCheckOperation, veoPredict } from './client';
import { veoCheckOperation, veoPredict } from './client.js';
import {
fromVeoOperation,
toVeoModel,
toVeoOperationRequest,
toVeoPredictRequest,
} from './converters';
import { ClientOptions, Model, VertexPluginOptions } from './types';
import { checkModelName, extractVersion } from './utils';
} from './converters.js';
import { ClientOptions, Model, VertexPluginOptions } from './types.js';
import { checkModelName, extractVersion } from './utils.js';

export const VeoConfigSchema = z
.object({
Expand Down
6 changes: 3 additions & 3 deletions js/plugins/google-genai/tests/common/converters_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import {
toGeminiMessage,
toGeminiSystemInstruction,
toGeminiTool,
} from '../../src/common/converters';
import type { GenerateContentCandidate } from '../../src/common/types';
} from '../../src/common/converters.js';
import type { GenerateContentCandidate } from '../../src/common/types.js';
import {
ExecutableCodeLanguage,
FunctionCallingMode,
Outcome,
SchemaType,
} from '../../src/common/types';
} from '../../src/common/types.js';

describe('toGeminiMessage', () => {
const testCases = [
Expand Down
2 changes: 1 addition & 1 deletion js/plugins/google-genai/tests/common/utils_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
extractText,
extractVersion,
modelName,
} from '../../src/common/utils';
} from '../../src/common/utils.js';

describe('Common Utils', () => {
describe('extractErrMsg', () => {
Expand Down
6 changes: 3 additions & 3 deletions js/plugins/google-genai/tests/googleai/client_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
FinishReason,
HarmCategory,
HarmProbability,
} from '../../src/common/types';
} from '../../src/common/types.js';
import { getGenkitClientHeader } from '../../src/common/utils.js';
import {
TEST_ONLY,
Expand All @@ -34,7 +34,7 @@ import {
listModels,
veoCheckOperation,
veoPredict,
} from '../../src/googleai/client';
} from '../../src/googleai/client.js';
import {
ClientOptions,
EmbedContentRequest,
Expand All @@ -47,7 +47,7 @@ import {
Model,
VeoOperation,
VeoPredictRequest,
} from '../../src/googleai/types';
} from '../../src/googleai/types.js';

const { getAbortSignal } = TEST_ONLY;

Expand Down
9 changes: 6 additions & 3 deletions js/plugins/google-genai/tests/googleai/embedder_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ import * as assert from 'assert';
import { Document, Genkit, GenkitError } from 'genkit';
import { afterEach, beforeEach, describe, it } from 'node:test';
import * as sinon from 'sinon';
import { EmbeddingConfig, defineEmbedder } from '../../src/googleai/embedder';
import {
EmbeddingConfig,
defineEmbedder,
} from '../../src/googleai/embedder.js';
import {
EmbedContentResponse,
GoogleAIPluginOptions,
} from '../../src/googleai/types';
import { MISSING_API_KEY_ERROR } from '../../src/googleai/utils';
} from '../../src/googleai/types.js';
import { MISSING_API_KEY_ERROR } from '../../src/googleai/utils.js';

describe('defineGoogleAIEmbedder', () => {
let mockGenkit: sinon.SinonStubbedInstance<Genkit>;
Expand Down
6 changes: 3 additions & 3 deletions js/plugins/google-genai/tests/googleai/gemini_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import {
GeminiTtsConfigSchema,
defineModel,
model,
} from '../../src/googleai/gemini';
} from '../../src/googleai/gemini.js';
import {
FinishReason,
GenerateContentRequest,
GenerateContentResponse,
GoogleAIPluginOptions,
} from '../../src/googleai/types';
import { MISSING_API_KEY_ERROR } from '../../src/googleai/utils';
} from '../../src/googleai/types.js';
import { MISSING_API_KEY_ERROR } from '../../src/googleai/utils.js';

describe('Google AI Gemini', () => {
let mockGenkit: sinon.SinonStubbedInstance<Genkit>;
Expand Down
6 changes: 3 additions & 3 deletions js/plugins/google-genai/tests/googleai/imagen_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import { GenerateRequest, getBasicUsageStats } from 'genkit/model';
import { afterEach, beforeEach, describe, it } from 'node:test';
import * as sinon from 'sinon';
import { getGenkitClientHeader } from '../../src/common/utils.js';
import { getGoogleAIUrl } from '../../src/googleai/client';
import { getGoogleAIUrl } from '../../src/googleai/client.js';
import {
ImagenConfig,
ImagenConfigSchema,
TEST_ONLY,
defineModel,
model,
} from '../../src/googleai/imagen';
} from '../../src/googleai/imagen.js';
import {
ImagenPredictRequest,
ImagenPredictResponse,
Expand All @@ -36,7 +36,7 @@ import {
import {
API_KEY_FALSE_ERROR,
MISSING_API_KEY_ERROR,
} from '../../src/googleai/utils';
} from '../../src/googleai/utils.js';

const { toImagenParameters, fromImagenPrediction } = TEST_ONLY;

Expand Down
2 changes: 1 addition & 1 deletion js/plugins/google-genai/tests/googleai/utils_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
calculateApiKey,
checkApiKey,
getApiKeyFromEnvVar,
} from '../../src/googleai/utils'; // Assuming the file is named utils.ts
} from '../../src/googleai/utils.js'; // Assuming the file is named utils.ts

describe('API Key Utils', () => {
let originalEnv: NodeJS.ProcessEnv;
Expand Down
Loading