@cortask/core 0.2.16 → 0.2.18
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/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -279,14 +279,17 @@ var AnthropicProvider = class {
|
|
|
279
279
|
this.client = new Anthropic({ apiKey });
|
|
280
280
|
}
|
|
281
281
|
async generateText(params) {
|
|
282
|
+
const maxTokens = params.maxTokens ?? 16e3;
|
|
283
|
+
const budgetTokens = 1e4;
|
|
284
|
+
const useThinking = maxTokens > budgetTokens;
|
|
282
285
|
const response = await this.client.messages.create({
|
|
283
286
|
model: params.model,
|
|
284
|
-
max_tokens:
|
|
287
|
+
max_tokens: maxTokens,
|
|
285
288
|
temperature: 1,
|
|
286
289
|
system: params.systemPrompt,
|
|
287
290
|
messages: toAnthropicMessages(params.messages),
|
|
288
291
|
tools: params.tools ? toAnthropicTools(params.tools) : void 0,
|
|
289
|
-
thinking: { type: "enabled", budget_tokens:
|
|
292
|
+
...useThinking ? { thinking: { type: "enabled", budget_tokens: budgetTokens } } : {}
|
|
290
293
|
});
|
|
291
294
|
let content = "";
|
|
292
295
|
let thinking = "";
|
|
@@ -317,14 +320,17 @@ var AnthropicProvider = class {
|
|
|
317
320
|
};
|
|
318
321
|
}
|
|
319
322
|
async *generateStream(params) {
|
|
323
|
+
const maxTokens = params.maxTokens ?? 16e3;
|
|
324
|
+
const budgetTokens = 1e4;
|
|
325
|
+
const useThinking = maxTokens > budgetTokens;
|
|
320
326
|
const stream = this.client.messages.stream({
|
|
321
327
|
model: params.model,
|
|
322
|
-
max_tokens:
|
|
328
|
+
max_tokens: maxTokens,
|
|
323
329
|
temperature: 1,
|
|
324
330
|
system: params.systemPrompt,
|
|
325
331
|
messages: toAnthropicMessages(params.messages),
|
|
326
332
|
tools: params.tools ? toAnthropicTools(params.tools) : void 0,
|
|
327
|
-
thinking: { type: "enabled", budget_tokens:
|
|
333
|
+
...useThinking ? { thinking: { type: "enabled", budget_tokens: budgetTokens } } : {}
|
|
328
334
|
});
|
|
329
335
|
for await (const event of stream) {
|
|
330
336
|
if (event.type === "content_block_start") {
|