Skip to content

Commit 441edf8

Browse files
committed
fixed overlong lines
1 parent b4b6ea0 commit 441edf8

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

Chunk.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ class Chunk implements \JsonSerializable, \Stringable
1717
* @param int $created
1818
* @param int $score
1919
*/
20-
public function __construct(protected $page, protected $id, protected $text, protected $embedding, $lang = '', $created = '', protected $score = 0)
20+
public function __construct(
21+
protected $page,
22+
protected $id,
23+
protected $text,
24+
protected $embedding,
25+
$lang = '',
26+
$created = '',
27+
protected $score = 0
28+
)
2129
{
2230
$this->language = $lang ?: $this->determineLanguage();
2331
$this->created = $created ?: time();

Storage/SQLiteStorage.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ public function statistics()
199199
*/
200200
public function sqliteCosineSimilarityCallback($query, $embedding)
201201
{
202-
return (float)$this->cosineSimilarity(json_decode($query, null, 512, JSON_THROW_ON_ERROR), json_decode($embedding, null, 512, JSON_THROW_ON_ERROR));
202+
return (float)$this->cosineSimilarity(
203+
json_decode($query, true, 512, JSON_THROW_ON_ERROR),
204+
json_decode($embedding, true, 512, JSON_THROW_ON_ERROR)
205+
);
203206
}
204207

205208
/**

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"require": {
3+
"php": ">=8.0",
34
"vanderlee/php-sentence": "^1.0",
45
"mehrab-wj/tiktoken-php": "^1.0",
56
"erusev/parsedown": "^1.7",

helper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ public function askQuestion($question, $previous = [])
162162
{
163163
$similar = $this->getEmbeddings()->getSimilarChunks($question, $this->getLanguageLimit());
164164
if ($similar) {
165-
$context = implode("\n", array_map(static fn(Chunk $chunk) => "\n```\n" . $chunk->getText() . "\n```\n", $similar));
165+
$context = implode(
166+
"\n",
167+
array_map(static fn(Chunk $chunk) => "\n```\n" . $chunk->getText() . "\n```\n", $similar)
168+
);
166169
$prompt = $this->getPrompt('question', [
167170
'context' => $context,
168171
'language' => $this->getLanguagePrompt()

0 commit comments

Comments
 (0)