@providerprotocol/ai 0.0.24 → 0.0.26
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.
- package/dist/google/index.d.ts +34 -1
- package/dist/google/index.js +42 -1
- package/dist/google/index.js.map +1 -1
- package/dist/openrouter/index.d.ts +59 -0
- package/dist/openrouter/index.js +114 -19
- package/dist/openrouter/index.js.map +1 -1
- package/package.json +1 -1
package/dist/google/index.d.ts
CHANGED
|
@@ -42,6 +42,17 @@ interface GoogleLLMParams {
|
|
|
42
42
|
responseMimeType?: 'text/plain' | 'application/json';
|
|
43
43
|
/** Response schema for structured output */
|
|
44
44
|
responseSchema?: Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Modalities to generate in the response.
|
|
47
|
+
*
|
|
48
|
+
* Use `['IMAGE']` or `['TEXT', 'IMAGE']` with Gemini image generation models
|
|
49
|
+
* (e.g., gemini-2.5-flash-image aka Nano Banana).
|
|
50
|
+
*/
|
|
51
|
+
responseModalities?: GoogleResponseModality[];
|
|
52
|
+
/**
|
|
53
|
+
* Image generation configuration for Gemini image response modalities.
|
|
54
|
+
*/
|
|
55
|
+
imageConfig?: GoogleImageConfig;
|
|
45
56
|
/**
|
|
46
57
|
* Presence penalty for new topics
|
|
47
58
|
* Positive values encourage discussing new topics
|
|
@@ -124,6 +135,28 @@ interface GoogleLLMParams {
|
|
|
124
135
|
*/
|
|
125
136
|
toolConfig?: GoogleToolConfig;
|
|
126
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Output modality enum values for Gemini responseModalities.
|
|
140
|
+
*
|
|
141
|
+
* The API supports TEXT, IMAGE, and AUDIO response types. Some SDK examples
|
|
142
|
+
* use Title Case values, so both are accepted here.
|
|
143
|
+
*/
|
|
144
|
+
type GoogleResponseModality = 'TEXT' | 'IMAGE' | 'AUDIO' | 'Text' | 'Image' | 'Audio';
|
|
145
|
+
/**
|
|
146
|
+
* Image generation configuration for Gemini response modalities.
|
|
147
|
+
*/
|
|
148
|
+
interface GoogleImageConfig {
|
|
149
|
+
/**
|
|
150
|
+
* Preferred aspect ratio for generated images.
|
|
151
|
+
* Example: "1:1", "9:16", "16:9".
|
|
152
|
+
*/
|
|
153
|
+
aspectRatio?: string;
|
|
154
|
+
/**
|
|
155
|
+
* Preferred output size for generated images.
|
|
156
|
+
* Example: "1024x1024".
|
|
157
|
+
*/
|
|
158
|
+
imageSize?: string;
|
|
159
|
+
}
|
|
127
160
|
/**
|
|
128
161
|
* Configuration for extended thinking/reasoning in Gemini 2.5+ and 3+ models.
|
|
129
162
|
*
|
|
@@ -980,4 +1013,4 @@ declare const google: Provider<unknown> & {
|
|
|
980
1013
|
};
|
|
981
1014
|
};
|
|
982
1015
|
|
|
983
|
-
export { type CacheCreateOptions, type CacheListOptions, type GoogleBuiltInTool, type GoogleCacheCreateRequest, type GoogleCacheListResponse, type GoogleCacheResponse, type GoogleCacheUpdateRequest, type GoogleCodeExecutionResult, type GoogleCodeExecutionTool, type GoogleEmbedParams, type GoogleFileSearchTool, type GoogleGroundingMetadata, type GoogleHeaders, type GoogleLLMParams, type GoogleMapsTool, type GoogleSearchTool, type GoogleTaskType, type GoogleToolConfig, type GoogleUrlContextTool, cache, google, tools };
|
|
1016
|
+
export { type CacheCreateOptions, type CacheListOptions, type GoogleBuiltInTool, type GoogleCacheCreateRequest, type GoogleCacheListResponse, type GoogleCacheResponse, type GoogleCacheUpdateRequest, type GoogleCodeExecutionResult, type GoogleCodeExecutionTool, type GoogleEmbedParams, type GoogleFileSearchTool, type GoogleGroundingMetadata, type GoogleHeaders, type GoogleImageConfig, type GoogleLLMParams, type GoogleMapsTool, type GoogleResponseModality, type GoogleSearchTool, type GoogleTaskType, type GoogleToolConfig, type GoogleUrlContextTool, cache, google, tools };
|
package/dist/google/index.js
CHANGED
|
@@ -281,6 +281,16 @@ function transformResponse(data) {
|
|
|
281
281
|
args: fc.functionCall.args,
|
|
282
282
|
thoughtSignature: fc.thoughtSignature
|
|
283
283
|
});
|
|
284
|
+
} else if ("inlineData" in part) {
|
|
285
|
+
const imagePart = part;
|
|
286
|
+
const dataString = imagePart.inlineData.data;
|
|
287
|
+
if (dataString) {
|
|
288
|
+
content.push({
|
|
289
|
+
type: "image",
|
|
290
|
+
mimeType: imagePart.inlineData.mimeType ?? "image/png",
|
|
291
|
+
source: { type: "base64", data: dataString }
|
|
292
|
+
});
|
|
293
|
+
}
|
|
284
294
|
} else if ("codeExecutionResult" in part) {
|
|
285
295
|
const codeResult = part;
|
|
286
296
|
if (codeResult.codeExecutionResult.output) {
|
|
@@ -326,6 +336,7 @@ function createStreamState() {
|
|
|
326
336
|
reasoning: "",
|
|
327
337
|
thoughtSignature: void 0,
|
|
328
338
|
toolCalls: [],
|
|
339
|
+
images: [],
|
|
329
340
|
finishReason: null,
|
|
330
341
|
inputTokens: 0,
|
|
331
342
|
outputTokens: 0,
|
|
@@ -387,6 +398,20 @@ function transformStreamChunk(chunk, state) {
|
|
|
387
398
|
argumentsJson: JSON.stringify(fc.functionCall.args)
|
|
388
399
|
}
|
|
389
400
|
});
|
|
401
|
+
} else if ("inlineData" in part) {
|
|
402
|
+
const imagePart = part;
|
|
403
|
+
const dataString = imagePart.inlineData.data;
|
|
404
|
+
if (dataString) {
|
|
405
|
+
state.images.push({
|
|
406
|
+
data: dataString,
|
|
407
|
+
mimeType: imagePart.inlineData.mimeType ?? "image/png"
|
|
408
|
+
});
|
|
409
|
+
events.push({
|
|
410
|
+
type: StreamEventType.ImageDelta,
|
|
411
|
+
index: state.images.length - 1,
|
|
412
|
+
delta: { data: decodeBase64(dataString) }
|
|
413
|
+
});
|
|
414
|
+
}
|
|
390
415
|
} else if ("codeExecutionResult" in part) {
|
|
391
416
|
const codeResult = part;
|
|
392
417
|
if (codeResult.codeExecutionResult.output) {
|
|
@@ -424,6 +449,13 @@ function buildResponseFromState(state) {
|
|
|
424
449
|
} catch {
|
|
425
450
|
}
|
|
426
451
|
}
|
|
452
|
+
for (const imageData of state.images) {
|
|
453
|
+
content.push({
|
|
454
|
+
type: "image",
|
|
455
|
+
mimeType: imageData.mimeType,
|
|
456
|
+
source: { type: "base64", data: imageData.data }
|
|
457
|
+
});
|
|
458
|
+
}
|
|
427
459
|
for (const tc of state.toolCalls) {
|
|
428
460
|
const toolCallId = tc.id || createGoogleToolCallId(tc.name, toolCalls.length);
|
|
429
461
|
toolCalls.push({
|
|
@@ -479,6 +511,14 @@ function normalizeStopReason(reason) {
|
|
|
479
511
|
return "end_turn";
|
|
480
512
|
}
|
|
481
513
|
}
|
|
514
|
+
function decodeBase64(base64) {
|
|
515
|
+
const binaryString = atob(base64);
|
|
516
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
517
|
+
for (let i = 0; i < binaryString.length; i += 1) {
|
|
518
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
519
|
+
}
|
|
520
|
+
return bytes;
|
|
521
|
+
}
|
|
482
522
|
|
|
483
523
|
// src/providers/google/llm.ts
|
|
484
524
|
var GOOGLE_API_BASE = "https://generativelanguage.googleapis.com/v1beta";
|
|
@@ -488,7 +528,8 @@ var GOOGLE_CAPABILITIES = {
|
|
|
488
528
|
structuredOutput: true,
|
|
489
529
|
imageInput: true,
|
|
490
530
|
videoInput: true,
|
|
491
|
-
audioInput: true
|
|
531
|
+
audioInput: true,
|
|
532
|
+
imageOutput: true
|
|
492
533
|
};
|
|
493
534
|
function buildUrl(modelId, action) {
|
|
494
535
|
return `${GOOGLE_API_BASE}/models/${modelId}:${action}`;
|