thebird 1.2.2 → 1.2.3
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/index.js +6 -6
- package/lib/convert.js +2 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7,18 +7,18 @@ const { resolveTransformers, applyRequestTransformers } = require('./lib/transfo
|
|
|
7
7
|
const openaiProv = require('./lib/providers/openai');
|
|
8
8
|
|
|
9
9
|
function streamGemini({ model, system, messages, tools, onStepFinish, apiKey,
|
|
10
|
-
temperature, maxOutputTokens, topP, topK, safetySettings }) {
|
|
10
|
+
temperature, maxOutputTokens, topP, topK, safetySettings, responseModalities }) {
|
|
11
11
|
return {
|
|
12
|
-
fullStream: createFullStream({ model, system, messages, tools, onStepFinish, apiKey, temperature, maxOutputTokens, topP, topK, safetySettings }),
|
|
12
|
+
fullStream: createFullStream({ model, system, messages, tools, onStepFinish, apiKey, temperature, maxOutputTokens, topP, topK, safetySettings, responseModalities }),
|
|
13
13
|
warnings: Promise.resolve([])
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async function* createFullStream({ model, system, messages, tools, onStepFinish, apiKey, temperature, maxOutputTokens, topP, topK, safetySettings }) {
|
|
17
|
+
async function* createFullStream({ model, system, messages, tools, onStepFinish, apiKey, temperature, maxOutputTokens, topP, topK, safetySettings, responseModalities }) {
|
|
18
18
|
const client = getClient(apiKey);
|
|
19
19
|
const modelId = extractModelId(model);
|
|
20
20
|
let contents = convertMessages(messages);
|
|
21
|
-
const { config } = buildConfig({ system, tools, temperature, maxOutputTokens, topP, topK, safetySettings });
|
|
21
|
+
const { config } = buildConfig({ system, tools, temperature, maxOutputTokens, topP, topK, safetySettings, responseModalities });
|
|
22
22
|
while (true) {
|
|
23
23
|
yield { type: 'start-step' };
|
|
24
24
|
try {
|
|
@@ -66,11 +66,11 @@ async function* createFullStream({ model, system, messages, tools, onStepFinish,
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
async function generateGemini({ model, system, messages, tools, apiKey, temperature, maxOutputTokens, topP, topK, safetySettings }) {
|
|
69
|
+
async function generateGemini({ model, system, messages, tools, apiKey, temperature, maxOutputTokens, topP, topK, safetySettings, responseModalities }) {
|
|
70
70
|
const client = getClient(apiKey);
|
|
71
71
|
const modelId = extractModelId(model);
|
|
72
72
|
let contents = convertMessages(messages);
|
|
73
|
-
const { config } = buildConfig({ system, tools, temperature, maxOutputTokens, topP, topK, safetySettings });
|
|
73
|
+
const { config } = buildConfig({ system, tools, temperature, maxOutputTokens, topP, topK, safetySettings, responseModalities });
|
|
74
74
|
while (true) {
|
|
75
75
|
const response = await withRetry(() => client.models.generateContent({ model: modelId, contents, config }));
|
|
76
76
|
const candidate = response.candidates?.[0];
|
package/lib/convert.js
CHANGED
|
@@ -69,7 +69,7 @@ function extractModelId(model) {
|
|
|
69
69
|
return 'gemini-2.0-flash';
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function buildConfig({ system, tools, temperature, maxOutputTokens, topP, topK, safetySettings } = {}) {
|
|
72
|
+
function buildConfig({ system, tools, temperature, maxOutputTokens, topP, topK, safetySettings, responseModalities } = {}) {
|
|
73
73
|
const geminiTools = convertTools(tools);
|
|
74
74
|
const config = {
|
|
75
75
|
maxOutputTokens: maxOutputTokens ?? 8192,
|
|
@@ -80,6 +80,7 @@ function buildConfig({ system, tools, temperature, maxOutputTokens, topP, topK,
|
|
|
80
80
|
if (system) config.systemInstruction = system;
|
|
81
81
|
if (geminiTools.length > 0) config.tools = [{ functionDeclarations: geminiTools }];
|
|
82
82
|
if (safetySettings) config.safetySettings = safetySettings;
|
|
83
|
+
if (responseModalities) config.responseModalities = responseModalities;
|
|
83
84
|
return { config, geminiTools };
|
|
84
85
|
}
|
|
85
86
|
|
package/package.json
CHANGED