Skip to content

Commit

Permalink
🤖 Automatic code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain authored and github-actions[bot] committed May 16, 2024
1 parent f31e961 commit 337fd95
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 25 deletions.
3 changes: 0 additions & 3 deletions Embeddings.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ class Embeddings
/**
* Embeddings constructor.
*
* @param ChatInterface $chatModel
* @param EmbeddingInterface $embedModel
* @param AbstractStorage $storage
* @param array $config The plugin configuration
*/
public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions Model/AbstractModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract class AbstractModel implements ModelInterface
protected $requestStart = 0;

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

/** @var DokuHTTPClient */
protected $http;
Expand Down Expand Up @@ -194,7 +194,7 @@ public function setDebug($debug = true)
* @return mixed
* @throws \Exception when the response indicates an error
*/
abstract protected function parseAPIResponse($response);
abstract protected function parseAPIResponse(mixed $response);

/**
* Send a request to the API
Expand Down
2 changes: 1 addition & 1 deletion Model/Groq/ChatModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(string $name, array $config)
throw new \Exception('Groq API key not configured');
}

$this->http->headers['Authorization'] = 'Bearer '.$config['groq_apikey'];
$this->http->headers['Authorization'] = 'Bearer ' . $config['groq_apikey'];
}

/** @inheritdoc */
Expand Down
1 change: 0 additions & 1 deletion Model/Ollama/AbstractOllama.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ protected function parseAPIResponse($response)

return $response;
}

}
4 changes: 2 additions & 2 deletions Model/Reka/ChatModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ protected function request($endpoint, $data)
/** @inheritdoc */
protected function parseAPIResponse($response)
{
if(((int) $this->http->status) !== 200) {
if(isset($response['detail'])) {
if (((int) $this->http->status) !== 200) {
if (isset($response['detail'])) {
throw new \Exception('Reka API error: ' . $response['detail']);
} else {
throw new \Exception('Reka API error: ' . $this->http->status . ' ' . $this->http->error);
Expand Down
10 changes: 2 additions & 8 deletions ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

class ModelFactory
{
/** @var array The plugin configuration */
protected array $config;

public $chatModel;
public $rephraseModel;
public $embeddingModel;
Expand All @@ -19,9 +16,8 @@ class ModelFactory
/**
* @param array $config The plugin configuration
*/
public function __construct(array $config)
public function __construct(protected array $config)
{
$this->config = $config;
}

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

/**
* Set the debug flag for all models
*
* @param bool $debug
*/
public function setDebug(bool $debug = true)
{
Expand Down Expand Up @@ -122,7 +116,7 @@ public function getModels($availableOnly = false, $typeOnly = '')
try {
$info['instance'] = $this->loadModel($type, "$namespace $name");
$info['instance']->setDebug($this->debug);
} catch (\Exception $e) {
} catch (\Exception) {
if ($availableOnly) continue;
$info['instance'] = false;
}
Expand Down
2 changes: 1 addition & 1 deletion Storage/PineconeStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function deletePageChunks($page, $firstChunkID)
$this->runQuery('/vectors/delete', ['ids' => $ids]);
} catch (\Exception $e) {
// 5 is the code for "namespace not found" See #12
if($e->getCode() !== 5) throw $e;
if ($e->getCode() !== 5) throw $e;
}
}

Expand Down
4 changes: 2 additions & 2 deletions cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ protected function createEmbeddings($clear)
$data = $this->helper->getRunData();
$lastEmbedModel = $data['embed used'] ?? '';

if(
if (
!$clear && $lastEmbedModel &&
$lastEmbedModel != (string) $this->helper->getEmbeddingModel()
){
) {
$this->warning('Embedding model has changed since last run. Forcing an index rebuild');
$clear = true;
}
Expand Down
3 changes: 0 additions & 3 deletions cli/simulate.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ protected function records2rows(array $result): array
/**
* Prefix each key in the given stats array to be merged with a larger array
*
* @param string $prefix
* @param array $stats
* @return array
*/
protected function flattenStats(string $prefix, array $stats)
Expand All @@ -173,7 +171,6 @@ protected function flattenStats(string $prefix, array $stats)
}

/**
* @param string $file
* @return array
* @throws Exception
*/
Expand Down
2 changes: 0 additions & 2 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public function setLogger($logger)
/**
* Update the configuration
*
* @param array $config
* @return void
*/
public function updateConfig(array $config)
Expand Down Expand Up @@ -387,7 +386,6 @@ public function getLanguageLimit()
/**
* Store info about the last run
*
* @param array $data
* @return void
*/
public function setRunData(array $data)
Expand Down

0 comments on commit 337fd95

Please sign in to comment.