@layer-ai/core 2.0.41 → 2.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FunctionCallingConfigMode } from '@google/genai';
|
|
2
|
-
import { LayerRequest, LayerResponse, Role, FinishReason, VideoSize } from '@layer-ai/sdk';
|
|
2
|
+
import { LayerRequest, LayerResponse, Role, FinishReason, ImageSize, VideoSize } from '@layer-ai/sdk';
|
|
3
3
|
import { BaseProviderAdapter } from './base-adapter.js';
|
|
4
4
|
import { type Provider } from "../../lib/provider-constants.js";
|
|
5
5
|
export declare class GoogleAdapter extends BaseProviderAdapter {
|
|
@@ -7,6 +7,9 @@ export declare class GoogleAdapter extends BaseProviderAdapter {
|
|
|
7
7
|
protected roleMappings: Record<Role, string>;
|
|
8
8
|
protected finishReasonMappings: Record<string, FinishReason>;
|
|
9
9
|
protected toolChoiceMappings: Record<string, FunctionCallingConfigMode>;
|
|
10
|
+
protected imageSizeConfig: Record<ImageSize, {
|
|
11
|
+
aspectRatio: string;
|
|
12
|
+
}>;
|
|
10
13
|
protected videoSizeConfig: Record<VideoSize, {
|
|
11
14
|
aspectRatio: string;
|
|
12
15
|
resolution: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-adapter.d.ts","sourceRoot":"","sources":["../../../src/services/providers/google-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,yBAAyB,EAI1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAgB1E,qBAAa,aAAc,SAAQ,mBAAmB;IACpD,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAm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AAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAIrE;IAEF,SAAS,CAAC,eAAe,EAAE,MAAM,CAAC,SAAS,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAQnE;IAEF,SAAS,CAAC,eAAe,EAAE,MAAM,CAC/B,SAAS,EACT;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAC5C,CAKC;IAEI,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBnE,UAAU,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,aAAa,CAAC;YAYzE,UAAU;YAwLT,gBAAgB;YAmNjB,qBAAqB;YA6CrB,gBAAgB;YAsChB,qBAAqB;YAsHrB,kBAAkB;IA2ChC,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -39,6 +39,15 @@ export class GoogleAdapter extends BaseProviderAdapter {
|
|
|
39
39
|
none: FunctionCallingConfigMode.NONE,
|
|
40
40
|
required: FunctionCallingConfigMode.ANY,
|
|
41
41
|
};
|
|
42
|
+
this.imageSizeConfig = {
|
|
43
|
+
'256x256': { aspectRatio: '1:1' },
|
|
44
|
+
'512x512': { aspectRatio: '1:1' },
|
|
45
|
+
'1024x1024': { aspectRatio: '1:1' },
|
|
46
|
+
'1792x1024': { aspectRatio: '16:9' },
|
|
47
|
+
'1024x1792': { aspectRatio: '9:16' },
|
|
48
|
+
'1536x1024': { aspectRatio: '3:2' },
|
|
49
|
+
'1024x1536': { aspectRatio: '2:3' },
|
|
50
|
+
};
|
|
42
51
|
this.videoSizeConfig = {
|
|
43
52
|
'720x1280': { aspectRatio: '9:16', resolution: '720p' },
|
|
44
53
|
'1280x720': { aspectRatio: '16:9', resolution: '720p' },
|
|
@@ -412,6 +421,9 @@ export class GoogleAdapter extends BaseProviderAdapter {
|
|
|
412
421
|
if (!model) {
|
|
413
422
|
throw new Error('Model is required for chat completion');
|
|
414
423
|
}
|
|
424
|
+
// Derive aspect ratio from size if provided
|
|
425
|
+
const sizeConfig = image.size ? this.imageSizeConfig[image.size] : null;
|
|
426
|
+
const aspectRatio = sizeConfig?.aspectRatio;
|
|
415
427
|
// Google's Imagen API via generateImages
|
|
416
428
|
const response = await client.models.generateImages({
|
|
417
429
|
model: model,
|
|
@@ -419,6 +431,7 @@ export class GoogleAdapter extends BaseProviderAdapter {
|
|
|
419
431
|
config: {
|
|
420
432
|
numberOfImages: image.count || 1,
|
|
421
433
|
...(image.seed !== undefined && { seed: image.seed }),
|
|
434
|
+
...(aspectRatio && { aspectRatio }),
|
|
422
435
|
},
|
|
423
436
|
});
|
|
424
437
|
const images = response.generatedImages?.map((img) => ({
|