blob: 55c0cfef3bfe78af8ac04cdc53d112cf87f17ec6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<?php
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Testing\Provider;
use OCP\TextProcessing\FreePromptTaskType;
use OCP\TextProcessing\IProviderWithExpectedRuntime;
use OCP\TextProcessing\ITaskType;
/**
* @template-implements IProviderWithExpectedRuntime<FreePromptTaskType|ITaskType>
*/
class FakeTextProcessingProviderSync implements IProviderWithExpectedRuntime {
public function getName(): string {
return 'Fake text processing provider (synchronous)';
}
public function process(string $prompt): string {
return $this->mb_strrev($prompt) . ' (done with FakeTextProcessingProviderSync)';
}
public function getTaskType(): string {
return FreePromptTaskType::class;
}
public function getExpectedRuntime(): int {
return 1;
}
/**
* Reverse a miltibyte string.
*
* @param string $string The string to be reversed.
* @return string The reversed string
*/
private function mb_strrev(string $string): string {
$chars = mb_str_split($string, 1);
return implode('', array_reverse($chars));
}
}
|