@saltcorn/agents 0.4.9 → 0.4.10

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.
Files changed (2) hide show
  1. package/index.js +16 -12
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -105,27 +105,31 @@ module.exports = {
105
105
  agent_generate: {
106
106
  run: async (agent_name, prompt, opts = {}) => {
107
107
  const action = await Trigger.findOne({ name: agent_name });
108
- const run = await WorkflowRun.create({
109
- status: "Running",
110
- started_by: opts.user?.id,
111
- trigger_id: action.id,
112
- context: {
113
- implemented_fcall_ids: [],
114
- interactions: [{ role: "user", content: prompt }],
115
- funcalls: {},
116
- },
117
- });
108
+ let run;
109
+
110
+ if (opts.run_id) run = await WorkflowRun.findOne({ id: +opts.run_id });
111
+ else
112
+ run = await WorkflowRun.create({
113
+ status: "Running",
114
+ started_by: opts.user?.id,
115
+ trigger_id: action.id,
116
+ context: {
117
+ implemented_fcall_ids: [],
118
+ interactions: [{ role: "user", content: prompt }],
119
+ funcalls: {},
120
+ },
121
+ });
118
122
  const result = await process_interaction(
119
123
  run,
120
124
  action.configuration,
121
125
  {
122
126
  user: opts?.user,
123
127
  body: {},
124
- disable_markdown: opts?.disable_markdown_render,
128
+ disable_markdown_render: opts?.disable_markdown_render,
125
129
  },
126
130
  null
127
131
  );
128
- return { text: result.json.response };
132
+ return { text: result.json.response, run_id: run.id };
129
133
  },
130
134
  isAsync: true,
131
135
  description: "Run an agent on a prompt",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/agents",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "AI agents for Saltcorn",
5
5
  "main": "index.js",
6
6
  "dependencies": {