@ax-llm/ax 11.0.58 → 11.0.59
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.cjs +34 -22
- package/index.cjs.map +1 -1
- package/index.d.cts +3 -2
- package/index.d.ts +3 -2
- package/index.js +34 -22
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1202,6 +1202,9 @@ var AxBaseAI = class {
|
|
|
1202
1202
|
`Model ${model} does not support thinkingTokenBudget.`
|
|
1203
1203
|
);
|
|
1204
1204
|
}
|
|
1205
|
+
if (options?.showThoughts && !this.getFeatures(model).hasShowThoughts) {
|
|
1206
|
+
throw new Error(`Model ${model} does not support showThoughts.`);
|
|
1207
|
+
}
|
|
1205
1208
|
modelConfig.stream = (options?.stream !== void 0 ? options.stream : modelConfig.stream) ?? true;
|
|
1206
1209
|
const canStream = this.getFeatures(model).streaming;
|
|
1207
1210
|
if (!canStream) {
|
|
@@ -1310,13 +1313,6 @@ var AxBaseAI = class {
|
|
|
1310
1313
|
const wrappedRespFn = (state) => (resp) => {
|
|
1311
1314
|
const res2 = respFn(resp, state);
|
|
1312
1315
|
res2.sessionId = options?.sessionId;
|
|
1313
|
-
if (options?.hideThought) {
|
|
1314
|
-
res2.results.forEach((result) => {
|
|
1315
|
-
if (result.thought) {
|
|
1316
|
-
result.thought = void 0;
|
|
1317
|
-
}
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
1316
|
if (!res2.modelUsage) {
|
|
1321
1317
|
res2.modelUsage = {
|
|
1322
1318
|
ai: this.name,
|
|
@@ -1355,13 +1351,6 @@ var AxBaseAI = class {
|
|
|
1355
1351
|
}
|
|
1356
1352
|
const res = this.aiImpl.createChatResp(rv);
|
|
1357
1353
|
res.sessionId = options?.sessionId;
|
|
1358
|
-
if (options?.hideThought) {
|
|
1359
|
-
res.results.forEach((result) => {
|
|
1360
|
-
if (result.thought) {
|
|
1361
|
-
result.thought = void 0;
|
|
1362
|
-
}
|
|
1363
|
-
});
|
|
1364
|
-
}
|
|
1365
1354
|
if (!res.modelUsage) {
|
|
1366
1355
|
const tokenUsage = this.aiImpl.getTokenUsage();
|
|
1367
1356
|
if (tokenUsage) {
|
|
@@ -1582,7 +1571,14 @@ function setChatResponseEvents(res, span, excludeContentFromTrace) {
|
|
|
1582
1571
|
if (!res.results) {
|
|
1583
1572
|
return;
|
|
1584
1573
|
}
|
|
1585
|
-
for (
|
|
1574
|
+
for (let index = 0; index < res.results.length; index++) {
|
|
1575
|
+
const result = res.results[index];
|
|
1576
|
+
if (!result) {
|
|
1577
|
+
continue;
|
|
1578
|
+
}
|
|
1579
|
+
if (!result.content && !result.thought && !result.functionCalls?.length && !result.finishReason) {
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1586
1582
|
const toolCalls = result.functionCalls?.map((call) => {
|
|
1587
1583
|
return {
|
|
1588
1584
|
id: call.id,
|
|
@@ -3497,6 +3493,9 @@ var AxAIGoogleGeminiImpl = class {
|
|
|
3497
3493
|
break;
|
|
3498
3494
|
}
|
|
3499
3495
|
}
|
|
3496
|
+
if (config.showThoughts !== void 0) {
|
|
3497
|
+
thinkingConfig.includeThoughts = config.showThoughts;
|
|
3498
|
+
}
|
|
3500
3499
|
const generationConfig = {
|
|
3501
3500
|
maxOutputTokens: req.modelConfig?.maxTokens ?? this.config.maxTokens,
|
|
3502
3501
|
temperature: req.modelConfig?.temperature ?? this.config.temperature,
|
|
@@ -4285,7 +4284,7 @@ var AxAIOpenAIResponsesImpl = class {
|
|
|
4285
4284
|
}
|
|
4286
4285
|
return items;
|
|
4287
4286
|
}
|
|
4288
|
-
createChatReq(req,
|
|
4287
|
+
createChatReq(req, config) {
|
|
4289
4288
|
const model = req.model;
|
|
4290
4289
|
const apiConfig = { name: "/responses" };
|
|
4291
4290
|
let instructionsFromPrompt = null;
|
|
@@ -4308,6 +4307,10 @@ var AxAIOpenAIResponsesImpl = class {
|
|
|
4308
4307
|
parameters: v.parameters ?? {}
|
|
4309
4308
|
})
|
|
4310
4309
|
);
|
|
4310
|
+
const includeFields = [];
|
|
4311
|
+
if (config.showThoughts) {
|
|
4312
|
+
includeFields.push("reasoning.encrypted_content");
|
|
4313
|
+
}
|
|
4311
4314
|
let mutableReq = {
|
|
4312
4315
|
model,
|
|
4313
4316
|
input: "",
|
|
@@ -4322,7 +4325,7 @@ var AxAIOpenAIResponsesImpl = class {
|
|
|
4322
4325
|
// Sourced from modelConfig or global config
|
|
4323
4326
|
// Optional fields from AxAIOpenAIResponsesRequest that need to be in Mutable for initialization
|
|
4324
4327
|
background: void 0,
|
|
4325
|
-
include: void 0,
|
|
4328
|
+
include: includeFields.length > 0 ? includeFields : void 0,
|
|
4326
4329
|
metadata: void 0,
|
|
4327
4330
|
parallel_tool_calls: this.config.parallelToolCalls,
|
|
4328
4331
|
previous_response_id: void 0,
|
|
@@ -4395,9 +4398,13 @@ var AxAIOpenAIResponsesImpl = class {
|
|
|
4395
4398
|
break;
|
|
4396
4399
|
case "reasoning":
|
|
4397
4400
|
currentResult.id = item.id;
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
+
if (item.encrypted_content) {
|
|
4402
|
+
currentResult.thought = item.encrypted_content;
|
|
4403
|
+
} else {
|
|
4404
|
+
currentResult.thought = item.summary.map(
|
|
4405
|
+
(s) => typeof s === "object" ? JSON.stringify(s) : s
|
|
4406
|
+
).join("\n");
|
|
4407
|
+
}
|
|
4401
4408
|
break;
|
|
4402
4409
|
case "file_search_call":
|
|
4403
4410
|
currentResult.id = item.id;
|
|
@@ -4715,7 +4722,9 @@ var AxAIOpenAIResponsesImpl = class {
|
|
|
4715
4722
|
{
|
|
4716
4723
|
const reasoningItem = event.item;
|
|
4717
4724
|
baseResult.id = event.item.id;
|
|
4718
|
-
if (reasoningItem.
|
|
4725
|
+
if (reasoningItem.encrypted_content) {
|
|
4726
|
+
baseResult.thought = reasoningItem.encrypted_content;
|
|
4727
|
+
} else if (reasoningItem.summary) {
|
|
4719
4728
|
baseResult.thought = reasoningItem.summary.map(
|
|
4720
4729
|
(s) => typeof s === "object" ? JSON.stringify(s) : s
|
|
4721
4730
|
).join("\n");
|
|
@@ -8162,7 +8171,8 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
8162
8171
|
stream,
|
|
8163
8172
|
functions: _functions,
|
|
8164
8173
|
functionCall: _functionCall,
|
|
8165
|
-
thinkingTokenBudget
|
|
8174
|
+
thinkingTokenBudget,
|
|
8175
|
+
showThoughts
|
|
8166
8176
|
} = options ?? {};
|
|
8167
8177
|
const chatPrompt = mem?.history(sessionId) ?? [];
|
|
8168
8178
|
if (chatPrompt.length === 0) {
|
|
@@ -8188,6 +8198,7 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
8188
8198
|
stream,
|
|
8189
8199
|
debug: false,
|
|
8190
8200
|
thinkingTokenBudget,
|
|
8201
|
+
showThoughts,
|
|
8191
8202
|
traceContext,
|
|
8192
8203
|
abortSignal: options?.abortSignal
|
|
8193
8204
|
}
|
|
@@ -8602,6 +8613,7 @@ Content: ${result.content}`
|
|
|
8602
8613
|
...funcNames ? { provided_functions: funcNames } : {},
|
|
8603
8614
|
...options?.model ? { model: options.model } : {},
|
|
8604
8615
|
...options?.thinkingTokenBudget ? { thinking_token_budget: options.thinkingTokenBudget } : {},
|
|
8616
|
+
...options?.showThoughts ? { show_thoughts: options.showThoughts } : {},
|
|
8605
8617
|
...options?.maxSteps ? { max_steps: options.maxSteps } : {},
|
|
8606
8618
|
...options?.maxRetries ? { max_retries: options.maxRetries } : {},
|
|
8607
8619
|
...options?.fastFail ? { fast_fail: options.fastFail } : {}
|