@stackfactor/agent-utils 1.0.14 → 1.0.15

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
@@ -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 Google providers.
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 | 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` |
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: `8192` for Claude, `200000` for other providers) |
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":";wBAmVQ,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"}
1
+ {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAsVQ,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"}
@@ -245,9 +245,12 @@ 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. Cap the default well
250
+ // below that threshold; callers can override via config.maxTokens.
248
251
  return new anthropic_1.ChatAnthropic({
249
252
  apiKey: config.anthropicAPIKey,
250
- maxTokens: config.maxTokens || 200000,
253
+ maxTokens: config.maxTokens || 16384,
251
254
  modelName: modelName,
252
255
  ...modelSettings,
253
256
  });
@@ -1 +1 @@
1
- {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAmVQ,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"}
1
+ {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":";wBAsVQ,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"}
@@ -240,9 +240,12 @@ 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. Cap the default well
245
+ // below that threshold; callers can override via config.maxTokens.
243
246
  return new ChatAnthropic({
244
247
  apiKey: config.anthropicAPIKey,
245
- maxTokens: config.maxTokens || 200000,
248
+ maxTokens: config.maxTokens || 16384,
246
249
  modelName: modelName,
247
250
  ...modelSettings,
248
251
  });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "restricted"
5
5
  },
6
- "version": "1.0.14",
6
+ "version": "1.0.15",
7
7
  "description": "",
8
8
  "main": "dist/cjs/index.js",
9
9
  "module": "dist/esm/index.js",