🎨 加入针对内容块的人工智能辅助支持 https://github.com/siyuan-note/siyuan/issues/7566

This commit is contained in:
Liang Ding 2023-03-08 22:46:58 +08:00
parent faf08d6c60
commit ca65fd777f
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -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({