Skip to content

Commit

Permalink
Merge pull request #162 from nextcloud/fix/headline-language
Browse files Browse the repository at this point in the history
fix: English headlines for English text with OpenAI
  • Loading branch information
janepie authored Dec 4, 2024
2 parents f07f69c + 0591ee3 commit a28884f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/TaskProcessing/HeadlineProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function process(?string $userId, array $input, callable $reportProgress)
throw new RuntimeException('Invalid prompt');
}
$prompt = $input['input'];
$prompt = 'Give me the headline of the following text in its original language. Output only the headline.' . "\n\n" . $prompt;
$prompt = 'Give me the headline of the following text in its original language. Do not output the language. Output only the headline without any quotes or additional punctuation.' . "\n\n" . $prompt;

$maxTokens = null;
if (isset($input['max_tokens']) && is_int($input['max_tokens'])) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Providers/OpenAiProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function testHeadlineProvider(): 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']];
$message = 'Give me the headline of the following text in its original language. Output only the headline.' . "\n\n" . $prompt;
$message = 'Give me the headline of the following text in its original language. Do not output the language. Output only the headline without any quotes or additional punctuation.' . "\n\n" . $prompt;
$options['body'] = json_encode(['model' => Application::DEFAULT_COMPLETION_MODEL_ID, 'messages' => [['role' => 'user', 'content' => $message]], 'max_tokens' => Application::DEFAULT_MAX_NUM_OF_TOKENS, 'n' => $n, 'user' => self::TEST_USER1]);

$iResponse = $this->createMock(\OCP\Http\Client\IResponse::class);
Expand Down

0 comments on commit a28884f

Please sign in to comment.