From fd21f1613316e17d8d321e09d6b81a5d6944a461 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Thu, 23 Nov 2023 20:16:22 +0800 Subject: [PATCH] feat: thinking in storage --- package-lock.json | 59 +++++++++++++++++++++++++++++ package.json | 1 + prompts/prebuild/menubar-prompts.ts | 10 +++++ prompts/prompts-manager.js | 8 ++++ types/custom-action.type.ts | 11 +++--- 5 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 prompts/prebuild/menubar-prompts.ts create mode 100644 prompts/prompts-manager.js diff --git a/package-lock.json b/package-lock.json index dc3ca1e..b2bf4b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,6 +59,7 @@ "@tiptap/react": "^2.1.12", "@tiptap/starter-kit": "^2.1.12", "@tiptap/suggestion": "^2.1.12", + "handlebars": "^4.7.8", "markdown-it": "^13.0.2", "next": "latest", "prosemirror-changeset": "^2.2.1", @@ -2370,6 +2371,26 @@ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, + "node_modules/handlebars": { + "version": "4.7.8", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", + "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", + "dependencies": { + "minimist": "^1.2.5", + "neo-async": "^2.6.2", + "source-map": "^0.6.1", + "wordwrap": "^1.0.0" + }, + "bin": { + "handlebars": "bin/handlebars" + }, + "engines": { + "node": ">=0.4.7" + }, + "optionalDependencies": { + "uglify-js": "^3.1.4" + } + }, "node_modules/hasown": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", @@ -2633,6 +2654,14 @@ "node": "*" } }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/mz": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", @@ -2660,6 +2689,11 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" + }, "node_modules/next": { "version": "14.0.3", "resolved": "https://registry.npmjs.org/next/-/next-14.0.3.tgz", @@ -3340,6 +3374,14 @@ "compute-scroll-into-view": "^3.0.2" } }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", @@ -3518,6 +3560,18 @@ "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==" }, + "node_modules/uglify-js": { + "version": "3.17.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", + "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", + "optional": true, + "bin": { + "uglifyjs": "bin/uglifyjs" + }, + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/update-browserslist-db": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz", @@ -3611,6 +3665,11 @@ "node": ">=10.13.0" } }, + "node_modules/wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==" + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 0dccdc0..66b87ad 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@tiptap/react": "^2.1.12", "@tiptap/starter-kit": "^2.1.12", "@tiptap/suggestion": "^2.1.12", + "handlebars": "^4.7.8", "markdown-it": "^13.0.2", "next": "latest", "prosemirror-changeset": "^2.2.1", diff --git a/prompts/prebuild/menubar-prompts.ts b/prompts/prebuild/menubar-prompts.ts new file mode 100644 index 0000000..a914751 --- /dev/null +++ b/prompts/prebuild/menubar-prompts.ts @@ -0,0 +1,10 @@ +import {FacetType, OutputForm, PromptAction} from "../../types/custom-action.type"; + +const MenubarPrompts: PromptAction[] = [ + { + name: 'File', + template: '', + facetType: FacetType.TOOLBAR_MENU, + outputForm: OutputForm.CHAT, + } +]; diff --git a/prompts/prompts-manager.js b/prompts/prompts-manager.js new file mode 100644 index 0000000..5e80d8a --- /dev/null +++ b/prompts/prompts-manager.js @@ -0,0 +1,8 @@ +import Handlebars from 'handlebars' + +class PromptsManager { + compile (string, data) { + const template = Handlebars.compile(string) + return template(data) + } +} \ No newline at end of file diff --git a/types/custom-action.type.ts b/types/custom-action.type.ts index e971741..df9c8e9 100644 --- a/types/custom-action.type.ts +++ b/types/custom-action.type.ts @@ -1,4 +1,4 @@ -enum FacetType { +export enum FacetType { TOOLBAR_MENU = 0, BUBBLE_MENU = 1, CONTEXT_MENU = 2, @@ -6,7 +6,7 @@ enum FacetType { QUICK_INSERT = 4, } -enum OutputForm { +export enum OutputForm { STREAMING = 0, NORMAL = 1, CHAT = 2, @@ -14,7 +14,7 @@ enum OutputForm { NOTIFICATION = 4, } -enum VariableType { +export enum VariableType { BEFORE_CURSOR, AFTER_CURSOR, SELECTION, @@ -23,9 +23,10 @@ enum VariableType { RELATED_CHUNKS, } -interface CustomAction { +export interface PromptAction { + name: string; + template: string; facetType: FacetType; outputForm: OutputForm; - content?: any; }