@saltcorn/agents 0.6.10 → 0.6.12
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/common.js +28 -3
- package/package.json +1 -1
- package/skills/GenerateAndRunJsCode.js +7 -1
package/common.js
CHANGED
|
@@ -95,6 +95,24 @@ const get_initial_interactions = async (config, user, triggering_row) => {
|
|
|
95
95
|
return interacts;
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
const getSystemPrompt = async (config, user, triggering_row, formbody) => {
|
|
99
|
+
let sysPrompts = [
|
|
100
|
+
interpolate(config.sys_prompt, triggering_row || {}, user, "System prompt"),
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
const skills = get_skill_instances(config);
|
|
104
|
+
for (const skill of skills) {
|
|
105
|
+
const sysPr = await skill.systemPrompt?.({
|
|
106
|
+
...(formbody || {}),
|
|
107
|
+
user,
|
|
108
|
+
triggering_row,
|
|
109
|
+
});
|
|
110
|
+
if (sysPr) sysPrompts.push(sysPr);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return sysPrompts.join("\n\n");
|
|
114
|
+
};
|
|
115
|
+
|
|
98
116
|
const getCompletionArguments = async (
|
|
99
117
|
config,
|
|
100
118
|
user,
|
|
@@ -327,8 +345,8 @@ const process_interaction = async (
|
|
|
327
345
|
myHasResult = false;
|
|
328
346
|
if (stream && viewname) {
|
|
329
347
|
let content =
|
|
330
|
-
|
|
331
|
-
|
|
348
|
+
(tool.skill.skill_label || tool.skill.constructor.skill_name) +
|
|
349
|
+
" ";
|
|
332
350
|
const view = View.findOne({ name: viewname });
|
|
333
351
|
const pageLoadTag = req.body.page_load_tag;
|
|
334
352
|
view.emitRealTimeEvent(
|
|
@@ -405,6 +423,12 @@ const process_interaction = async (
|
|
|
405
423
|
if (tool.tool.postProcess && !stop) {
|
|
406
424
|
const chat = run.context.interactions;
|
|
407
425
|
let generateUsed = false;
|
|
426
|
+
const systemPrompt = await getSystemPrompt(
|
|
427
|
+
config,
|
|
428
|
+
req.user,
|
|
429
|
+
triggering_row,
|
|
430
|
+
req.body,
|
|
431
|
+
);
|
|
408
432
|
const postprocres = await tool.tool.postProcess({
|
|
409
433
|
tool_call,
|
|
410
434
|
result,
|
|
@@ -415,6 +439,7 @@ const process_interaction = async (
|
|
|
415
439
|
return await sysState.functions.llm_generate.run(prompt, {
|
|
416
440
|
chat,
|
|
417
441
|
appendToChat: true,
|
|
442
|
+
systemPrompt,
|
|
418
443
|
...opts,
|
|
419
444
|
});
|
|
420
445
|
},
|
|
@@ -425,7 +450,7 @@ const process_interaction = async (
|
|
|
425
450
|
view.emitRealTimeEvent(
|
|
426
451
|
`STREAM_CHUNK?page_load_tag=${pageLoadTag}`,
|
|
427
452
|
{
|
|
428
|
-
content: s,
|
|
453
|
+
content: s + " ",
|
|
429
454
|
},
|
|
430
455
|
);
|
|
431
456
|
},
|
package/package.json
CHANGED
|
@@ -47,6 +47,9 @@ class GenerateAndRunJsCodeSkill {
|
|
|
47
47
|
console,
|
|
48
48
|
sleep,
|
|
49
49
|
setTimeout,
|
|
50
|
+
URL,
|
|
51
|
+
Buffer,
|
|
52
|
+
console,
|
|
50
53
|
});
|
|
51
54
|
return await f();
|
|
52
55
|
}
|
|
@@ -143,7 +146,10 @@ The code you write can use await at the top level, and should return
|
|
|
143
146
|
|
|
144
147
|
Now generate the JavaScript code required by the user.`,
|
|
145
148
|
);
|
|
146
|
-
getState().log(
|
|
149
|
+
getState().log(
|
|
150
|
+
6,
|
|
151
|
+
"Generated code:\n--BEGIN CODE--\n" + str + "\n--END CODE--\n",
|
|
152
|
+
);
|
|
147
153
|
const js_code = str.includes("```javascript")
|
|
148
154
|
? str.split("```javascript")[1].split("```")[0]
|
|
149
155
|
: str;
|