feat: pictures for the assistant - the models make and edit them by themselves through the Vertex API (a new picture, or the user's attached photo, or the last picture made), with an API key in Настройки and a switch for the prompt improver; folded descriptions of pictures and searches; the name of an attached file opens or saves it; a deleted chat is wiped from the database files, attachments included
This commit is contained in:
1 parent
c72fcfebf3
commit
dd1244a169
13 files changed
+925
-20
No files matched your search
@@ -46,12 +46,25 @@
|
||||
|
||||
// parseActions finds what an assistant's answer asks the panel to do:
|
||||
// closed ``` blocks headed run [machine], read|ls [machine:]path or
|
||||
// write [machine:]path (its body the file's text).
|
||||
// write [machine:]path (its body the file's text); search, fetch, and image
|
||||
// (a picture to make or - with edit - to change; the first line may give
|
||||
// its ratio, quality and the photo's file name).
|
||||
function parseActions(text) {
|
||||
const out = [], re = /```(run|read|ls|write|search|fetch)([^\n]*)\n([\s\S]*?)```/g;
|
||||
const out = [], re = /```(run|read|ls|write|search|fetch|image)([^\n]*)\n([\s\S]*?)```/g;
|
||||
for (let m; (m = re.exec(text));) {
|
||||
const kind = m[1], head = m[2].trim(), body = m[3].replace(/\n$/, '');
|
||||
if (kind === 'run') { out.push({kind, machine: head, path: '', body}); continue; }
|
||||
if (kind === 'image') {
|
||||
// ```image [edit] [1:1|16:9|…|auto] [fast|artist|0.2plus] [noenhance] [file name]
|
||||
let rest = head, edit = false, enhance = true, ratio = '', model = '', file = '', t;
|
||||
if ((t = /^edit(?=\s|$)\s*/.exec(rest))) { edit = true; rest = rest.slice(t[0].length); }
|
||||
rest = rest.replace(/(?:^|\s)(\d+:\d+|auto)(?=\s|$)/, (_, v) => { ratio = v; return ' '; })
|
||||
.replace(/(?:^|\s)(fast|artist|0\.2plus)(?=\s|$)/, (_, v) => { model = v; return ' '; })
|
||||
.replace(/(?:^|\s)(noenhance|enhance)(?=\s|$)/, (_, v) => { enhance = v === 'enhance'; return ' '; });
|
||||
file = rest.trim();
|
||||
out.push({kind, machine: '', path: '', body, edit, enhance, ratio, model, file});
|
||||
continue;
|
||||
}
|
||||
if (kind === 'search' || kind === 'fetch') { out.push({kind, machine: '', path: '', body: (head + '\n' + body).trim()}); continue; }
|
||||
const c = head.indexOf(':');
|
||||
const machine = c > 0 && !head.startsWith('/') ? head.slice(0, c) : '';
|
||||
|
||||
Reference in new issue
Block a user