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",
"warning": "⚠️ AI responses can be inaccurate or misleading.",
"smartEditSummarize": "Summarize",
"smartEditImproveWriting":"Improve Writing",
"smartEditCouldNotFetchResult": "Could not fetch result from OpenAI",
"smartEditCouldNotFetchKey": "Could not fetch OpenAI key",
"smartEditDisabled": "Connect OpenAI in Settings",

View File

@ -5,7 +5,8 @@ import 'package:easy_localization/easy_localization.dart';
enum SmartEditAction {
summarize,
fixSpelling;
fixSpelling,
improveWriting;
String get toInstruction {
switch (this) {
@ -13,6 +14,8 @@ enum SmartEditAction {
return 'Tl;dr';
case SmartEditAction.fixSpelling:
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';
case SmartEditAction.fixSpelling:
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;
case 1:
return SmartEditAction.fixSpelling;
case 2:
return SmartEditAction.improveWriting;
}
return SmartEditAction.fixSpelling;
}
@ -41,6 +48,8 @@ enum SmartEditAction {
return LocaleKeys.document_plugins_smartEditSummarize.tr();
case SmartEditAction.fixSpelling:
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 {
setState(() {
this.result += response.choices.first.text;
if (response.choices.first.text != '\n') {
this.result += response.choices.first.text;
}
});
},
onEnd: () async {