mirror of
https://github.com/FreshRSS/Extensions.git
synced 2026-11-04 10:48:40 +00:00
[LLM Classification] Do not HTML-encode re-used tags again (#573)
* [LLM Classification] Do not HTML-encode re-used tags again The tags of an entry are stored HTML-encoded: `applyClassification()` encodes the tags returned by the LLM with `htmlspecialchars()`, like SimplePie does for the categories of the feeds. When an already classified entry is updated without any change to its prompt, the extension re-uses the stored tags instead of calling the LLM again, but passed them as-is to `applyClassification()`, which encoded them a second time. So a tag such as `R&D` became `R&D` in the database after classification, then `R&D` after the next such update, and so on. When a list of allowed tags is configured, the encoded tags did not match the list anymore (`R&D` is not `R&D`), and were silently removed from the entry. Decode the stored tags before re-using them, so that they go through the same encoding and allow-list check as the tags returned by the LLM. Decoding first also lets tags match a configured prefix containing such characters. Bump the extension version to 0.3.2. * [LLM Classification] Decode single quotes in re-used tags too
This commit is contained in:
1 parent
ecd1c55ab9
commit
73fb62c120
2 files changed
+6
-2
No files matched your search
@@ -439,7 +439,11 @@ final class LlmClassificationExtension extends Minz_Extension {
|
||||
if ($existingPromptHash === $incomingPromptHash) {
|
||||
// Re-use existing tags matching the prefix
|
||||
$prefix = $this->getUserConfigurationString('tag_prefix') ?? '';
|
||||
$existingTags = $existingEntry->tags();
|
||||
// Decode the stored tags before re-adding them (will be HTML-encoded again in applyClassification)
|
||||
$existingTags = array_map(
|
||||
static fn(string $tag) => htmlspecialchars_decode($tag, ENT_QUOTES),
|
||||
$existingEntry->tags()
|
||||
);
|
||||
if ($prefix !== '') {
|
||||
$existingTags = array_values(array_filter(
|
||||
$existingTags,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "LLM Classification",
|
||||
"author": "Alkarex",
|
||||
"description": "Tag incoming articles by calling an OpenAI-compatible LLM API",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"entrypoint": "LlmClassification",
|
||||
"type": "user",
|
||||
"compatibility": "1.28.2"
|
||||
|
||||
Reference in new issue
Block a user