@saltcorn/agents 0.7.3 → 0.7.4

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/action.js CHANGED
@@ -89,6 +89,7 @@ module.exports = {
89
89
  trigger_id,
90
90
  run_id,
91
91
  req,
92
+ is_sub_agent,
92
93
  ...rest
93
94
  }) => {
94
95
  const userinput = interpolate(configuration.prompt, row, user);
@@ -114,6 +115,9 @@ module.exports = {
114
115
  undefined,
115
116
  [],
116
117
  row,
118
+ { stream: false },
119
+ false,
120
+ is_sub_agent
117
121
  );
118
122
  },
119
123
  };
package/common.js CHANGED
@@ -239,6 +239,7 @@ const process_interaction = async (
239
239
  triggering_row = {},
240
240
  agentsViewCfg = { stream: false },
241
241
  dyn_updates = false,
242
+ is_sub_agent = false,
242
243
  ) => {
243
244
  const { stream, viewname, layout } = agentsViewCfg;
244
245
  const sysState = getState();
@@ -290,6 +291,7 @@ const process_interaction = async (
290
291
  interactions: complArgs.chat,
291
292
  });
292
293
  const responses = [];
294
+ const raw_responses = [];
293
295
 
294
296
  const add_response = async (resp, not_final) => {
295
297
  if (dyn_updates)
@@ -457,7 +459,7 @@ const process_interaction = async (
457
459
  interactions: run.context.interactions,
458
460
  });
459
461
 
460
- if (myHasResult && !stop) hasResult = true;
462
+ if (myHasResult && !stop && !tool.tool.postProcess) hasResult = true;
461
463
  }
462
464
  }
463
465
 
@@ -520,10 +522,17 @@ const process_interaction = async (
520
522
  ],
521
523
  });
522
524
  if (postprocres.add_response) {
525
+ if (!postprocres.add_responses)
526
+ postprocres.add_responses = [postprocres.add_response];
527
+ else postprocres.add_responses.push(postprocres.add_response);
528
+ }
529
+
530
+ for (const add_resp of postprocres.add_responses || []) {
531
+ raw_responses.push(add_resp);
523
532
  const renderedAddResponse =
524
- typeof postprocres.add_response === "string"
525
- ? md.render(postprocres.add_response)
526
- : postprocres.add_response;
533
+ typeof add_resp === "string"
534
+ ? md.render(add_resp)
535
+ : add_resp;
527
536
  add_response(
528
537
  wrapSegment(
529
538
  wrapCard(
@@ -537,7 +546,7 @@ const process_interaction = async (
537
546
  );
538
547
  //replace tool response with this
539
548
  // run.context.interactions.forEach((ic) => {});
540
- const result = postprocres.add_response;
549
+ const result = add_resp;
541
550
  await sysState.functions.llm_add_message.run(
542
551
  "assistant",
543
552
  !result || typeof result === "string"
@@ -605,6 +614,7 @@ const process_interaction = async (
605
614
  triggering_row,
606
615
  agentsViewCfg,
607
616
  dyn_updates,
617
+ is_sub_agent,
608
618
  );
609
619
  } else if (typeof answer === "string")
610
620
  add_response(
@@ -625,6 +635,7 @@ const process_interaction = async (
625
635
  return {
626
636
  json: {
627
637
  success: "ok",
638
+ ...(is_sub_agent ? { raw_responses } : {}),
628
639
  response: [...prevResponses, ...responses].join(""),
629
640
  run_id: run?.id,
630
641
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/agents",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "AI agents for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {
@@ -66,13 +66,16 @@ class SubagentToSkill {
66
66
  return div({ class: "border border-primary p-2 m-2" }, phrase);
67
67
  },*/
68
68
  postProcess: async ({ tool_call, req, generate, emit_update, run }) => {
69
- await agent_action.run({
69
+ const subres = await agent_action.run({
70
70
  row: {},
71
71
  configuration: { ...trigger.configuration, prompt: "continue" },
72
72
  user: req.user,
73
73
  run_id: run.id,
74
+ is_sub_agent: true,
74
75
  req,
75
76
  });
77
+ if (subres.json.raw_responses)
78
+ return { add_responses: subres.json.raw_responses };
76
79
  return {
77
80
  //stop: true,
78
81
  //add_response: result,
@@ -128,7 +128,7 @@ for (const nameconfig of require("./configs")) {
128
128
  const result = await action.run({
129
129
  row: {
130
130
  theprompt:
131
- "What is the 16th Fibonacci number (when F1=1 and F2=1)? Consult both the math agent and the oracle and see if they agree",
131
+ "What is the 16th Fibonacci number (when F1=1 and F2=1)? Consult both the math agent and the oracle and see if they agree. You must call both the OracleAgent and the MathsAgent tools simultaneously",
132
132
  },
133
133
  configuration,
134
134
  user,