From ca65fd777f5ccb91db57a8a90607ad9921cc73c9 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 8 Mar 2023 22:46:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:art:=20=E5=8A=A0=E5=85=A5=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E5=86=85=E5=AE=B9=E5=9D=97=E7=9A=84=E4=BA=BA=E5=B7=A5?= =?UTF-8?q?=E6=99=BA=E8=83=BD=E8=BE=85=E5=8A=A9=E6=94=AF=E6=8C=81=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7566?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/ai/actions.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/ai/actions.ts b/app/src/ai/actions.ts index 85b7c6a26..d4e278111 100644 --- a/app/src/ai/actions.ts +++ b/app/src/ai/actions.ts @@ -28,7 +28,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { submenu: [{ label: window.siyuan.languages.aiTranslate_zh_CN, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [zh_CN]"}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -36,7 +36,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiTranslate_ja_JP, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [ja_JP]"}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -44,7 +44,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiTranslate_ko_KR, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [ko_KR]"}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -52,7 +52,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiTranslate_en_US, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [en_US]"}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -60,7 +60,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiTranslate_es_ES, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [es_ES]"}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -68,7 +68,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiTranslate_fr_FR, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [fr_FR]"}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -76,7 +76,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiTranslate_de_DE, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [de_DE]"}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -99,6 +99,14 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }); } }, { + label: window.siyuan.languages.aiFixGrammarSpell, + click() { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Identify the language used in the following text and mark it as {x}, correct the grammar and spelling errors, return the result in language {x}"}, (response) => { + focusByRange(protyle.toolbar.range); + insertHTML(response.data, protyle, true); + }); + } + },{ label: window.siyuan.languages.aiCustomAction, click() { const dialog = new Dialog({ From 1cc65f5f2acc1ea79e6eebbff89b206e061d8c56 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 8 Mar 2023 22:50:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:art:=20=E5=8A=A0=E5=85=A5=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E5=86=85=E5=AE=B9=E5=9D=97=E7=9A=84=E4=BA=BA=E5=B7=A5?= =?UTF-8?q?=E6=99=BA=E8=83=BD=E8=BE=85=E5=8A=A9=E6=94=AF=E6=8C=81=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7566?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/ai/actions.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/ai/actions.ts b/app/src/ai/actions.ts index d4e278111..8d2ced11d 100644 --- a/app/src/ai/actions.ts +++ b/app/src/ai/actions.ts @@ -85,7 +85,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiExtractSummary, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Summarize"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: window.siyuan.languages.aiExtractSummary}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -93,7 +93,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiBrainStorm, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Brainstorm"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: window.siyuan.languages.aiBrainStorm}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); }); @@ -101,7 +101,7 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => { }, { label: window.siyuan.languages.aiFixGrammarSpell, click() { - fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Identify the language used in the following text and mark it as {x}, correct the grammar and spelling errors, return the result in language {x}"}, (response) => { + fetchPost("/api/ai/chatGPTWithAction", {ids, action: window.siyuan.languages.aiFixGrammarSpell}, (response) => { focusByRange(protyle.toolbar.range); insertHTML(response.data, protyle, true); });