mirror of
https://github.com/hyeonseonam/auto-classifier.git
synced 2026-07-22 07:40:29 +00:00
refactor: Remove max_suggestions from template and apply globally in classification logic
This commit is contained in:
parent
aedda20210
commit
c1d7a78e5c
2 changed files with 11 additions and 7 deletions
17
src/main.ts
17
src/main.ts
|
|
@ -133,10 +133,6 @@ export default class AutoClassifierPlugin extends Plugin {
|
|||
let user_prompt = this.settings.commandOption.prmpt_template;
|
||||
user_prompt = user_prompt.replace("{{input}}", input);
|
||||
user_prompt = user_prompt.replace("{{reference}}", refs.join(","));
|
||||
user_prompt = user_prompt.replace(
|
||||
"{{max_suggestions}}",
|
||||
String(this.settings.commandOption.max_suggestions),
|
||||
);
|
||||
|
||||
const system_role = this.settings.commandOption.prmpt_template;
|
||||
|
||||
|
|
@ -166,6 +162,15 @@ export default class AutoClassifierPlugin extends Plugin {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Limit number of suggestions
|
||||
const limitedOutputs = resOutputs.slice(0, this.settings.commandOption.max_suggestions);
|
||||
|
||||
// Validate output format
|
||||
if (!Array.isArray(limitedOutputs)) {
|
||||
new Notice(`⛔ ${this.manifest.name}: output format error (expected array)`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Avoid low reliability
|
||||
if (resReliability <= 0.2) {
|
||||
new Notice(
|
||||
|
|
@ -175,7 +180,7 @@ export default class AutoClassifierPlugin extends Plugin {
|
|||
}
|
||||
|
||||
// ------- [Add Tags] -------
|
||||
for (const resOutput of resOutputs) {
|
||||
for (const resOutput of limitedOutputs) {
|
||||
// Output Type 1. [Tag Case] + Output Type 2. [Wikilink Case]
|
||||
if (
|
||||
commandOption.outType == OutType.Tag ||
|
||||
|
|
@ -218,7 +223,7 @@ export default class AutoClassifierPlugin extends Plugin {
|
|||
);
|
||||
}
|
||||
}
|
||||
new Notice(`✅ ${this.manifest.name}: classified with ${resOutputs.length} tags`);
|
||||
new Notice(`✅ ${this.manifest.name}: classified with ${limitedOutputs.length} tags`);
|
||||
} catch (error) {
|
||||
new Notice(`⛔ ${this.manifest.name}: JSON parsing error - ${error}`);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ export const DEFAULT_PROMPT_TEMPLATE = `Classify this content:
|
|||
{{input}}
|
||||
"""
|
||||
Answer format is JSON {reliability:0~1, outputs:[tag1,tag2,...]}.
|
||||
Suggest up to {{max_suggestions}} most relevant tags.
|
||||
Even if you are not sure, qualify the reliability and select the best matches.
|
||||
Output tags must be from these options:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue