nextcloud/lib/public/LanguageModel/SummaryTask.php
Marcel Klehr 9d5717d239 LLM OCP API: ADd topics and headline tasks
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
2023-07-07 13:39:10 +02:00

29 lines
713 B
PHP

<?php
namespace OCP\LanguageModel;
use RuntimeException;
final class SummaryTask extends AbstractLanguageModelTask {
public const TYPE = 'summarize';
/**
* @param ILanguageModelProvider $provider
* @throws RuntimeException
* @return string
*/
public function visitProvider(ILanguageModelProvider $provider): string {
if (!$provider instanceof ISummaryProvider) {
throw new \RuntimeException('SummaryTask#visitProvider expects ISummaryProvider');
}
return $provider->summarize($this->getInput());
}
public function canUseProvider(ILanguageModelProvider $provider): bool {
return $provider instanceof ISummaryProvider;
}
public function getType(): string {
return self::TYPE;
}
}