@stackfactor/agent-utils 1.0.15 → 1.0.17
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/README.md
CHANGED
|
@@ -299,7 +299,7 @@ The `config` object accepted by LangChain methods supports the following keys:
|
|
|
299
299
|
| `kimiAPIKey` | `string` | Kimi (Moonshot) API key |
|
|
300
300
|
| `glmAPIKey` | `string` | GLM (Zhipu) API key |
|
|
301
301
|
| `temperature` | `number` | Sampling temperature |
|
|
302
|
-
| `maxTokens` | `number` | Maximum output tokens (default: `
|
|
302
|
+
| `maxTokens` | `number` | Maximum output tokens (default: `16384` for Claude, `200000` for other providers). For Claude, values above `21333` automatically enable LangChain streaming to bypass the Anthropic SDK's 10-minute non-streaming guard. |
|
|
303
303
|
| `agentic` | `boolean` | Enable agentic mode in `runPromptWithModel` |
|
|
304
304
|
| `recursionLimit` | `number` | Max agent steps (default: `25`) |
|
|
305
305
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBA2VQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,KACV,GAAG;sBAyBG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAmfF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCAxYO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDA6rBF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CA7vB8B,GAAG,KAAG,MAAM;;AAwzBzD,wBAOE"}
|
package/dist/cjs/langChain.js
CHANGED
|
@@ -31,7 +31,7 @@ Do NOT include raw newlines, tabs, or unescaped quotes inside JSON string values
|
|
|
31
31
|
* @returns A formatted string describing all validation failures
|
|
32
32
|
*/
|
|
33
33
|
const formatZodErrors = (zodError) => {
|
|
34
|
-
const errors = zodError.issues
|
|
34
|
+
const errors = zodError.issues && Array.isArray(zodError.issues)
|
|
35
35
|
? zodError.issues.map((err) => {
|
|
36
36
|
const path = err.path.length > 0 ? err.path.join(".") : "root";
|
|
37
37
|
// Provide more context based on error type
|
|
@@ -56,7 +56,7 @@ const formatZodErrors = (zodError) => {
|
|
|
56
56
|
return `Field "${path}": ${err.message}`;
|
|
57
57
|
}
|
|
58
58
|
})
|
|
59
|
-
: [];
|
|
59
|
+
: ["Schema validation error"];
|
|
60
60
|
return `Schema validation failed:\n - ${errors.join("\n - ")}`;
|
|
61
61
|
};
|
|
62
62
|
/**
|
|
@@ -246,12 +246,16 @@ const getLLMModel = (modelName, config, schema = null) => {
|
|
|
246
246
|
// Claude models (Anthropic)
|
|
247
247
|
if (modelName.startsWith("claude-")) {
|
|
248
248
|
// Anthropic's SDK rejects non-streamed requests when max_tokens is large
|
|
249
|
-
// enough that the operation could exceed 10 minutes
|
|
250
|
-
//
|
|
249
|
+
// enough that the operation could exceed 10 minutes (threshold: 21333).
|
|
250
|
+
// Auto-enable LangChain streaming above that cutoff so `.invoke()` routes
|
|
251
|
+
// through the streaming endpoint internally — callers see no interface
|
|
252
|
+
// change, but the guard is bypassed.
|
|
253
|
+
const maxTokens = config.maxTokens || 16384;
|
|
251
254
|
return new anthropic_1.ChatAnthropic({
|
|
252
255
|
apiKey: config.anthropicAPIKey,
|
|
253
|
-
maxTokens
|
|
256
|
+
maxTokens,
|
|
254
257
|
modelName: modelName,
|
|
258
|
+
streaming: maxTokens > 16384,
|
|
255
259
|
...modelSettings,
|
|
256
260
|
});
|
|
257
261
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBA2VQ,MAAM,aACD,MAAM,gBACH,MAAM,SACb,GAAG,EAAE,kBACI,GAAG,UACX,GAAG,KACV,GAAG;sBAyBG,GAAG,UACF,MAAM,UACN,GAAG,eACC,QAAQ,GAAG,IAAI,KAC1B,OAAO,CAAC,GAAG,CAAC;wCAmfF,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,KACpB,GAAG;oCAxYO,MAAM,UACT,GAAG,UACH,GAAG,oBACO,GAAG,eACT,MAAM,eACN,MAAM,wBACG,OAAO,WACpB,GAAG,cACA,MAAM,UACV,GAAG,EAAE,KACX,OAAO,CAAC,GAAG,CAAC;sDA6rBF,MAAM,UACT,GAAG,UACH,MAAM,YACL,GAAG,KACX,OAAO,CAAC,GAAG,CAAC;0CA7vB8B,GAAG,KAAG,MAAM;;AAwzBzD,wBAOE"}
|
package/dist/esm/langChain.js
CHANGED
|
@@ -26,7 +26,7 @@ Do NOT include raw newlines, tabs, or unescaped quotes inside JSON string values
|
|
|
26
26
|
* @returns A formatted string describing all validation failures
|
|
27
27
|
*/
|
|
28
28
|
const formatZodErrors = (zodError) => {
|
|
29
|
-
const errors = zodError.issues
|
|
29
|
+
const errors = zodError.issues && Array.isArray(zodError.issues)
|
|
30
30
|
? zodError.issues.map((err) => {
|
|
31
31
|
const path = err.path.length > 0 ? err.path.join(".") : "root";
|
|
32
32
|
// Provide more context based on error type
|
|
@@ -51,7 +51,7 @@ const formatZodErrors = (zodError) => {
|
|
|
51
51
|
return `Field "${path}": ${err.message}`;
|
|
52
52
|
}
|
|
53
53
|
})
|
|
54
|
-
: [];
|
|
54
|
+
: ["Schema validation error"];
|
|
55
55
|
return `Schema validation failed:\n - ${errors.join("\n - ")}`;
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
@@ -241,12 +241,16 @@ const getLLMModel = (modelName, config, schema = null) => {
|
|
|
241
241
|
// Claude models (Anthropic)
|
|
242
242
|
if (modelName.startsWith("claude-")) {
|
|
243
243
|
// Anthropic's SDK rejects non-streamed requests when max_tokens is large
|
|
244
|
-
// enough that the operation could exceed 10 minutes
|
|
245
|
-
//
|
|
244
|
+
// enough that the operation could exceed 10 minutes (threshold: 21333).
|
|
245
|
+
// Auto-enable LangChain streaming above that cutoff so `.invoke()` routes
|
|
246
|
+
// through the streaming endpoint internally — callers see no interface
|
|
247
|
+
// change, but the guard is bypassed.
|
|
248
|
+
const maxTokens = config.maxTokens || 16384;
|
|
246
249
|
return new ChatAnthropic({
|
|
247
250
|
apiKey: config.anthropicAPIKey,
|
|
248
|
-
maxTokens
|
|
251
|
+
maxTokens,
|
|
249
252
|
modelName: modelName,
|
|
253
|
+
streaming: maxTokens > 16384,
|
|
250
254
|
...modelSettings,
|
|
251
255
|
});
|
|
252
256
|
}
|