@ax-llm/ax 12.0.24 → 12.0.25
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 +94 -44
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js +94 -44
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -919,64 +919,42 @@ var axCreateDefaultLogger = (output = defaultOutput) => {
|
|
|
919
919
|
return (message, options) => {
|
|
920
920
|
const tags = options?.tags ?? [];
|
|
921
921
|
let formattedMessage = message;
|
|
922
|
-
|
|
923
|
-
|
|
922
|
+
let colorFunction = (text) => text;
|
|
923
|
+
if (tags.includes("warning") || tags.includes("discovery")) {
|
|
924
|
+
colorFunction = (text) => colorLog.yellow(text);
|
|
925
|
+
} else if (tags.includes("error")) {
|
|
926
|
+
colorFunction = (text) => colorLog.red(text);
|
|
924
927
|
} else if (tags.includes("success") || tags.includes("responseContent")) {
|
|
925
|
-
|
|
926
|
-
} else if (tags.includes("functionName")) {
|
|
927
|
-
if (tags.includes("firstFunction")) {
|
|
928
|
-
formattedMessage = `
|
|
929
|
-
${colorLog.whiteBright(formattedMessage)}`;
|
|
930
|
-
} else {
|
|
931
|
-
formattedMessage = `${colorLog.whiteBright(formattedMessage)}`;
|
|
932
|
-
}
|
|
928
|
+
colorFunction = (text) => colorLog.greenBright(text);
|
|
933
929
|
} else if (tags.includes("systemContent") || tags.includes("assistantContent")) {
|
|
934
|
-
|
|
935
|
-
} else if (tags.includes("
|
|
936
|
-
|
|
930
|
+
colorFunction = (text) => colorLog.blueBright(text);
|
|
931
|
+
} else if (tags.includes("functionName")) {
|
|
932
|
+
colorFunction = (text) => colorLog.whiteBright(text);
|
|
937
933
|
} else if (tags.includes("functionArg")) {
|
|
938
|
-
|
|
934
|
+
colorFunction = (text) => colorLog.blueBright(text);
|
|
935
|
+
} else if (tags.includes("functionResult")) {
|
|
936
|
+
colorFunction = (text) => colorLog.yellow(text);
|
|
939
937
|
}
|
|
940
|
-
if (tags.includes("responseStart") || tags.includes("systemStart") || tags.includes("userStart")) {
|
|
938
|
+
if (tags.includes("responseStart") || tags.includes("systemStart") || tags.includes("userStart") || tags.includes("assistantStart") || tags.includes("error") || tags.includes("functionName") || tags.includes("functionArg")) {
|
|
941
939
|
formattedMessage = `
|
|
942
940
|
${formattedMessage}`;
|
|
943
|
-
}
|
|
941
|
+
}
|
|
942
|
+
if (tags.includes("responseEnd") || tags.includes("systemEnd") || tags.includes("userEnd") || tags.includes("assistantStart") || tags.includes("error") || tags.includes("functionEnd")) {
|
|
944
943
|
formattedMessage = `${formattedMessage}
|
|
945
|
-
`;
|
|
946
|
-
} else if (tags.includes("assistantStart")) {
|
|
947
|
-
formattedMessage = `
|
|
948
|
-
${formattedMessage}
|
|
949
|
-
`;
|
|
950
|
-
} else if (tags.includes("error")) {
|
|
951
|
-
formattedMessage = `
|
|
952
|
-
${formattedMessage}
|
|
953
|
-
`;
|
|
954
|
-
} else if (tags.includes("functionEnd")) {
|
|
955
|
-
formattedMessage = `
|
|
956
944
|
`;
|
|
957
945
|
}
|
|
958
|
-
output(formattedMessage);
|
|
946
|
+
output(colorFunction(formattedMessage));
|
|
959
947
|
};
|
|
960
948
|
};
|
|
961
949
|
var axCreateDefaultTextLogger = (output = defaultOutput) => {
|
|
962
950
|
return (message, options) => {
|
|
963
951
|
const tags = options?.tags ?? [];
|
|
964
952
|
let formattedMessage = message;
|
|
965
|
-
if (tags.includes("responseStart") || tags.includes("systemStart") || tags.includes("userStart")) {
|
|
953
|
+
if (tags.includes("responseStart") || tags.includes("systemStart") || tags.includes("userStart") || tags.includes("assistantStart") || tags.includes("error") || tags.includes("functionName") || tags.includes("functionArg")) {
|
|
966
954
|
formattedMessage = `
|
|
967
955
|
${formattedMessage}`;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
`;
|
|
971
|
-
} else if (tags.includes("assistantStart")) {
|
|
972
|
-
formattedMessage = `
|
|
973
|
-
${formattedMessage}
|
|
974
|
-
`;
|
|
975
|
-
} else if (tags.includes("error")) {
|
|
976
|
-
formattedMessage = `
|
|
977
|
-
${formattedMessage}
|
|
978
|
-
`;
|
|
979
|
-
} else if (tags.includes("functionEnd")) {
|
|
956
|
+
}
|
|
957
|
+
if (tags.includes("responseEnd") || tags.includes("systemEnd") || tags.includes("userEnd") || tags.includes("assistantStart") || tags.includes("error") || tags.includes("functionEnd")) {
|
|
980
958
|
formattedMessage = `${formattedMessage}
|
|
981
959
|
`;
|
|
982
960
|
}
|
|
@@ -1187,9 +1165,14 @@ var logResponseResult = (r, logger = defaultLogger) => {
|
|
|
1187
1165
|
if (r.content) {
|
|
1188
1166
|
logger(r.content, { tags: ["responseContent"] });
|
|
1189
1167
|
}
|
|
1168
|
+
const loggedFunctionCalls = /* @__PURE__ */ new Set();
|
|
1190
1169
|
if (r.functionCalls && r.functionCalls.length > 0) {
|
|
1191
1170
|
for (const [i, f2] of r.functionCalls.entries()) {
|
|
1192
|
-
if (f2.
|
|
1171
|
+
if (f2.id) {
|
|
1172
|
+
if (loggedFunctionCalls.has(f2.id)) {
|
|
1173
|
+
continue;
|
|
1174
|
+
}
|
|
1175
|
+
loggedFunctionCalls.add(f2.id);
|
|
1193
1176
|
const tags = ["functionName"];
|
|
1194
1177
|
if (i === 0) {
|
|
1195
1178
|
tags.push("firstFunction");
|
|
@@ -1197,7 +1180,7 @@ var logResponseResult = (r, logger = defaultLogger) => {
|
|
|
1197
1180
|
if (r.functionCalls.length > 1) {
|
|
1198
1181
|
tags.push("multipleFunctions");
|
|
1199
1182
|
}
|
|
1200
|
-
logger(`[${i + 1}] ${f2.function.name}`, { tags });
|
|
1183
|
+
logger(`[${i + 1}] ${f2.function.name}[${f2.id}]`, { tags });
|
|
1201
1184
|
}
|
|
1202
1185
|
if (f2.function.params) {
|
|
1203
1186
|
const params = typeof f2.function.params === "string" ? f2.function.params : JSON.stringify(f2.function.params, null, 2);
|
|
@@ -1216,7 +1199,20 @@ var logResponse = (resp, logger = defaultLogger) => {
|
|
|
1216
1199
|
}
|
|
1217
1200
|
};
|
|
1218
1201
|
var logResponseDelta = (delta, logger = defaultLogger) => {
|
|
1219
|
-
logger(delta, { tags: ["responseContent"] });
|
|
1202
|
+
logger(delta, { tags: ["responseContent", "responseDelta"] });
|
|
1203
|
+
};
|
|
1204
|
+
var logFunctionResults = (results, logger = defaultLogger) => {
|
|
1205
|
+
for (const result of results) {
|
|
1206
|
+
logger(`Function Result [${result.functionId}]:`, {
|
|
1207
|
+
tags: ["functionName"]
|
|
1208
|
+
});
|
|
1209
|
+
if (result.isError) {
|
|
1210
|
+
logger(result.result, { tags: ["functionResult", "error"] });
|
|
1211
|
+
} else {
|
|
1212
|
+
logger(result.result, { tags: ["functionResult"] });
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
logger("", { tags: ["functionEnd"] });
|
|
1220
1216
|
};
|
|
1221
1217
|
|
|
1222
1218
|
// ai/metrics.ts
|
|
@@ -4907,6 +4903,54 @@ var AxAIGoogleGeminiImpl = class {
|
|
|
4907
4903
|
void 0
|
|
4908
4904
|
// requestId not available
|
|
4909
4905
|
);
|
|
4906
|
+
case "UNEXPECTED_TOOL_CALL":
|
|
4907
|
+
throw new AxAIRefusalError(
|
|
4908
|
+
"Unexpected tool call",
|
|
4909
|
+
void 0,
|
|
4910
|
+
// model not available in candidate
|
|
4911
|
+
void 0
|
|
4912
|
+
// requestId not available
|
|
4913
|
+
);
|
|
4914
|
+
case "FINISH_REASON_UNSPECIFIED":
|
|
4915
|
+
throw new AxAIRefusalError(
|
|
4916
|
+
"Finish reason unspecified",
|
|
4917
|
+
void 0,
|
|
4918
|
+
// model not available in candidate
|
|
4919
|
+
void 0
|
|
4920
|
+
// requestId not available
|
|
4921
|
+
);
|
|
4922
|
+
case "BLOCKLIST":
|
|
4923
|
+
throw new AxAIRefusalError(
|
|
4924
|
+
"Content was blocked due to blocklist",
|
|
4925
|
+
void 0,
|
|
4926
|
+
// model not available in candidate
|
|
4927
|
+
void 0
|
|
4928
|
+
// requestId not available
|
|
4929
|
+
);
|
|
4930
|
+
case "PROHIBITED_CONTENT":
|
|
4931
|
+
throw new AxAIRefusalError(
|
|
4932
|
+
"Content was blocked due to prohibited content",
|
|
4933
|
+
void 0,
|
|
4934
|
+
// model not available in candidate
|
|
4935
|
+
void 0
|
|
4936
|
+
// requestId not available
|
|
4937
|
+
);
|
|
4938
|
+
case "SPII":
|
|
4939
|
+
throw new AxAIRefusalError(
|
|
4940
|
+
"Content was blocked due to SPII",
|
|
4941
|
+
void 0,
|
|
4942
|
+
// model not available in candidate
|
|
4943
|
+
void 0
|
|
4944
|
+
// requestId not available
|
|
4945
|
+
);
|
|
4946
|
+
case "OTHER":
|
|
4947
|
+
throw new AxAIRefusalError(
|
|
4948
|
+
"Other finish reason",
|
|
4949
|
+
void 0,
|
|
4950
|
+
// model not available in candidate
|
|
4951
|
+
void 0
|
|
4952
|
+
// requestId not available
|
|
4953
|
+
);
|
|
4910
4954
|
}
|
|
4911
4955
|
if (!candidate.content || !candidate.content.parts) {
|
|
4912
4956
|
return result;
|
|
@@ -7270,6 +7314,9 @@ var MemoryImpl = class {
|
|
|
7270
7314
|
} else {
|
|
7271
7315
|
this.data.push({ role: "function", chat });
|
|
7272
7316
|
}
|
|
7317
|
+
if (this.options?.debug) {
|
|
7318
|
+
debugFunctionResults(results);
|
|
7319
|
+
}
|
|
7273
7320
|
}
|
|
7274
7321
|
addResponse(results) {
|
|
7275
7322
|
const chat = results.map(({ index, ...value }) => ({
|
|
@@ -7458,6 +7505,9 @@ function debugResponse(value) {
|
|
|
7458
7505
|
function debugResponseDelta(delta) {
|
|
7459
7506
|
logResponseDelta(delta);
|
|
7460
7507
|
}
|
|
7508
|
+
function debugFunctionResults(results) {
|
|
7509
|
+
logFunctionResults(results);
|
|
7510
|
+
}
|
|
7461
7511
|
|
|
7462
7512
|
// dsp/asserts.ts
|
|
7463
7513
|
var AxAssertionError = class extends Error {
|