diff --git a/lib/core/util/chat_title.dart b/lib/core/util/chat_title.dart index 4317aba..121a837 100644 --- a/lib/core/util/chat_title.dart +++ b/lib/core/util/chat_title.dart @@ -1,13 +1,15 @@ abstract final class ChatTitleUtil { static const _maxLen = 20; + static const userCotentLocator = 'GPTBOX>>>'; + static const titlePrompt = ''' -Generate a title for the user content behind `GPTBOX>>>` with requirements: +Generate a title for the user content behind `$userCotentLocator` with requirements: 0. the language of the generated title should be the same as the user content 1. <= 10 characters if Chinese, Japanese, Korean, etc. 2. <= $_maxLen letters if English, German, French, etc. -3. the title should be meaningful, concise, no additional punctuation and only title itself -GPTBOX>>>'''; +3. the title should be meaningful, concise, no additional punctuation and only title itself. +$userCotentLocator'''; static final _punctionsRm = RegExp('[“”]'); @@ -16,6 +18,8 @@ GPTBOX>>>'''; if (title.startsWith('《')) title = title.substring(1); if (title.endsWith('》')) title = title.substring(0, title.length - 1); + title = title.replaceFirst(userCotentLocator, ''); + title = title.replaceAll(_punctionsRm, ''); title = title.replaceAll('\n', ' ');