listpage-next-ai 0.0.259 → 0.0.261
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/dist/cjs/index.js +43 -8
- package/package.json +5 -9
package/dist/cjs/index.js
CHANGED
|
@@ -122,18 +122,18 @@ function createDatabaseTools(options) {
|
|
|
122
122
|
}),
|
|
123
123
|
onGenerateChart && (0, external_langchain_namespaceObject.tool)(async ({ sql, chartConfig, title })=>{
|
|
124
124
|
try {
|
|
125
|
-
|
|
125
|
+
await onGenerateChart({
|
|
126
126
|
sql,
|
|
127
127
|
title,
|
|
128
128
|
chartConfig
|
|
129
129
|
});
|
|
130
|
-
return
|
|
130
|
+
return `已生成图表`;
|
|
131
131
|
} catch (error) {
|
|
132
132
|
return `工具目前不可用:${error.message}`;
|
|
133
133
|
}
|
|
134
134
|
}, {
|
|
135
135
|
name: 'generate_chart',
|
|
136
|
-
description: '
|
|
136
|
+
description: '在需要可视化展示数据或者生成图表时调用该工具,用于生成图表,仅需调用前端自动展示,无需额外处理。',
|
|
137
137
|
schema: {
|
|
138
138
|
type: 'object',
|
|
139
139
|
properties: {
|
|
@@ -182,7 +182,7 @@ function createDatabaseTools(options) {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
})
|
|
185
|
-
];
|
|
185
|
+
].filter(Boolean);
|
|
186
186
|
}
|
|
187
187
|
function createKnowledgeTools(options) {
|
|
188
188
|
const { knowledges, onRetrieveFullDocs, onRetrieveFragments } = options;
|
|
@@ -256,7 +256,7 @@ const langgraph_namespaceObject = require("@langchain/langgraph");
|
|
|
256
256
|
const external_zod_namespaceObject = require("zod");
|
|
257
257
|
const messages_namespaceObject = require("@langchain/core/messages");
|
|
258
258
|
const maxIterationsMiddleware = ({ maxIterations })=>(0, external_langchain_namespaceObject.createMiddleware)({
|
|
259
|
-
name: '
|
|
259
|
+
name: 'maxIterations',
|
|
260
260
|
stateSchema: external_zod_namespaceObject.z.object({
|
|
261
261
|
iterations: external_zod_namespaceObject.z.number().default(0)
|
|
262
262
|
}),
|
|
@@ -316,6 +316,39 @@ function createPatchToolCallsMiddleware() {
|
|
|
316
316
|
}
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
|
+
const v3_namespaceObject = require("zod/v3");
|
|
320
|
+
require("@langchain/core/tools");
|
|
321
|
+
const TODO_LIST_MIDDLEWARE_SYSTEM_PROMPT = `## \`write_todos\`
|
|
322
|
+
|
|
323
|
+
You have access to the \`write_todos\` tool to help you manage and plan complex objectives.
|
|
324
|
+
Use this tool for complex objectives to ensure that you are tracking each necessary step and giving the user visibility into your progress.
|
|
325
|
+
This tool is very helpful for planning complex objectives, and for breaking down these larger complex objectives into smaller steps.
|
|
326
|
+
|
|
327
|
+
It is critical that you mark todos as completed as soon as you are done with a step. Do not batch up multiple steps before marking them as completed.
|
|
328
|
+
For simple objectives that only require a few steps, it is better to just complete the objective directly and NOT use this tool.
|
|
329
|
+
Writing todos takes time and tokens, use it when it is helpful for managing complex many-step problems! But not for simple few-step requests.
|
|
330
|
+
|
|
331
|
+
## Important To-Do List Usage Notes to Remember
|
|
332
|
+
- The \`write_todos\` tool should never be called multiple times in parallel.
|
|
333
|
+
- Don't be afraid to revise the To-Do list as you go. New information may reveal new tasks that need to be done, or old tasks that are irrelevant.
|
|
334
|
+
|
|
335
|
+
IMPORTANT: When you decide to use this tool, you MUST wrap your thought process (the explanation of why you are creating the list) in <think> tags.
|
|
336
|
+
For example:
|
|
337
|
+
<think>
|
|
338
|
+
I need to create a todo list to track...
|
|
339
|
+
</think>`;
|
|
340
|
+
const TodoStatus = v3_namespaceObject.z["enum"]([
|
|
341
|
+
'pending',
|
|
342
|
+
'in_progress',
|
|
343
|
+
'completed'
|
|
344
|
+
]).describe('Status of the todo');
|
|
345
|
+
const TodoSchema = v3_namespaceObject.z.object({
|
|
346
|
+
content: v3_namespaceObject.z.string().describe('Content of the todo item'),
|
|
347
|
+
status: TodoStatus
|
|
348
|
+
});
|
|
349
|
+
v3_namespaceObject.z.object({
|
|
350
|
+
todos: v3_namespaceObject.z.array(TodoSchema).default([])
|
|
351
|
+
});
|
|
319
352
|
const jieba_namespaceObject = require("@node-rs/jieba");
|
|
320
353
|
const dict_namespaceObject = require("@node-rs/jieba/dict");
|
|
321
354
|
class BM25 {
|
|
@@ -403,7 +436,7 @@ function createWordTools(options) {
|
|
|
403
436
|
];
|
|
404
437
|
}
|
|
405
438
|
function createReactAgent(options) {
|
|
406
|
-
const { name, model, system_prompt, tools, middleware, features, databaseOptions, knowledgeOptions, wordOptions, inject_current_time, max_iterations = 0 } = options;
|
|
439
|
+
const { name, model, system_prompt, tools = [], middleware = [], features, databaseOptions, knowledgeOptions, wordOptions, inject_current_time, max_iterations = 0 } = options;
|
|
407
440
|
const agent = (0, external_langchain_namespaceObject.createAgent)({
|
|
408
441
|
name,
|
|
409
442
|
model,
|
|
@@ -413,13 +446,15 @@ function createReactAgent(options) {
|
|
|
413
446
|
...features.knowledge ? createKnowledgeTools(knowledgeOptions) : [],
|
|
414
447
|
...features.word ? createWordTools(wordOptions) : [],
|
|
415
448
|
...tools
|
|
416
|
-
],
|
|
449
|
+
].filter(Boolean),
|
|
417
450
|
middleware: [
|
|
418
451
|
inject_current_time && currentTimeMiddleware(),
|
|
419
452
|
max_iterations > 0 && maxIterationsMiddleware({
|
|
420
453
|
maxIterations: max_iterations
|
|
421
454
|
}),
|
|
422
|
-
(0, external_langchain_namespaceObject.todoListMiddleware)(
|
|
455
|
+
(0, external_langchain_namespaceObject.todoListMiddleware)({
|
|
456
|
+
systemPrompt: TODO_LIST_MIDDLEWARE_SYSTEM_PROMPT
|
|
457
|
+
}),
|
|
423
458
|
(0, external_langchain_namespaceObject.summarizationMiddleware)({
|
|
424
459
|
model: model,
|
|
425
460
|
trigger: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "listpage-next-ai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.261",
|
|
4
4
|
"description": "A React component library for creating filter forms with Ant Design",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -37,15 +37,11 @@
|
|
|
37
37
|
"typescript": "^5.9.2"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@langchain/
|
|
41
|
-
"@langchain/
|
|
42
|
-
"@langchain/
|
|
43
|
-
"
|
|
44
|
-
"@langchain/openai": "~1.1.1",
|
|
45
|
-
"@langchain/tavily": "~1.0.1",
|
|
46
|
-
"deepagents": "~1.3.1",
|
|
40
|
+
"@langchain/core": "1.1.5",
|
|
41
|
+
"@langchain/langgraph": "1.0.0",
|
|
42
|
+
"@langchain/openai": "1.1.1",
|
|
43
|
+
"langchain": "1.2.0",
|
|
47
44
|
"fast-glob": "^3.3.3",
|
|
48
|
-
"langchain": "^1.2.0",
|
|
49
45
|
"lodash": "~4.17.21",
|
|
50
46
|
"rxjs": "~7.8.2",
|
|
51
47
|
"uuid": "9.0.1",
|