@stackfactor/agent-utils 1.0.14 → 1.0.16
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 +17 -9
- package/dist/cjs/langChain.d.ts.map +1 -1
- package/dist/cjs/langChain.js +8 -1
- package/dist/esm/langChain.d.ts.map +1 -1
- package/dist/esm/langChain.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
|
|
26
26
|
## `langChain`
|
|
27
27
|
|
|
28
|
-
Unified interface for running LLM prompts, managing LangChain agents, and generating images across OpenAI, Anthropic, and
|
|
28
|
+
Unified interface for running LLM prompts, managing LangChain agents, and generating images across OpenAI, Anthropic, Google, DeepSeek, Kimi (Moonshot), and GLM (Zhipu) providers.
|
|
29
29
|
|
|
30
30
|
### `langChain.runPromptWithModel(modelName, config, prompt, onProgressReport?, minPercent?, maxPercent?, expectsJsonResponse?, schema?, agentName?, tools?)`
|
|
31
31
|
|
|
@@ -39,8 +39,8 @@ When `expectsJsonResponse` is `true` (the default), JSON escape instructions are
|
|
|
39
39
|
|
|
40
40
|
| Parameter | Type | Default | Description |
|
|
41
41
|
| --------------------- | -------------------- | --------------- | -------------------------------------------------------------------------------------------------------- |
|
|
42
|
-
| `modelName` | `string` | — | Model identifier: `"gpt-4o"`, `"claude-3-5-sonnet"`, `"gemini-1.5-pro"`, etc.
|
|
43
|
-
| `config` | `object` | — | API keys (`openAIAPIKey`, `anthropicAPIKey`, `googleAPIKey`), `temperature`, `agentic`, `recursionLimit` |
|
|
42
|
+
| `modelName` | `string` | — | Model identifier: `"gpt-4o"`, `"claude-3-5-sonnet"`, `"gemini-1.5-pro"`, `"deepseek-chat"`, `"kimi-k2-0905-preview"`, `"glm-4.6"`, etc. |
|
|
43
|
+
| `config` | `object` | — | API keys (`openAIAPIKey`, `anthropicAPIKey`, `googleAPIKey`, `deepSeekAPIKey`, `kimiAPIKey`, `glmAPIKey`), `temperature`, `agentic`, `recursionLimit` |
|
|
44
44
|
| `prompt` | `string \| object[]` | — | Plain string or array of `{ role, content }` message objects |
|
|
45
45
|
| `onProgressReport` | `function \| null` | `null` | Async callback receiving `{ message, progress }` updates |
|
|
46
46
|
| `minPercent` | `number` | `0` | Lower bound for progress percentage |
|
|
@@ -266,11 +266,16 @@ Shared constants used across the package.
|
|
|
266
266
|
|
|
267
267
|
### Text / Chat
|
|
268
268
|
|
|
269
|
-
| Provider
|
|
270
|
-
|
|
|
271
|
-
| OpenAI
|
|
272
|
-
| Anthropic
|
|
273
|
-
| Google
|
|
269
|
+
| Provider | Model Prefix | Example |
|
|
270
|
+
| ----------------- | ---------------------- | ------------------------------------ |
|
|
271
|
+
| OpenAI | `gpt-` | `gpt-4o`, `gpt-4o-mini` |
|
|
272
|
+
| Anthropic | `claude-` | `claude-3-5-sonnet`, `claude-3-opus` |
|
|
273
|
+
| Google | `gemini-` | `gemini-1.5-pro`, `gemini-2.0-flash` |
|
|
274
|
+
| DeepSeek | `deepseek-` | `deepseek-chat`, `deepseek-reasoner` |
|
|
275
|
+
| Kimi (Moonshot) | `kimi-`, `moonshot-` | `kimi-k2-0905-preview`, `moonshot-v1-8k` |
|
|
276
|
+
| GLM (Zhipu) | `glm-` | `glm-4.6`, `glm-4.5` |
|
|
277
|
+
|
|
278
|
+
DeepSeek, Kimi, and GLM are routed through their OpenAI-compatible endpoints. Native structured output via `response_format` with JSON schema is only applied to `gpt-*` models; all other providers (including these three) use prompt-based JSON instructions.
|
|
274
279
|
|
|
275
280
|
### Image Generation
|
|
276
281
|
|
|
@@ -290,8 +295,11 @@ The `config` object accepted by LangChain methods supports the following keys:
|
|
|
290
295
|
| `openAIAPIKey` | `string` | OpenAI API key |
|
|
291
296
|
| `anthropicAPIKey` | `string` | Anthropic API key |
|
|
292
297
|
| `googleAPIKey` | `string` | Google AI API key |
|
|
298
|
+
| `deepSeekAPIKey` | `string` | DeepSeek API key |
|
|
299
|
+
| `kimiAPIKey` | `string` | Kimi (Moonshot) API key |
|
|
300
|
+
| `glmAPIKey` | `string` | GLM (Zhipu) API key |
|
|
293
301
|
| `temperature` | `number` | Sampling temperature |
|
|
294
|
-
| `maxTokens` | `number` | Maximum output tokens (default: `200000`)
|
|
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. |
|
|
295
303
|
| `agentic` | `boolean` | Enable agentic mode in `runPromptWithModel` |
|
|
296
304
|
| `recursionLimit` | `number` | Max agent steps (default: `25`) |
|
|
297
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":";wBA0VQ,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
|
@@ -245,10 +245,17 @@ const getLLMModel = (modelName, config, schema = null) => {
|
|
|
245
245
|
};
|
|
246
246
|
// Claude models (Anthropic)
|
|
247
247
|
if (modelName.startsWith("claude-")) {
|
|
248
|
+
// Anthropic's SDK rejects non-streamed requests when max_tokens is large
|
|
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;
|
|
248
254
|
return new anthropic_1.ChatAnthropic({
|
|
249
255
|
apiKey: config.anthropicAPIKey,
|
|
250
|
-
maxTokens
|
|
256
|
+
maxTokens,
|
|
251
257
|
modelName: modelName,
|
|
258
|
+
streaming: maxTokens > 16384,
|
|
252
259
|
...modelSettings,
|
|
253
260
|
});
|
|
254
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":";wBA0VQ,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
|
@@ -240,10 +240,17 @@ const getLLMModel = (modelName, config, schema = null) => {
|
|
|
240
240
|
};
|
|
241
241
|
// Claude models (Anthropic)
|
|
242
242
|
if (modelName.startsWith("claude-")) {
|
|
243
|
+
// Anthropic's SDK rejects non-streamed requests when max_tokens is large
|
|
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;
|
|
243
249
|
return new ChatAnthropic({
|
|
244
250
|
apiKey: config.anthropicAPIKey,
|
|
245
|
-
maxTokens
|
|
251
|
+
maxTokens,
|
|
246
252
|
modelName: modelName,
|
|
253
|
+
streaming: maxTokens > 16384,
|
|
247
254
|
...modelSettings,
|
|
248
255
|
});
|
|
249
256
|
}
|