Skip to content

Commit

Permalink
opt.: remove GPTBOX>>> from chat title (#22) (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit authored Jun 11, 2024
1 parent d34b90b commit d64df6c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/core/util/chat_title.dart
Original file line number Diff line number Diff line change
@@ -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('[“”]');

Expand All @@ -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', ' ');

Expand Down

0 comments on commit d64df6c

Please sign in to comment.