Skip to content

Commit 7f62540

Browse files
committed
fix(TaskProcessing): update summary prompt
Signed-off-by: Edward Ly <[email protected]>
1 parent 9a275d3 commit 7f62540

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/TaskProcessing/SummaryProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,18 @@ public function process(?string $userId, array $input, callable $reportProgress)
126126
try {
127127
$completions = [];
128128
if ($this->openAiAPIService->isUsingOpenAi() || $this->openAiSettingsService->getChatEndpointEnabled()) {
129-
$summarySystemPrompt = 'Summarize the following text in the same language as the text.';
129+
$summarySystemPrompt = 'You are a helpful assistant that summarizes text in the same language as the text. ' .
130+
'You should only return the summary without any additional information.';
130131

131132
foreach ($prompts as $p) {
132133
$completion = $this->openAiAPIService->createChatCompletion($userId, $model, $p, $summarySystemPrompt, null, 1, $maxTokens);
133134
$completions[] = $completion['messages'];
134135
}
135136
} else {
136137
$wrapSummaryPrompt = function (string $p): string {
137-
return 'Summarize the following text delimited by XML tags in the same language as the text.\n\n<text>\n' . $p . '\n</text>';
138+
return 'You are a helpful assistant that summarizes text in the same language as the text. ' .
139+
'You should only return the summary without any additional information. ' .
140+
'Here is the text to summarize:\n\n' . $p . '\n';
138141
};
139142

140143
foreach (array_map($wrapSummaryPrompt, $prompts) as $p) {

tests/unit/Providers/OpenAiProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ public function testSummaryProvider(): void {
391391
$url = self::OPENAI_API_BASE . 'chat/completions';
392392

393393
$options = ['timeout' => Application::OPENAI_DEFAULT_REQUEST_TIMEOUT, 'headers' => ['User-Agent' => Application::USER_AGENT, 'Authorization' => self::AUTHORIZATION_HEADER, 'Content-Type' => 'application/json']];
394-
$systemPrompt = 'Summarize the following text in the same language as the text.';
394+
$systemPrompt = 'You are a helpful assistant that summarizes text in the same language as the text. ' .
395+
'You should only return the summary without any additional information.';
395396
$options['body'] = json_encode([
396397
'model' => Application::DEFAULT_COMPLETION_MODEL_ID,
397398
'messages' => [['role' => 'system', 'content' => $systemPrompt],

0 commit comments

Comments
 (0)