@saltcorn/agents 0.4.8 → 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.
- package/index.js +16 -12
- 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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
128
|
+
disable_markdown_render: opts?.disable_markdown_render,
|
|
125
129
|
},
|
|
126
130
|
null
|
|
127
131
|
);
|
|
128
|
-
return 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",
|