From 518502835c7b14fd0cdb4082bb88e07e08e163da Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Sat, 2 Dec 2023 22:38:29 +0800 Subject: [PATCH] refactor: rename for function names --- .../action/{AiActionHandler.ts => AiActionExecutor.ts} | 7 ++++--- .../editor/action/{ActionExecutor.ts => PromptCompiler.ts} | 2 +- .../src/components/editor/action/custom-editor-commands.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) rename editor/src/components/editor/action/{AiActionHandler.ts => AiActionExecutor.ts} (94%) rename editor/src/components/editor/action/{ActionExecutor.ts => PromptCompiler.ts} (98%) diff --git a/editor/src/components/editor/action/AiActionHandler.ts b/editor/src/components/editor/action/AiActionExecutor.ts similarity index 94% rename from editor/src/components/editor/action/AiActionHandler.ts rename to editor/src/components/editor/action/AiActionExecutor.ts index 7edd484..138b122 100644 --- a/editor/src/components/editor/action/AiActionHandler.ts +++ b/editor/src/components/editor/action/AiActionExecutor.ts @@ -1,11 +1,11 @@ import { Editor } from "@tiptap/core"; import { ChangeForm, OutputForm, PromptAction } from "@/components/editor/defs/custom-action.type"; -import { ActionExecutor, actionPosition } from "@/components/editor/action/ActionExecutor"; +import { PromptCompiler, actionPosition } from "@/components/editor/action/PromptCompiler"; // @ts-ignore import { MarkdownParser } from "node_modules/tiptap-markdown/src/parse/MarkdownParser"; -export class AiActionHandler { +export class AiActionExecutor { private readonly editor: Editor; constructor(editor: Editor) { @@ -93,7 +93,8 @@ export class AiActionHandler { } public async execute(action: PromptAction) { - const actionExecutor = new ActionExecutor(action, this.editor); + // builtinFunction + const actionExecutor = new PromptCompiler(action, this.editor); actionExecutor.compile(); let prompt = action.compiledTemplate; diff --git a/editor/src/components/editor/action/ActionExecutor.ts b/editor/src/components/editor/action/PromptCompiler.ts similarity index 98% rename from editor/src/components/editor/action/ActionExecutor.ts rename to editor/src/components/editor/action/PromptCompiler.ts index 856482f..cab64d8 100644 --- a/editor/src/components/editor/action/ActionExecutor.ts +++ b/editor/src/components/editor/action/PromptCompiler.ts @@ -3,7 +3,7 @@ import { Editor, Range } from "@tiptap/core"; import { Selection } from "prosemirror-state"; import { PromptsManager } from "@/components/editor/prompts/prompts-manager"; -export class ActionExecutor { +export class PromptCompiler { private action: PromptAction; private editor: Editor; diff --git a/editor/src/components/editor/action/custom-editor-commands.ts b/editor/src/components/editor/action/custom-editor-commands.ts index 1fc810f..2aaf0a4 100644 --- a/editor/src/components/editor/action/custom-editor-commands.ts +++ b/editor/src/components/editor/action/custom-editor-commands.ts @@ -4,7 +4,7 @@ import { Transaction } from "prosemirror-state"; import { DefinedVariable, FacetType, OutputForm, PromptAction, } from "@/components/editor/defs/custom-action.type"; import { PromptsManager } from "@/components/editor/prompts/prompts-manager"; import { ARTICLE_TYPE_OPTIONS, TypeOptions } from "@/components/editor/defs/type-options.type"; -import { AiActionHandler } from "@/components/editor/action/AiActionHandler"; +import { AiActionExecutor } from "@/components/editor/action/AiActionExecutor"; declare module "@tiptap/core" { interface Commands { @@ -55,7 +55,7 @@ export const CustomEditorCommands = Extension.create({ callLlm: (action: PromptAction) => async ({ tr, commands, editor }: { tr: Transaction; commands: Commands, editor: Editor }) => { - let actionHandler = new AiActionHandler(editor); + let actionHandler = new AiActionExecutor(editor); return await actionHandler.execute(action) }, getAiActions: