Skip to content

Commit

Permalink
feat: Allow answering in the same langauge as the input
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Jun 7, 2024
1 parent efdee89 commit 8f19d07
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/TextProcessing/HeadlineProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getName(): string {
public function process(string $prompt): string {
$startTime = time();
$adminModel = $this->config->getAppValue(Application::APP_ID, 'default_completion_model_id', Application::DEFAULT_COMPLETION_MODEL_ID) ?: Application::DEFAULT_COMPLETION_MODEL_ID;
$prompt = 'Give me the headline of the following text:' . "\n\n" . $prompt;
$prompt = 'Give me the headline of the following text in its original language. Output only the headline.' . "\n\n" . $prompt;
// Max tokens are limited later to max tokens specified in the admin settings so here we just request PHP_INT_MAX
try {
if ($this->openAiAPIService->isUsingOpenAi() || $this->openAiSettingsService->getChatEndpointEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/TextProcessing/ReformulateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getName(): string {
public function process(string $prompt): string {
$startTime = time();
$adminModel = $this->config->getAppValue(Application::APP_ID, 'default_completion_model_id', Application::DEFAULT_COMPLETION_MODEL_ID) ?: Application::DEFAULT_COMPLETION_MODEL_ID;
$prompt = 'Reformulate the following text:' . "\n\n" . $prompt;
$prompt = 'Reformulate the following text. Detect the language of the text. Use the same language as the original text. Output only the reformulation. Here is the text:' . "\n\n" . $prompt . "\n\n" . 'Here is your reformulation in the same language:';
// Max tokens are limited later to max tokens specified in the admin settings so here we just request PHP_INT_MAX
try {
if ($this->openAiAPIService->isUsingOpenAi() || $this->openAiSettingsService->getChatEndpointEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/TextProcessing/SummaryProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function process(string $prompt): string {
// to try it out:
// curl -H "content-type: application/json" -H "ocs-apirequest: true" -u user:pass http://localhost/dev/server/ocs/v2.php/textprocessing/schedule -d '{"input":"this is a short sentence to talk about food and weather and sport","type":"OCP\\TextProcessing\\SummaryTaskType","appId":"plopapp","identifier":"superidentifier"}' -X POST
$adminModel = $this->config->getAppValue(Application::APP_ID, 'default_completion_model_id', Application::DEFAULT_COMPLETION_MODEL_ID) ?: Application::DEFAULT_COMPLETION_MODEL_ID;
$prompt = 'Summarize the following text:' . "\n\n" . $prompt;
$prompt = 'Summarize the following text. Detect the language of the text. Use the same language as the text. Output only the summary. Here is the text:' . "\n\n" . $prompt . "\n\n" . 'Here is your summary in the same language as the text:';
// Max tokens are limited later to max tokens specified in the admin settings so here we just request PHP_INT_MAX
try {
if ($this->openAiAPIService->isUsingOpenAi() || $this->openAiSettingsService->getChatEndpointEnabled()) {
Expand Down

0 comments on commit 8f19d07

Please sign in to comment.