feat: AI - improve writing (#2257)

* feat: AI - Improve writing

* fix: new line in result

* formatted code
This commit is contained in:
alceil 2023-05-03 12:59:36 +05:30 committed by GitHub
parent 9e3ad1a6be
commit f9095cfc64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -363,6 +363,7 @@
"smartEditFixSpelling": "Fix spelling", "smartEditFixSpelling": "Fix spelling",
"warning": "⚠️ AI responses can be inaccurate or misleading.", "warning": "⚠️ AI responses can be inaccurate or misleading.",
"smartEditSummarize": "Summarize", "smartEditSummarize": "Summarize",
"smartEditImproveWriting":"Improve Writing",
"smartEditCouldNotFetchResult": "Could not fetch result from OpenAI", "smartEditCouldNotFetchResult": "Could not fetch result from OpenAI",
"smartEditCouldNotFetchKey": "Could not fetch OpenAI key", "smartEditCouldNotFetchKey": "Could not fetch OpenAI key",
"smartEditDisabled": "Connect OpenAI in Settings", "smartEditDisabled": "Connect OpenAI in Settings",

View File

@ -5,7 +5,8 @@ import 'package:easy_localization/easy_localization.dart';
enum SmartEditAction { enum SmartEditAction {
summarize, summarize,
fixSpelling; fixSpelling,
improveWriting;
String get toInstruction { String get toInstruction {
switch (this) { switch (this) {
@ -13,6 +14,8 @@ enum SmartEditAction {
return 'Tl;dr'; return 'Tl;dr';
case SmartEditAction.fixSpelling: case SmartEditAction.fixSpelling:
return 'Correct this to standard English:'; return 'Correct this to standard English:';
case SmartEditAction.improveWriting:
return 'Rewrite this in your own words:';
} }
} }
@ -22,6 +25,8 @@ enum SmartEditAction {
return '$input\n\nTl;dr'; return '$input\n\nTl;dr';
case SmartEditAction.fixSpelling: case SmartEditAction.fixSpelling:
return 'Correct this to standard English:\n\n$input'; return 'Correct this to standard English:\n\n$input';
case SmartEditAction.improveWriting:
return 'Rewrite this:\n\n$input';
} }
} }
@ -31,6 +36,8 @@ enum SmartEditAction {
return SmartEditAction.summarize; return SmartEditAction.summarize;
case 1: case 1:
return SmartEditAction.fixSpelling; return SmartEditAction.fixSpelling;
case 2:
return SmartEditAction.improveWriting;
} }
return SmartEditAction.fixSpelling; return SmartEditAction.fixSpelling;
} }
@ -41,6 +48,8 @@ enum SmartEditAction {
return LocaleKeys.document_plugins_smartEditSummarize.tr(); return LocaleKeys.document_plugins_smartEditSummarize.tr();
case SmartEditAction.fixSpelling: case SmartEditAction.fixSpelling:
return LocaleKeys.document_plugins_smartEditFixSpelling.tr(); return LocaleKeys.document_plugins_smartEditFixSpelling.tr();
case SmartEditAction.improveWriting:
return LocaleKeys.document_plugins_smartEditImproveWriting.tr();
} }
} }
} }

View File

@ -356,7 +356,9 @@ class _SmartEditInputState extends State<_SmartEditInput> {
}, },
onProcess: (response) async { onProcess: (response) async {
setState(() { setState(() {
this.result += response.choices.first.text; if (response.choices.first.text != '\n') {
this.result += response.choices.first.text;
}
}); });
}, },
onEnd: () async { onEnd: () async {