@tstdl/base 0.92.38 → 0.92.39
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/ai/ai.service.js +5 -3
- package/package.json +1 -1
package/ai/ai.service.js
CHANGED
|
@@ -202,17 +202,19 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
|
|
|
202
202
|
responseSchema: isDefined(request.generationSchema) ? convertToOpenApiSchema(request.generationSchema) : undefined,
|
|
203
203
|
frequencyPenalty: request.generationOptions?.frequencyPenalty
|
|
204
204
|
};
|
|
205
|
+
const model = request.model ?? this.defaultModel;
|
|
206
|
+
const maxModelTokens = model.includes('thinking') ? 65536 : 8192;
|
|
207
|
+
const maxTotalOutputTokens = request.generationOptions?.maxOutputTokens ?? maxModelTokens;
|
|
205
208
|
const inputContent = this.convertContents(request.contents);
|
|
206
|
-
const maxTotalOutputTokens = request.generationOptions?.maxOutputTokens ?? 8192;
|
|
207
209
|
let iterations = 0;
|
|
208
210
|
let totalPromptTokens = 0;
|
|
209
211
|
let totalOutputTokens = 0;
|
|
210
212
|
let totalTokens = 0;
|
|
211
213
|
while (totalOutputTokens < maxTotalOutputTokens) {
|
|
212
|
-
const generation = await this.getModel(
|
|
214
|
+
const generation = await this.getModel(model).generateContentStream({
|
|
213
215
|
generationConfig: {
|
|
214
216
|
...generationConfig,
|
|
215
|
-
maxOutputTokens: Math.min(
|
|
217
|
+
maxOutputTokens: Math.min(maxModelTokens, maxTotalOutputTokens - totalOutputTokens)
|
|
216
218
|
},
|
|
217
219
|
systemInstruction: request.systemInstruction,
|
|
218
220
|
tools: (isDefined(googleFunctionDeclarations) && (googleFunctionDeclarations.length > 0)) ? [{ functionDeclarations: googleFunctionDeclarations }] : undefined,
|