diff --git a/lib/public/LanguageModel/HeadlineTask.php b/lib/public/LanguageModel/HeadlineTask.php new file mode 100644 index 00000000000..003488b6841 --- /dev/null +++ b/lib/public/LanguageModel/HeadlineTask.php @@ -0,0 +1,29 @@ +findHeadline($this->getInput()); + } + + public function canUseProvider(ILanguageModelProvider $provider): bool { + return $provider instanceof IHeadlineProvider; + } + + public function getType(): string { + return self::TYPE; + } +} diff --git a/lib/public/LanguageModel/IHeadlineProvider.php b/lib/public/LanguageModel/IHeadlineProvider.php new file mode 100644 index 00000000000..2ade27d2f74 --- /dev/null +++ b/lib/public/LanguageModel/IHeadlineProvider.php @@ -0,0 +1,43 @@ + + * + * @author Marcel Klehr + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + + +namespace OCP\LanguageModel; + +use RuntimeException; + +/** + * @since 28.0.0 + */ +interface IHeadlineProvider extends ILanguageModelProvider { + + /** + * @param string $text The text to find headline for + * @returns string the headline + * @since 28.0.0 + * @throws RuntimeException If the text could not be transcribed + */ + public function findHeadline(string $text): string; +} diff --git a/lib/public/LanguageModel/ILanguageModelTask.php b/lib/public/LanguageModel/ILanguageModelTask.php index 478ee54e8a3..3775546d4f0 100644 --- a/lib/public/LanguageModel/ILanguageModelTask.php +++ b/lib/public/LanguageModel/ILanguageModelTask.php @@ -2,7 +2,7 @@ namespace OCP\LanguageModel; -interface ILanguageModelTask { +interface ILanguageModelTask extends \JsonSerializable { public const STATUS_FAILED = 4; public const STATUS_SUCCESSFUL = 3; public const STATUS_RUNNING = 2; @@ -10,8 +10,10 @@ interface ILanguageModelTask { public const STATUS_UNKNOWN = 0; public const TYPES = [ - SummaryTask::TYPE => SummaryTask::class, FreePromptTask::TYPE => FreePromptTask::class, + SummaryTask::TYPE => SummaryTask::class, + HeadlineTask::TYPE => HeadlineTask::class, + TopicsTask::TYPE => TopicsTask::class, ]; /** @@ -44,6 +46,16 @@ interface ILanguageModelTask { */ public function getInput(): string; + /** + * @param string $output + */ + public function setOutput(string $output): void; + + /** + * @return string + */ + public function getOutput(): string; + /** * @return string */ diff --git a/lib/public/LanguageModel/ITopicsProvider.php b/lib/public/LanguageModel/ITopicsProvider.php new file mode 100644 index 00000000000..a55df0d7044 --- /dev/null +++ b/lib/public/LanguageModel/ITopicsProvider.php @@ -0,0 +1,43 @@ + + * + * @author Marcel Klehr + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + + +namespace OCP\LanguageModel; + +use RuntimeException; + +/** + * @since 28.0.0 + */ +interface ITopicsProvider extends ILanguageModelProvider { + + /** + * @param string $text The text to find topics for + * @returns string the topics, comma separated + * @since 28.0.0 + * @throws RuntimeException If the text could not be transcribed + */ + public function findTopics(string $text): string; +} diff --git a/lib/public/LanguageModel/SummaryTask.php b/lib/public/LanguageModel/SummaryTask.php index 35f20cebfb6..3c300246f03 100644 --- a/lib/public/LanguageModel/SummaryTask.php +++ b/lib/public/LanguageModel/SummaryTask.php @@ -8,7 +8,7 @@ final class SummaryTask extends AbstractLanguageModelTask { public const TYPE = 'summarize'; /** - * @param ILanguageModelProvider&ISummaryProvider $provider + * @param ILanguageModelProvider $provider * @throws RuntimeException * @return string */ diff --git a/lib/public/LanguageModel/TopicsTask.php b/lib/public/LanguageModel/TopicsTask.php new file mode 100644 index 00000000000..98ffabfc815 --- /dev/null +++ b/lib/public/LanguageModel/TopicsTask.php @@ -0,0 +1,29 @@ +findTopics($this->getInput()); + } + + public function canUseProvider(ILanguageModelProvider $provider): bool { + return $provider instanceof ITopicsProvider; + } + + public function getType(): string { + return self::TYPE; + } +}