Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/TaskProcessing/SummaryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,18 @@ public function process(?string $userId, array $input, callable $reportProgress)
try {
$completions = [];
if ($this->openAiAPIService->isUsingOpenAi() || $this->openAiSettingsService->getChatEndpointEnabled()) {
$summarySystemPrompt = 'Summarize the following text in the same language as the text.';
$summarySystemPrompt = 'You are a helpful assistant that summarizes text in the same language as the text. ' .
'You should only return the summary without any additional information.';

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

foreach (array_map($wrapSummaryPrompt, $prompts) as $p) {
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Providers/OpenAiProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ public function testSummaryProvider(): void {
$url = self::OPENAI_API_BASE . 'chat/completions';

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