@saltcorn/copilot 0.3.1 → 0.3.2
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/chat-copilot.js +18 -11
- package/common.js +0 -1
- package/package.json +3 -3
package/chat-copilot.js
CHANGED
|
@@ -33,6 +33,8 @@ const {
|
|
|
33
33
|
getPromptFromTemplate,
|
|
34
34
|
incompleteCfgMsg,
|
|
35
35
|
} = require("./common");
|
|
36
|
+
const MarkdownIt = require("markdown-it"),
|
|
37
|
+
md = new MarkdownIt();
|
|
36
38
|
|
|
37
39
|
const get_state_fields = () => [];
|
|
38
40
|
|
|
@@ -85,7 +87,9 @@ const run = async (table_id, viewname, cfg, state, { res, req }) => {
|
|
|
85
87
|
div(
|
|
86
88
|
{ class: "interaction-segment" },
|
|
87
89
|
span({ class: "badge bg-secondary" }, "Copilot"),
|
|
88
|
-
|
|
90
|
+
typeof interact.content === "string"
|
|
91
|
+
? md.render(interact.content)
|
|
92
|
+
: interact.content
|
|
89
93
|
)
|
|
90
94
|
);
|
|
91
95
|
break;
|
|
@@ -154,18 +158,19 @@ const run = async (table_id, viewname, cfg, state, { res, req }) => {
|
|
|
154
158
|
button(
|
|
155
159
|
{
|
|
156
160
|
type: "button",
|
|
157
|
-
class: "btn btn-secondary btn-sm",
|
|
161
|
+
class: "btn btn-secondary btn-sm py-0",
|
|
162
|
+
style: "font-size: 0.9em;height:1.5em",
|
|
158
163
|
onclick: "unset_state_field('run_id')",
|
|
159
164
|
title: "New session",
|
|
160
165
|
},
|
|
161
|
-
i({ class: "fas fa-redo" })
|
|
166
|
+
i({ class: "fas fa-redo fa-sm" })
|
|
162
167
|
)
|
|
163
168
|
),
|
|
164
169
|
prevRuns.map((run) =>
|
|
165
170
|
div(
|
|
166
171
|
{
|
|
167
172
|
onclick: `set_state_field('run_id',${run.id})`,
|
|
168
|
-
class: "prevcopilotrun",
|
|
173
|
+
class: "prevcopilotrun border p-2",
|
|
169
174
|
},
|
|
170
175
|
localeDateTime(run.started_at),
|
|
171
176
|
|
|
@@ -200,9 +205,8 @@ const run = async (table_id, viewname, cfg, state, { res, req }) => {
|
|
|
200
205
|
`div.interaction-segment:not(:first-child) {border-top: 1px solid #e7e7e7; }
|
|
201
206
|
div.interaction-segment {padding-top: 5px;padding-bottom: 5px;}
|
|
202
207
|
div.interaction-segment p {margin-bottom: 0px;}
|
|
203
|
-
div.interaction-segment div.card {margin-top: 0.5rem;}
|
|
204
|
-
div.prevcopilotrun {
|
|
205
|
-
div.prevcopilotrun:hover {cursor: pointer}
|
|
208
|
+
div.interaction-segment div.card {margin-top: 0.5rem;}
|
|
209
|
+
div.prevcopilotrun:hover {cursor: pointer; background-color: var(--tblr-secondary-bg-subtle, var(--bs-secondary-bg-subtle, gray));}
|
|
206
210
|
.copilot-entry .submit-button:hover { cursor: pointer}
|
|
207
211
|
|
|
208
212
|
.copilot-entry .submit-button {
|
|
@@ -238,7 +242,7 @@ const run = async (table_id, viewname, cfg, state, { res, req }) => {
|
|
|
238
242
|
function restore_old_button_elem(btn) {
|
|
239
243
|
const oldText = $(btn).data("old-text");
|
|
240
244
|
btn.html(oldText);
|
|
241
|
-
btn.css({ width: "" });
|
|
245
|
+
btn.css({ width: "" }).prop("disabled", false);
|
|
242
246
|
btn.removeData("old-text");
|
|
243
247
|
}
|
|
244
248
|
function processExecuteResponse(res) {
|
|
@@ -382,7 +386,10 @@ const interact = async (table_id, viewname, config, body, { req }) => {
|
|
|
382
386
|
actions.push(markup);
|
|
383
387
|
}
|
|
384
388
|
return { json: { success: "ok", actions, run_id: run.id } };
|
|
385
|
-
} else
|
|
389
|
+
} else
|
|
390
|
+
return {
|
|
391
|
+
json: { success: "ok", response: md.render(answer), run_id: run.id },
|
|
392
|
+
};
|
|
386
393
|
};
|
|
387
394
|
|
|
388
395
|
const renderToolcall = async (tool_call, viewname, implemented, run) => {
|
|
@@ -409,9 +416,9 @@ const wrapAction = (
|
|
|
409
416
|
implemented,
|
|
410
417
|
run
|
|
411
418
|
) =>
|
|
419
|
+
span({ class: "badge bg-info ms-1" }, actionClass.title) +
|
|
412
420
|
div(
|
|
413
|
-
{ class: "card mb-3" },
|
|
414
|
-
div({ class: "card-header" }, h5(actionClass.title)),
|
|
421
|
+
{ class: "card mb-3 bg-secondary-subtle" },
|
|
415
422
|
div(
|
|
416
423
|
{ class: "card-body" },
|
|
417
424
|
inner_markup,
|
package/common.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/copilot",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "AI assistant for building Saltcorn applications",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@saltcorn/data": "^0.9.0",
|
|
8
|
-
"axios": "0.16.2",
|
|
9
8
|
"underscore": "1.13.6",
|
|
10
|
-
"node-sql-parser": "4.15.0"
|
|
9
|
+
"node-sql-parser": "4.15.0",
|
|
10
|
+
"markdown-it": "14.1.0"
|
|
11
11
|
},
|
|
12
12
|
"author": "Tom Nielsen",
|
|
13
13
|
"license": "MIT",
|