From b4aee2e66226c0c0b98ca903f4ffe9646be20cd1 Mon Sep 17 00:00:00 2001 From: Alexandros Sigalas Date: Sun, 24 May 2026 08:19:23 +0300 Subject: [PATCH] Fix running fulltext and rag in parallel from async --- src/Embedding.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Embedding.php b/src/Embedding.php index f3ee5b9..9cb5be8 100644 --- a/src/Embedding.php +++ b/src/Embedding.php @@ -539,33 +539,32 @@ public function embed(?array $hook_data=null) // fulltext index or RAG/embeddings if ($fulltext) { - $extra = $extra ? array_values(array_filter(array_map('trim', $extra), static function ($v) { + $extra_ft = $extra ? array_values(array_filter(array_map('trim', $extra), static function ($v) { return $v && strlen((string)$v) > 3; })) : null; - if (!$extra || count($extra) <= 1) + if (!$extra_ft || count($extra_ft) <= 1) { - $extra = $extra ? $extra[0] : null; + $extra_ft = $extra_ft ? $extra_ft[0] : null; } else { - $extra = json_encode($extra, + $extra_ft = json_encode($extra_ft, JSON_UNESCAPED_SLASHES | JSON_INVALID_UTF8_IGNORE | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_LINE_TERMINATORS); } $this->db->insert(self::FULLTEXT_TABLE, [ self::FULLTEXT_TITLE => $title ?: null, self::FULLTEXT_DESCRIPTION => $description ?: null, - self::FULLTEXT_EXTRA => $extra, + self::FULLTEXT_EXTRA => $extra_ft, self::FULLTEXT_MODIFIED => $modified, ], [ self::FULLTEXT_APP => $app, self::FULLTEXT_APP_ID => $id, ], __LINE__, __FILE__, self::APP); - continue; + //continue; } if (self::$minimize_chunks) { - $chunks = self::chunkSplit($title . "\n" . $description . - ($extra ? "\n" . implode("\n", $extra) : "")); + $chunks = self::chunkSplit($title . "\n" . $description.($extra ? "\n" . implode("\n", $extra) : "")); } else {