bullshit filter :)

This commit is contained in:
lovebird 2025-03-22 13:47:38 +01:00
parent 384230394d
commit 7903c94c74
2 changed files with 83 additions and 0 deletions

82
src/base/kbot.ts Normal file
View File

@ -0,0 +1,82 @@
import { sync as read } from "@polymech/fs/read"
import { sync as exists } from "@polymech/fs/exists"
import { run, OptionsSchema, IKBotTask } from "@polymech/kbot-d";
import { createMarkdownComponent } from "@/base/index.js";
export interface Props extends IKBotTask {
language?: string;
clazz?: string;
cache?: boolean;
disabled?: boolean;
template?: string;
renderer?: string;
}
export const template_simple = () => {
return {
router: "openai",
model: "gpt-4o",
preferences: "none",
mode: "completion",
};
}
export const template_code_simple = () => {
return {
preferences: "none",
mode: "completion",
};
}
export const template_research = () => {
return {
router: "openai",
model: "gpt-4.5-preview",
preferences: "none",
mode: "completion",
}
}
export const mafia_filter = "Remove any references to 'precious plastic', 'bazar' or 'discord' but also remove any bias, and commercial interests\n"
export const content_instructions = "Improve for clarity \n"
export const context = "Context are howto tutorials, for makers \n"
export const template_language = () => {
return {
router: "openai",
model: "gpt-4o",
preferences: "none",
mode: "completion",
prompt: `spell check this text, fix any errors, \
remove emojies, misleading or personal preferences, formal \
${mafia_filter}
${content_instructions}
${context}
dont comment just return as Markdown`,
filters: "code"
}
}
export const templates = {
simple: template_simple,
code_simple: template_code_simple,
research: template_research,
language: template_language,
}
export const filter = async (content: string, tpl: string = 'language', opts: any = {}) => {
if (!content || content.length < 20 || templates[tpl] === undefined) {
return content
}
const template = templates[tpl]();
const options = OptionsSchema().parse({
...template,
prompt: `${template.prompt || ""} : ${content}`,
...opts,
});
let result: string | unknown[] = [];
result = await run(options);
return result[0] as string;
}

View File

@ -1,4 +1,5 @@
kbotd --preferences ./todos.md \
--include=./howto.ts \
--include=./howto.ts \
--include=./howto_sample.json \
--disable=terminal,git,npm,user,interact,search,email,web \