mirror of
https://github.com/nextcloud/server.git
synced 2026-02-17 18:00:44 -05:00
LLM OCP API: Add identifier param
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
5b772468ad
commit
f6f8cb4331
4 changed files with 33 additions and 5 deletions
|
|
@ -78,6 +78,11 @@ class Version28000Date20230616104802 extends SimpleMigrationStep {
|
|||
'length' => 32,
|
||||
'default' => '',
|
||||
]);
|
||||
$table->addColumn('identifier', Types::STRING, [
|
||||
'notnull' => true,
|
||||
'length' => 255,
|
||||
'default' => '',
|
||||
]);
|
||||
$table->addColumn('last_updated', 'integer', [
|
||||
'notnull' => false,
|
||||
'length' => 4,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ use OCP\LanguageModel\ILanguageModelTask;
|
|||
* @method string getuserId()
|
||||
* @method setAppId(string $type)
|
||||
* @method string getAppId()
|
||||
* @method setIdentifier(string $type)
|
||||
* @method string getIdentifier()
|
||||
*/
|
||||
class Task extends Entity {
|
||||
protected $lastUpdated;
|
||||
|
|
@ -29,16 +31,17 @@ class Task extends Entity {
|
|||
protected $status;
|
||||
protected $userId;
|
||||
protected $appId;
|
||||
protected $identifier;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id'];
|
||||
public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'identifier'];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId'];
|
||||
public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'identifier'];
|
||||
|
||||
|
||||
public function __construct() {
|
||||
|
|
@ -51,6 +54,7 @@ class Task extends Entity {
|
|||
$this->addType('status', 'integer');
|
||||
$this->addType('userId', 'string');
|
||||
$this->addType('appId', 'string');
|
||||
$this->addType('identifier', 'string');
|
||||
}
|
||||
|
||||
public function toRow(): array {
|
||||
|
|
@ -69,6 +73,7 @@ class Task extends Entity {
|
|||
'output' => $task->getOutput(),
|
||||
'userId' => $task->getUserId(),
|
||||
'appId' => $task->getAppId(),
|
||||
'identifier' => $task->getIdentifier(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,14 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
|
|||
* @param string $input
|
||||
* @param string $appId
|
||||
* @param string|null $userId
|
||||
* @param string $identifier An arbitrary identifier for this task. max length: 255 chars
|
||||
* @since 28.0.0
|
||||
*/
|
||||
final public function __construct(
|
||||
protected string $input,
|
||||
protected string $appId,
|
||||
protected ?string $userId,
|
||||
protected string $identifier = '',
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -122,6 +124,14 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
|
|||
return $this->appId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 28.0.0
|
||||
*/
|
||||
final public function getIdentifier(): string {
|
||||
return $this->identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @since 28.0.0
|
||||
|
|
@ -143,6 +153,7 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
|
|||
'appId' => $this->getAppId(),
|
||||
'input' => $this->getInput(),
|
||||
'output' => $this->getOutput(),
|
||||
'identifier' => $this->getIdentifier(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -153,7 +164,7 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
|
|||
* @since 28.0.0
|
||||
*/
|
||||
final public static function fromTaskEntity(Task $taskEntity): ILanguageModelTask {
|
||||
$task = self::factory($taskEntity->getType(), $taskEntity->getInput(), $taskEntity->getuserId(), $taskEntity->getAppId());
|
||||
$task = self::factory($taskEntity->getType(), $taskEntity->getInput(), $taskEntity->getuserId(), $taskEntity->getAppId(), $taskEntity->getIdentifier());
|
||||
$task->setId($taskEntity->getId());
|
||||
$task->setStatus($taskEntity->getStatus());
|
||||
$task->setOutput($taskEntity->getOutput());
|
||||
|
|
@ -165,14 +176,15 @@ abstract class AbstractLanguageModelTask implements ILanguageModelTask {
|
|||
* @param string $input
|
||||
* @param string|null $userId
|
||||
* @param string $appId
|
||||
* @param string $identifier
|
||||
* @return ILanguageModelTask
|
||||
* @throws \InvalidArgumentException
|
||||
* @since 28.0.0
|
||||
*/
|
||||
final public static function factory(string $type, string $input, ?string $userId, string $appId): ILanguageModelTask {
|
||||
final public static function factory(string $type, string $input, ?string $userId, string $appId, string $identifier): ILanguageModelTask {
|
||||
if (!in_array($type, array_keys(self::TYPES))) {
|
||||
throw new \InvalidArgumentException('Unknown task type');
|
||||
}
|
||||
return new (ILanguageModelTask::TYPES[$type])($input, $appId, $userId);
|
||||
return new (ILanguageModelTask::TYPES[$type])($input, $appId, $userId, $identifier);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,12 @@ interface ILanguageModelTask extends \JsonSerializable {
|
|||
*/
|
||||
public function getAppId(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function getIdentifier(): string;
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @since 28.0.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue