mirror of
https://github.com/nextcloud/server.git
synced 2026-04-27 01:00:20 -04:00
LLM OCP API: Fix static analysis
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
9935034480
commit
fac83ce4b6
4 changed files with 35 additions and 8 deletions
|
|
@ -110,10 +110,11 @@ class LanguageModelManager implements ILanguageModelManager {
|
|||
try {
|
||||
$task->setStatus(ILanguageModelTask::STATUS_RUNNING);
|
||||
$this->taskMapper->update(Task::fromLanguageModelTask($task));
|
||||
$task->setOutput($task->visitProvider($provider));
|
||||
$output = $task->visitProvider($provider);
|
||||
$task->setOutput($output);
|
||||
$task->setStatus(ILanguageModelTask::STATUS_SUCCESSFUL);
|
||||
$this->taskMapper->update(Task::fromLanguageModelTask($task));
|
||||
return $task->getOutput();
|
||||
return $output;
|
||||
} catch (\RuntimeException $e) {
|
||||
$this->logger->info('LanguageModel call using provider ' . $provider->getName() . ' failed', ['exception' => $e]);
|
||||
$task->setStatus(ILanguageModelTask::STATUS_FAILED);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,16 @@ final class FreePromptTask extends AbstractLanguageModelTask {
|
|||
return $provider->prompt($this->getInput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function canUseProvider(ILanguageModelProvider $provider): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string {
|
||||
return self::TYPE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,17 @@ namespace OCP\LanguageModel;
|
|||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @since 28.0.0
|
||||
*/
|
||||
final class SummaryTask extends AbstractLanguageModelTask {
|
||||
/**
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public const TYPE = 'summarize';
|
||||
|
||||
/**
|
||||
* @param ILanguageModelProvider $provider
|
||||
* @throws RuntimeException
|
||||
* @return string
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function visitProvider(ILanguageModelProvider $provider): string {
|
||||
if (!$provider instanceof ISummaryProvider) {
|
||||
|
|
@ -19,10 +23,16 @@ final class SummaryTask extends AbstractLanguageModelTask {
|
|||
return $provider->summarize($this->getInput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function canUseProvider(ILanguageModelProvider $provider): bool {
|
||||
return $provider instanceof ISummaryProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string {
|
||||
return self::TYPE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,17 @@ namespace OCP\LanguageModel;
|
|||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* @since 28.0.0
|
||||
*/
|
||||
final class TopicsTask extends AbstractLanguageModelTask {
|
||||
/**
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public const TYPE = 'topics';
|
||||
|
||||
/**
|
||||
* @param ILanguageModelProvider $provider
|
||||
* @throws RuntimeException
|
||||
* @return string
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function visitProvider(ILanguageModelProvider $provider): string {
|
||||
if (!$provider instanceof ITopicsProvider) {
|
||||
|
|
@ -19,10 +23,16 @@ final class TopicsTask extends AbstractLanguageModelTask {
|
|||
return $provider->findTopics($this->getInput());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function canUseProvider(ILanguageModelProvider $provider): bool {
|
||||
return $provider instanceof ITopicsProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string {
|
||||
return self::TYPE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue