Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
2e9dea2
Initial work on lm OCP API
marcelklehr Jun 15, 2023
457f1eb
LLM OCP API: Rework to use Task objects
marcelklehr Jun 15, 2023
d20ee42
LLM OCP API: Implement private backend code + add ILanguageModelTask
marcelklehr Jun 16, 2023
7031072
LLM OCP API: Add db migration
marcelklehr Jun 16, 2023
ed3672a
LLM OCP API: Add to RegistrationContext
marcelklehr Jun 16, 2023
33f3379
Fix Copyright
marcelklehr Jun 19, 2023
5807c43
LLM OCP API: ADd topics and headline tasks
marcelklehr Jun 20, 2023
236c32b
LLM OCP API: Implement ocs API
marcelklehr Jun 20, 2023
76a5db8
LLM OCP API: cs:fix
marcelklehr Jun 20, 2023
01db2cf
LLM OCP API: Make linters happy
marcelklehr Jun 20, 2023
dbd9420
LLM OCP API: Fix type errors
marcelklehr Jun 20, 2023
0024f0d
LLM OCP API: Add @since
marcelklehr Jun 20, 2023
02c78be
LLM OCP API: Fix static analysis
marcelklehr Jun 20, 2023
612af73
LLM OCP API: cs:fix
marcelklehr Jun 20, 2023
dd7eafa
LLM OCP API: Fix coding style and psalm
marcelklehr Jun 20, 2023
6320c68
Update lib/public/LanguageModel/ITopicsProvider.php
marcelklehr Jun 26, 2023
ecda18b
LLM OCP API: Add task definitions
marcelklehr Jun 26, 2023
1ac86d2
LLM OCP API: Commit autoloaders
marcelklehr Jun 26, 2023
4e3ca11
Update lib/public/AppFramework/Bootstrap/IRegistrationContext.php
marcelklehr Jun 27, 2023
4405027
Apply suggestions from code review
marcelklehr Jun 27, 2023
c8bbe8f
LLM OCP API: Type shenanigans for Visitor pattern
marcelklehr Jun 27, 2023
ddeaaea
LLM OCP API: strict types and copyright
marcelklehr Jun 27, 2023
d203e3a
OCP: Introduce OCP\Common\Exception\NotFoundException
marcelklehr Jun 27, 2023
fb9262e
LLM OCP API: Use OCP\Common\Exception\NotFoundException
marcelklehr Jun 27, 2023
e90dd4a
LLM OCP API: Fix copyright
marcelklehr Jun 27, 2023
44ce285
cs:fix
marcelklehr Jun 27, 2023
91325ef
Add tasks::last_updated column and vacate tasks after a week
marcelklehr Jun 28, 2023
2234497
TaskMapper#update: Use time factory
marcelklehr Jun 28, 2023
970d688
ILanguageModelManager: Add docblock description
marcelklehr Jun 28, 2023
c1085bf
ILanguageModelTask: Use php type checking along with psalm parameteri…
marcelklehr Jun 28, 2023
a462750
Add preliminary tests
marcelklehr Jun 28, 2023
d21f7bf
Fix tests
marcelklehr Jun 29, 2023
e717959
Make tests pass
marcelklehr Jun 29, 2023
09a8541
Add test for task cleanup
marcelklehr Jun 30, 2023
8197403
Fix LanguageModelManager#runTask: Insert task into db if it doesn't e…
marcelklehr Jun 30, 2023
4447d59
cs:fix
marcelklehr Jun 30, 2023
97a4a06
Apply suggestions from code review
marcelklehr Jul 6, 2023
ffedceb
LLM OCP API: Add identifier param
marcelklehr Jul 6, 2023
8f0618d
LLM OCP API: Fix psalm error
marcelklehr Jul 6, 2023
445b72a
LLM OCP API: Fix security issue
marcelklehr Jul 6, 2023
7320011
LLM OCP API: Fix psam errors
marcelklehr Jul 6, 2023
d9f2aaf
LLM OCP API: Fix psam error
marcelklehr Jul 6, 2023
8567315
LLM OCS API: s/tasks/tasktypes/
marcelklehr Jul 7, 2023
e312b2b
LLM OCS API: Add OpenAPI docs
marcelklehr Jul 7, 2023
22a93bf
Apply suggestions from code review
marcelklehr Jul 7, 2023
7a423e4
Update lib/public/LanguageModel/ILanguageModelProvider.php
marcelklehr Jul 7, 2023
9a36bb4
Update lib/public/LanguageModel/Events/TaskFailedEvent.php
marcelklehr Jul 7, 2023
b0cb5a4
LLM Migration: Return null if nothing changed
marcelklehr Jul 7, 2023
3350811
LLM OCP API: Add missing copyright and strict types
marcelklehr Jul 7, 2023
70e65ff
LLM OCP API: s/getAvailableTasks/getAvailableTaskClasses/
marcelklehr Jul 7, 2023
39bc710
LLM OCP API: Simplify LanguageModelManager#canHandleTask
marcelklehr Jul 7, 2023
ddb2726
LLM OCP API: Don't lose trace of wrapped exceptions
marcelklehr Jul 7, 2023
4ce77b9
LLM OCP API: Explain TaskBackgroundJob#setAllowParallelRuns
marcelklehr Jul 7, 2023
d578974
LLM OCP API: Simplify TaskBackgroundJob#run catch block
marcelklehr Jul 7, 2023
413a4f6
OCP\Common\NotFoundException: Add param type
marcelklehr Jul 7, 2023
5e86054
LLM OCP API: Avoid using OC in OCP
marcelklehr Jul 7, 2023
17351b6
LLM OCP API: Fix psalm issues
marcelklehr Jul 7, 2023
39d59a1
LLM OCP API: Fix OpenApi docs
marcelklehr Jul 7, 2023
15f08a7
LLM OCP API: Improve scheduleTask docblock
marcelklehr Jul 7, 2023
6b2687e
LLM OCP API: Change Tests to use EventDispatcher mock
marcelklehr Jul 7, 2023
a39e3c9
cs:fix
marcelklehr Jul 7, 2023
1ad0a29
LanguageModelApiController: Use jsonSerialize method to help psalm
marcelklehr Jul 7, 2023
8acb1dc
Since 27.1.0
marcelklehr Jul 7, 2023
fbd178a
Update core/Controller/LanguageModelApiController.php
marcelklehr Jul 11, 2023
6f5119c
Fix openapi docs
marcelklehr Jul 11, 2023
5d975b9
Update core/Controller/LanguageModelApiController.php
marcelklehr Jul 11, 2023
696a45d
Update core/Controller/LanguageModelApiController.php
marcelklehr Jul 11, 2023
cf2c42a
Massive refactoring: Turn LanguageModel OCP API into TextProcessing API
marcelklehr Jul 14, 2023
d8c44da
Fix psalm errors
marcelklehr Jul 14, 2023
87ac995
Fix psalm errors
marcelklehr Jul 14, 2023
322bb97
Apply suggestions from code review
marcelklehr Jul 17, 2023
4118baa
Update autoloaders
marcelklehr Jul 17, 2023
2d296ce
cs:fix
marcelklehr Jul 17, 2023
96ec6ff
Fix psalm errors
marcelklehr Jul 17, 2023
00e3fb1
Remove Task::factory method
marcelklehr Jul 19, 2023
cac5171
Fix tests: Adjust constructor signature
marcelklehr Jul 19, 2023
ad645c9
Fix tests: Adjust constructor signature
marcelklehr Jul 19, 2023
cc5818f
First pass at ai admin settings
marcelklehr Jul 24, 2023
43926a2
AI Admin settings: Implement mt settings, stt settings and tp settings
marcelklehr Jul 24, 2023
d4b2012
fix(TextProcessing): Inject L10N\IFactory instead of IL10N
marcelklehr Jul 24, 2023
674fd35
AI admin settings: Add save mechanism
marcelklehr Jul 24, 2023
7fd0b1b
AI admin settings: Use config values in AI feature managers
marcelklehr Jul 25, 2023
850a92e
AI admin settings: Add a draggable icon in UI for translation provide…
marcelklehr Jul 25, 2023
40d4da1
AI admin settings: Update composer autoloaders
marcelklehr Jul 25, 2023
6c8c047
AI admin settings: strict_types
marcelklehr Jul 25, 2023
832e0d3
AI admin settings: cs:fix
marcelklehr Jul 25, 2023
8507112
AI admin settings: lint:fix
marcelklehr Jul 25, 2023
9e6a864
AI admin settings: lint:fix
marcelklehr Jul 25, 2023
4b97ec7
AI admin settings: lint:fix
marcelklehr Jul 25, 2023
50adc8c
Migration: Drop llm_tasks table and add textprocessing_tasks
marcelklehr Jul 28, 2023
f4160e0
Fix typo
marcelklehr Jul 28, 2023
d13ceb3
Update apps/settings/src/components/AdminAI.vue
marcelklehr Jul 28, 2023
dbcfef1
Update apps/settings/src/components/AdminAI.vue
marcelklehr Jul 28, 2023
3d9a588
Admin AI settings: Improve a11y of machine translation precendence
marcelklehr Jul 28, 2023
8dee7d0
Admin AI settings: Use ContainerInterface instead of IServerContainer
marcelklehr Jul 28, 2023
52a1748
move long click handlers into methods
julien-nc Aug 1, 2023
f95cf63
use DB type constants
julien-nc Aug 1, 2023
67fa798
polish AI admin settings UI
julien-nc Aug 1, 2023
0029171
fix wrong NcSelect event in AI admin settings
julien-nc Aug 1, 2023
2d9a064
fix composer autoload files
julien-nc Aug 1, 2023
4bae251
fix: missing argument for TextProcessing Manager
kesselb Aug 2, 2023
41918cc
Fix TextProcessing test for 32bit
marcelklehr Aug 7, 2023
6eb1857
start implementing ocs endpoint to get task list from user+appId+iden…
julien-nc Aug 2, 2023
8e657a8
allow anon text processing scheduling
julien-nc Aug 3, 2023
f363f11
change sql where order to match index order
julien-nc Aug 4, 2023
0564bd2
feat: Add delete task API
juliusknorr Aug 4, 2023
993a559
fix psalm issue
julien-nc Aug 7, 2023
79d43fa
fix eslint issue
julien-nc Aug 9, 2023
8a9ad05
fix psalm issues
julien-nc Aug 9, 2023
240eb88
bump last version digit
julien-nc Aug 9, 2023
71db3ff
compile assets
julien-nc Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
LLM OCP API: Add @SInCE
Signed-off-by: Marcel Klehr <[email protected]>
(cherry picked from commit 9935034)
  • Loading branch information
marcelklehr committed Aug 9, 2023
commit 0024f0d1cb12421ec6fd59b01875c8b2045ad657
38 changes: 38 additions & 0 deletions lib/public/LanguageModel/AbstractLanguageModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

use OC\LanguageModel\Db\Task;

/**
* @since 28.0.0
*/
abstract class AbstractLanguageModelTask implements ILanguageModelTask {
protected ?int $id;
protected ?string $output;
protected int $status = ILanguageModelTask::STATUS_UNKNOWN;

/**
* @param string $input
* @param string $appId
* @param string|null $userId
* @since 28.0.0
*/
final public function __construct(
protected string $input,
protected string $appId,
Expand All @@ -20,76 +29,99 @@ final public function __construct(
* @param ILanguageModelProvider $provider
* @return string
* @throws \RuntimeException
* @since 28.0.0
*/
abstract public function visitProvider(ILanguageModelProvider $provider): string;

/**
* @param ILanguageModelProvider $provider
* @return bool
* @since 28.0.0
*/
abstract public function canUseProvider(ILanguageModelProvider $provider): bool;

/**
* @return string
* @since 28.0.0
*/
abstract public function getType(): string;

/**
* @return string|null
* @since 28.0.0
*/
final public function getOutput(): ?string {
return $this->output;
}

/**
* @param string|null $output
* @since 28.0.0
*/
final public function setOutput(?string $output): void {
$this->output = $output;
}

/**
* @return int
* @since 28.0.0
*/
final public function getStatus(): int {
return $this->status;
}

/**
* @param int $status
* @since 28.0.0
*/
final public function setStatus(int $status): void {
$this->status = $status;
}

/**
* @return int|null
* @since 28.0.0
*/
final public function getId(): ?int {
return $this->id;
}

/**
* @param int|null $id
* @since 28.0.0
*/
final public function setId(?int $id): void {
$this->id = $id;
}

/**
* @return string
* @since 28.0.0
*/
final public function getInput(): string {
return $this->input;
}

/**
* @return string
* @since 28.0.0
*/
final public function getAppId(): string {
return $this->appId;
}

/**
* @return string|null
* @since 28.0.0
*/
final public function getUserId(): ?string {
return $this->userId;
}

/**
* @return array
* @since 28.0.0
*/
public function jsonSerialize() {
return [
'id' => $this->getId(),
Expand All @@ -103,6 +135,11 @@ public function jsonSerialize() {
}


/**
* @param Task $taskEntity
* @return 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->setId($taskEntity->getId());
Expand All @@ -117,6 +154,7 @@ final public static function fromTaskEntity(Task $taskEntity): ILanguageModelTas
* @param string $appId
* @return ILanguageModelTask
* @throws \InvalidArgumentException
* @since 28.0.0
*/
final public static function factory(string $type, string $input, ?string $userId, string $appId): ILanguageModelTask {
if (!in_array($type, self::TYPES)) {
Expand Down
1 change: 1 addition & 0 deletions lib/public/LanguageModel/Events/TaskFailedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function __construct(ILanguageModelTask $task,

/**
* @return string
* @since 28.0.0
*/
public function getErrorMessage(): string {
return $this->errorMessage;
Expand Down
10 changes: 7 additions & 3 deletions lib/public/LanguageModel/FreePromptTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

use RuntimeException;

/**
* @since 28.0.0
*/
final class FreePromptTask extends AbstractLanguageModelTask {
/**
* @since 28.0.0
*/
public const TYPE = 'free_prompt';

/**
* @param ILanguageModelProvider $provider
* @throws RuntimeException
* @return string
* @inheritDoc
*/
public function visitProvider(ILanguageModelProvider $provider): string {
return $provider->prompt($this->getInput());
Expand Down
6 changes: 6 additions & 0 deletions lib/public/LanguageModel/HeadlineTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

use RuntimeException;

/**
* @since 28.0.0
*/
final class HeadlineTask extends AbstractLanguageModelTask {
/**
* @since 28.0.0
*/
public const TYPE = 'headline';

/**
Expand Down
1 change: 1 addition & 0 deletions lib/public/LanguageModel/ILanguageModelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function scheduleTask(ILanguageModelTask $task) : void;
* @return ILanguageModelTask
* @throws RuntimeException If the query failed
* @throws \ValueError If the task could not be found
* @since 28.0.0
*/
public function getTask(int $id): ILanguageModelTask;
}
41 changes: 41 additions & 0 deletions lib/public/LanguageModel/ILanguageModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,113 @@

namespace OCP\LanguageModel;

/**
* @since 28.0.0
*/
interface ILanguageModelTask extends \JsonSerializable {
/**
* @since 28.0.0
*/
public const STATUS_FAILED = 4;
/**
* @since 28.0.0
*/
public const STATUS_SUCCESSFUL = 3;
/**
* @since 28.0.0
*/
public const STATUS_RUNNING = 2;
/**
* @since 28.0.0
*/
public const STATUS_SCHEDULED = 1;
/**
* @since 28.0.0
*/
public const STATUS_UNKNOWN = 0;

/**
* @since 28.0.0
*/
public const TYPES = [
FreePromptTask::TYPE => FreePromptTask::class,
SummaryTask::TYPE => SummaryTask::class,
HeadlineTask::TYPE => HeadlineTask::class,
TopicsTask::TYPE => TopicsTask::class,
];

/**
* @param ILanguageModelProvider $provider
* @return string
* @since 28.0.0
*/
public function visitProvider(ILanguageModelProvider $provider): string;

/**
* @param ILanguageModelProvider $provider
* @return bool
* @since 28.0.0
*/
public function canUseProvider(ILanguageModelProvider $provider): bool;


/**
* @return string
* @since 28.0.0
*/
public function getType(): string;

/**
* @return int
* @since 28.0.0
*/
public function getStatus(): int;

/**
* @param int $status
* @since 28.0.0
*/
public function setStatus(int $status): void;

/**
* @param int|null $id
* @since 28.0.0
*/
public function setId(?int $id): void;

/**
* @return int|null
* @since 28.0.0
*/
public function getId(): ?int;

/**
* @return string
* @since 28.0.0
*/
public function getInput(): string;

/**
* @param string|null $output
* @since 28.0.0
*/
public function setOutput(?string $output): void;

/**
* @return null|string
* @since 28.0.0
*/
public function getOutput(): ?string;

/**
* @return string
* @since 28.0.0
*/
public function getAppId(): string;

/**
* @return string|null
* @since 28.0.0
*/
public function getUserId(): ?string;
}