deprogramming with kbot :)

This commit is contained in:
lovebird 2025-03-22 21:30:54 +01:00
parent 5eb222707e
commit 1ff05fb434
14 changed files with 120 additions and 61 deletions

View File

@ -23,7 +23,7 @@
"format": "unix-time"
}
],
"default": "2025-03-22T17:14:37.325Z"
"default": "2025-03-22T20:18:34.313Z"
},
"description": {
"type": "string",

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,9 @@
{
"model": "gpt-4o",
"model": "openai/o3-mini-high",
"messages": [
{
"role": "user",
"content": "spell check this text, fix any errors, remove emojies, misleading or personal preferences, formal Remove any references to 'precious plastic', 'bazar' or 'discord' but also remove any bias, and commercial interests\n\n Improve for clarity \n\n Context: howto tutorials, for makers \n\n dont comment just return as Markdown : This How-To will show you the way to convert your three phase single direction shredder into a new single phase-reverse function shredder. Which means that you would be able to plug it in anyplace you go. This is quite usefull if you like to go around with your shredder or if your workspace has only single-phase electricity.\n\nThe reverse function is quite cool when your shredder gets jammed.\n\n"
"content": "use a formal tone\nspell check the text, fix any errors\nremove emojis\nremove personal preferences or biases\nshorten text if possible but preserve personality\nremove references to preciousplastic, bazar and Discord\nremove any brain/green washing as well suggestions not related to the craft\nContext: howto tutorials, for makers\ndont comment just return as Markdown : This how-to contains information on how we built a low-cost, automated injection molding machine. Unfortunately the folder is way to big for uploading it here. \n\nWe added a link to our dropbox, where you can download the folder :)"
},
{
"role": "user",

View File

@ -36,23 +36,99 @@ export const template_research = () => {
mode: "completion",
}
}
export enum ToneFlags {
None = 0,
Formal = 1,
Friendly = 2
}
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: howto tutorials, for makers \n"
export enum ContentFlags {
None = 0,
SpellCheck = 1,
RemoveEmojis = 2,
RemovePersonalPrefs = 4,
Redunance = 8,
Shorten = 16
}
export const template_language = () => {
export enum ModerationFlags {
None = 0,
MafiaFilter = 1,
Deprogramming = 2
}
export enum ContextFlags {
None = 0,
MakerTutorials = 1
}
export enum FormatFlags {
None = 0,
Markdown = 1
}
const TONE_INSTRUCTIONS = [
{ mask: ToneFlags.Formal, text: "use a formal tone" },
{ mask: ToneFlags.Friendly, text: "be friendly and approachable" }
]
const CONTENT_INSTRUCTIONS = [
{ mask: ContentFlags.SpellCheck, text: "spell check the text, fix any errors" },
{ mask: ContentFlags.RemoveEmojis, text: "remove emojis" },
{ mask: ContentFlags.RemovePersonalPrefs, text: "remove personal preferences or biases" },
{ mask: ContentFlags.Redunance, text: "remove redunance, eg : we attached the files, ... " },
{ mask: ContentFlags.Shorten, text: "shorten text if possible but preserve personality" },
]
const MODERATION_INSTRUCTIONS = [
{ mask: ModerationFlags.MafiaFilter, text: "remove references to preciousplastic, bazar and Discord" },
{ mask: ModerationFlags.Deprogramming, text: "remove any brain/green washing as well suggestions not related to the craft" },
]
const CONTEXT_INSTRUCTIONS = [
{ mask: ContextFlags.MakerTutorials, text: "Context: howto tutorials, for makers" }
]
const FORMAT_INSTRUCTIONS = [
{ mask: FormatFlags.Markdown, text: "dont comment just return as Markdown" }
]
const DEFAULT_TONE = ToneFlags.Formal
const DEFAULT_CONTENT = ContentFlags.SpellCheck |
ContentFlags.RemoveEmojis |
ContentFlags.RemovePersonalPrefs |
ContentFlags.Shorten
const DEFAULT_MODERATION = ModerationFlags.MafiaFilter | ModerationFlags.Deprogramming
const DEFAULT_CONTEXT = ContextFlags.MakerTutorials
const DEFAULT_FORMAT = FormatFlags.Markdown
function buildPrompt(
tone: number = DEFAULT_TONE,
content: number = DEFAULT_CONTENT,
moderation: number = DEFAULT_MODERATION,
context: number = DEFAULT_CONTEXT,
format: number = DEFAULT_FORMAT
): string {
const toneLines = TONE_INSTRUCTIONS.filter(x => (tone & x.mask) === x.mask).map(x => x.text)
const contentLines = CONTENT_INSTRUCTIONS.filter(x => (content & x.mask) === x.mask).map(x => x.text)
const moderationLines = MODERATION_INSTRUCTIONS.filter(x => (moderation & x.mask) === x.mask).map(x => x.text)
const contextLines = CONTEXT_INSTRUCTIONS.filter(x => (context & x.mask) === x.mask).map(x => x.text)
const formatLines = FORMAT_INSTRUCTIONS.filter(x => (format & x.mask) === x.mask).map(x => x.text)
return [...toneLines, ...contentLines, ...moderationLines, ...contextLines, ...formatLines].join("\n")
}
export function templateLanguage(
tone: number = DEFAULT_TONE,
content: number = DEFAULT_CONTENT,
moderation: number = DEFAULT_MODERATION,
ctx: number = DEFAULT_CONTEXT,
format: number = DEFAULT_FORMAT
) {
const prompt = buildPrompt(tone, content, moderation, ctx, format)
return {
router: "openai",
model: "gpt-4o",
_router: "openai",
model: "openai/o3-mini-high",
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`,
prompt,
filters: "code"
}
}
@ -61,10 +137,10 @@ export const templates = {
simple: template_simple,
code_simple: template_code_simple,
research: template_research,
language: template_language,
howto: templateLanguage,
}
export const filter = async (content: string, tpl: string = 'language', opts: any = {}) => {
export const filter = async (content: string, tpl: string = 'howto', opts: any = {}) => {
if (!content || content.length < 20 || templates[tpl] === undefined) {
return content
}

View File

@ -19,6 +19,7 @@ import {
HOWTO_FILES_ABS,
I18N_SOURCE_LANGUAGE,
} from "config/config.js";
interface Props {
howto: IHowto;
}
@ -159,30 +160,6 @@ const authorLinks = (howto?.user?.data.urls || []).filter(
>
<Translate>Browse Files</Translate>
</a>
<!-- Resources -->
{
howto.files.length > 0 && (
<div class="p-8 mb-8">
<h2 class="text-xl font-semibold mb-2">
<Translate>Resources</Translate>
</h2>
<ul class="list-disc list-inside">
{howto.files.map((file) => (
<li>
<a
href={`${file.downloadUrl}`}
target="_blank"
rel="noopener noreferrer"
class="text-orange-700 hover:underline break-words"
>
{file.name}
</a>
</li>
))}
</ul>
</div>
)
}
</section>
<section class="border-t border-gray-200 bg-gray-50 p-8">
<h2 class="text-2xl font-bold text-gray-800 mb-6">

View File

@ -22,7 +22,7 @@ export const I18N_ASSET_PATH = "${SRC_DIR}/${SRC_NAME}-${DST_LANG}${SRC_EXT}"
export const HOWTO_GLOB = '**/config.json'
export const FILES_WEB = 'https://files.polymech.io/files/machines/howtos/'
export const HOWTO_FILTER_LLM = false
export const HOWTO_FILTER_LLM = true
export const HOWTO_ROOT = () => path.resolve(resolve("./public/resources/howtos"))
export const HOWTO_FILES_ABS = (id) => `${HOWTO_ROOT()}/${id}`
export const HOWTO_FILES_WEB = (id: string) => `${FILES_WEB}/${id}`

View File

@ -11,7 +11,7 @@ import { filter as language } from "@/base/kbot.js";
import {
HOWTO_FILES_WEB,
HOWTO_FILES_ABS,
HOWTO_FILTER_LLM,
HOWTO_FILTER_LLM,
} from "config/config.js";
import {
@ -49,7 +49,7 @@ export const ITEM_TYPE = 'howto'
//export const load = () => get(`${HOWTO_ROOT()}/${HOWTO_GLOB}`, HOWTO_ROOT(), ITEM_TYPE)
export const item_path = (item: any) => `${HOWTO_ROOT()}/${item.data.slug}`
const blacklist = ['precious-plastic', 'fair-enough', 'mad-plastic-labs', 'the-flipflopi', 'easymoulds','plasticpreneur'];
const blacklist = ['precious-plastic', 'fair-enough', 'mad-plastic-labs', 'the-flipflopi', 'easymoulds', 'plasticpreneur', 'sustainable-design-studio'];
const download = async (url, outputPath) => {
const stream = createWriteStream(outputPath);
@ -84,7 +84,7 @@ export const howtos = async () => {
let howtos = data.v3_howtos as any[]
howtos = howtos.filter((h) => h.moderation == 'accepted');
const tags = data.v3_tags;
howtos.forEach((howto: IHowto) => {
const howtoTags: any = [];
for (const ht in howto.tags) {
@ -197,7 +197,7 @@ export function loader(): Loader {
////////////////////////////////
//
// Utils
const urlBlacklist = ["thenounproject.com","preciousplastic.com"];
const urlBlacklist = ["thenounproject.com", "preciousplastic.com"];
const bannedWords = ["wizard", "magic2"];
const wordReplaceMap: Record<string, string> = {
Router: "CNC Router",
@ -237,21 +237,21 @@ export const replaceWords = (text: string): string =>
acc.replace(new RegExp(`\\b${word}\\b`, "gi"), replacement),
text,
);
export const filters = [
renderLinks,
filterBannedPhrases,
replaceWords,
HOWTO_FILTER_LLM ? language : (text: string) => text,
];
renderLinks,
filterBannedPhrases,
replaceWords,
HOWTO_FILTER_LLM ? language : (text: string) => text,
];
export async function applyFilters(text: string): Promise<string> {
let filtered = text;
for (const filterFn of filters) {
filtered = await filterFn(filtered);
}
return filtered;
let filtered = text;
for (const filterFn of filters) {
filtered = await filterFn(filtered);
}
return filtered;
}
////////////////////////////////
//
// Interfaces - Old
@ -339,8 +339,7 @@ export interface IOATag {
_id: string
}
export interface User
{
export interface User {
_modified: string
_id: string
subType: string

1
tests/filteredText.html Normal file
View File

@ -0,0 +1 @@
You can try this project with other types of CNC machines, even manual Routers or manual saw, as I did on this video: <a class="text-orange-600 underline" href="https://youtu.be/gxkcffQD3eQ," target="_blank" rel="noopener noreferrer">https://youtu.be/gxkcffQD3eQ,</a> but the important thing is that you share what you do and help this community to grow!!!<br><br>Share your ideas and comments!

1
tests/filteredText0.html Normal file
View File

@ -0,0 +1 @@
For this step we need to measure our plastic sheet: Height, Width and Thickness. Our X-Carve machine works with the CAM Software <a href="<a class="text-orange-600 underline" href="https://easel.inventables.com/"" target="_blank" rel="noopener noreferrer">https://easel.inventables.com/"</a> target="_blank" class="underline text-orange-600">Easel</a>, for me, the easiest software for CNC milling out there. <br><br>The cool thing about <a href="<a class="text-orange-600 underline" href="https://easel.inventables.com/"" target="_blank" rel="noopener noreferrer">https://easel.inventables.com/"</a> target="_blank" class="underline text-orange-600">Easel</a> (<a class="text-orange-600 underline" href="https://<a" target="_blank" rel="noopener noreferrer">https://<a</a> href="<a class="text-orange-600 underline" href="https://easel.inventables.com/"" target="_blank" rel="noopener noreferrer">https://easel.inventables.com/"</a> target="_blank" class="underline text-orange-600">Easel</a>.inventables.com/) is that you can "simulate" your actual material and THEY EVEN HAVE HDPE 2-Colors in their cutting material lists!!<br><br><br>

1
tests/filteredText1.html Normal file
View File

@ -0,0 +1 @@
Using the CNC clamps from the X-Carve, secure the sheet to the table,

1
tests/filteredText2.html Normal file
View File

@ -0,0 +1 @@
Now we go to our illustrator, such as Inkscape to design a vector file or download and open source one frome [Link Removed]<br><br>We download the SVG file, which is an open source vector format and import it to <a href="<a class="text-orange-600 underline" href="https://easel.inventables.com/"" target="_blank" rel="noopener noreferrer">https://easel.inventables.com/"</a> target="_blank" class="underline text-orange-600">Easel</a>. <br>

1
tests/filteredText3.html Normal file
View File

@ -0,0 +1 @@
Now with the file we can choose the width we want to carve/cut and then we go to cut and start the wizzard:<br>- We check that the sheet is fixed.<br>- We also specify the cutting bit, we are using a 1/8 flat flute bit. <br>- We tell the machine where the coordinate 0-0 is, which we always choose as the down left corner.<br>- We raise the bit, turn on the CNC Router!!!<br><br>AND PUM THE [filtered] BEGINS!!

1
tests/filteredText4.html Normal file
View File

@ -0,0 +1 @@
You take now your glasses or object and postprocess them and of course show it to your friends, family and so on.<br><br><br>

1
tests/filteredText5.html Normal file
View File

@ -0,0 +1 @@
You can try this project with other types of CNC machines, even manual Routers or manual saw, as I did on this video: <a class="text-orange-600 underline" href="https://youtu.be/gxkcffQD3eQ," target="_blank" rel="noopener noreferrer">https://youtu.be/gxkcffQD3eQ,</a> but the important thing is that you share what you do and help this community to grow!!!<br><br>Share your ideas and comments!