Skip to content

Commit f34c687

Browse files
splitbraingithub-actions[bot]
authored andcommitted
🤖 Automatic code style fixes
1 parent c2f5508 commit f34c687

File tree

6 files changed

+11
-27
lines changed

6 files changed

+11
-27
lines changed

‎Embeddings.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ class Embeddings
5151
/**
5252
* Embeddings constructor.
5353
*
54-
* @param ChatInterface $chatModel
55-
* @param EmbeddingInterface $embedModel
56-
* @param AbstractStorage $storage
5754
* @param array $config The plugin configuration
5855
*/
5956
public function __construct(

‎Model/AbstractModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ abstract class AbstractModel implements ModelInterface
3838
protected $requestStart = 0;
3939

4040
/** @var int How often to retry a request if it fails */
41-
public const MAX_RETRIES = 3;
41+
final public const MAX_RETRIES = 3;
4242

4343
/** @var DokuHTTPClient */
4444
protected $http;
@@ -194,7 +194,7 @@ public function setDebug($debug = true)
194194
* @return mixed
195195
* @throws \Exception when the response indicates an error
196196
*/
197-
abstract protected function parseAPIResponse($response);
197+
abstract protected function parseAPIResponse(mixed $response);
198198

199199
/**
200200
* Send a request to the API

‎ModelFactory.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
class ModelFactory
99
{
10-
/** @var array The plugin configuration */
11-
protected array $config;
12-
1310
public $chatModel;
1411
public $rephraseModel;
1512
public $embeddingModel;
@@ -19,9 +16,8 @@ class ModelFactory
1916
/**
2017
* @param array $config The plugin configuration
2118
*/
22-
public function __construct(array $config)
19+
public function __construct(protected array $config)
2320
{
24-
$this->config = $config;
2521
}
2622

2723
/**
@@ -39,8 +35,6 @@ public function updateConfig(array $config)
3935

4036
/**
4137
* Set the debug flag for all models
42-
*
43-
* @param bool $debug
4438
*/
4539
public function setDebug(bool $debug = true)
4640
{
@@ -122,7 +116,7 @@ public function getModels($availableOnly = false, $typeOnly = '')
122116
try {
123117
$info['instance'] = $this->loadModel($type, "$namespace $name");
124118
$info['instance']->setDebug($this->debug);
125-
} catch (\Exception $e) {
119+
} catch (\Exception) {
126120
if ($availableOnly) continue;
127121
$info['instance'] = false;
128122
}

‎cli/dev.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use dokuwiki\HTTP\DokuHTTPClient;
34
use dokuwiki\plugin\aichat\AbstractCLI;
45
use splitbrain\phpcli\Options;
56

@@ -25,7 +26,6 @@ protected function main(Options $options)
2526
parent::main($options);
2627

2728
switch ($options->getCmd()) {
28-
2929
case 'update':
3030
$this->updateModelData();
3131
break;
@@ -37,7 +37,7 @@ protected function main(Options $options)
3737
protected function updateModelData()
3838
{
3939

40-
$http = new \dokuwiki\HTTP\DokuHTTPClient();
40+
$http = new DokuHTTPClient();
4141
$url = 'https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json';
4242
$response = $http->get($url);
4343
if ($response === false) {
@@ -84,7 +84,7 @@ protected function updateModelData()
8484
if (!isset($ourProviders[$data['litellm_provider']])) continue;
8585
if (!in_array($data['mode'], ['chat', 'embedding'])) continue;
8686
$provider = $data['litellm_provider'];
87-
$model = explode('/', $model);
87+
$model = explode('/', (string) $model);
8888
$model = array_pop($model);
8989

9090
if (isset($ourProviders[$provider]['skip']) && preg_match($ourProviders[$provider]['skip'], $model)) {
@@ -103,13 +103,11 @@ protected function updateModelData()
103103
if ($data['mode'] === 'chat') {
104104
$newmodel['outputTokens'] = $data['max_output_tokens'];
105105
$newmodel['outputTokenPrice'] = round($data['output_cost_per_token'] * 1_000_000, 2);
106+
} elseif (isset($oldmodel['dimensions'])) {
107+
$newmodel['dimensions'] = $oldmodel['dimensions'];
106108
} else {
107-
if (isset($oldmodel['dimensions'])) {
108-
$newmodel['dimensions'] = $oldmodel['dimensions'];
109-
} else {
110-
$this->warning('No dimensions for ' . $provider . ' ' . $model . '. Check manually!');
111-
$newmodel['dimensions'] = 1536;
112-
}
109+
$this->warning('No dimensions for ' . $provider . ' ' . $model . '. Check manually!');
110+
$newmodel['dimensions'] = 1536;
113111
}
114112
$ourProviders[$provider]['models'][$data['mode']][$model] = $newmodel;
115113
}

‎cli/simulate.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ protected function records2rows(array $result): array
159159
/**
160160
* Prefix each key in the given stats array to be merged with a larger array
161161
*
162-
* @param string $prefix
163-
* @param array $stats
164162
* @return array
165163
*/
166164
protected function flattenStats(string $prefix, array $stats)
@@ -173,7 +171,6 @@ protected function flattenStats(string $prefix, array $stats)
173171
}
174172

175173
/**
176-
* @param string $file
177174
* @return array
178175
* @throws Exception
179176
*/

‎helper.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function setLogger($logger)
5959
/**
6060
* Update the configuration
6161
*
62-
* @param array $config
6362
* @return void
6463
*/
6564
public function updateConfig(array $config)
@@ -387,7 +386,6 @@ public function getLanguageLimit()
387386
/**
388387
* Store info about the last run
389388
*
390-
* @param array $data
391389
* @return void
392390
*/
393391
public function setRunData(array $data)

0 commit comments

Comments
 (0)