Repository navigation
Expand file tree
/
Copy pathcopilot-as-agent.js
More file actions
85 lines (80 loc) · 2.15 KB
/
Copy pathcopilot-as-agent.js
File metadata and controls
85 lines (80 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const Field = require("@saltcorn/data/models/field");
const Table = require("@saltcorn/data/models/table");
const Form = require("@saltcorn/data/models/form");
const View = require("@saltcorn/data/models/view");
const Trigger = require("@saltcorn/data/models/trigger");
const Plugin = require("@saltcorn/data/models/plugin");
const { findType } = require("@saltcorn/data/models/discovery");
const { save_menu_items } = require("@saltcorn/data/models/config");
const db = require("@saltcorn/data/db");
const WorkflowRun = require("@saltcorn/data/models/workflow_run");
const { localeDateTime } = require("@saltcorn/markup");
const {
div,
script,
domReady,
pre,
code,
input,
h4,
style,
h5,
button,
text_attr,
i,
p,
span,
small,
form,
textarea,
} = require("@saltcorn/markup/tags");
const { getState } = require("@saltcorn/data/db/state");
const { buildAgentRouteForwarders } = require("./agent-route-forwarding");
const get_state_fields = () => [];
const sys_prompt = ``;
const viewname = "Saltcorn Agent copilot";
const get_agent_view = () => {
const agent_action = new Trigger({
action: "Agent",
when_trigger: "Never",
configuration: {
viewname,
sys_prompt,
skills: [
{ skill_type: "Generate Page" },
{ skill_type: "Database design" },
{ skill_type: "Generate Workflow" },
{ skill_type: "Generate View" },
{ skill_type: "Registry editor" },
{ skill_type: "Javascript Action" },
{ skill_type: "Generate trigger" },
...(typeof Plugin.loadAndSaveNewPlugin === "function"
? [{ skill_type: "Install Plugin" }]
: []),
],
},
});
return new View({
viewtemplate: "Agent Chat",
name: viewname,
min_role: 1,
configuration: {
agent_action,
show_prev_runs: true,
viewname,
},
});
};
const run = async (table_id, viewname, cfg, state, reqres) => {
return await get_agent_view().run(state, reqres);
};
const routes = buildAgentRouteForwarders(get_agent_view);
module.exports = {
name: viewname,
display_state_form: false,
get_state_fields,
tableless: true,
singleton: true,
run,
routes,
};