kbot addons : von nuescht wuerd nuescht :)

This commit is contained in:
lovebird 2025-03-24 21:18:11 +01:00
parent ec082dc6ab
commit 167948de72
6 changed files with 43 additions and 5 deletions

View File

@ -3,7 +3,7 @@
"messages": [
{
"role": "user",
"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\nConvert units, from metric to imperial and vice versa (in braces)\ndont comment just return as Markdown : Here you will find the 3D model and blueprints to create the wall peg mold!"
"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\nConvert units, from metric to imperial and vice versa (in braces)\ndont comment just return as Markdown : # Resources\n\n ### Skills Developed or Improved\n\n- **Recycling and Waste Management**: Understanding the process of collecting, sorting, and processing marine litter and fishing nets for reuse.\n \n- **Material Science and Engineering**: Learning about the properties of polypropylene and how to combine it with recycled materials for optimal texture and color.\n\n- **Manufacturing Process Operation**: Gaining hands-on experience with industrial equipment such as an industrial dryer and modified sheetpress for board production.\n\n- **Prototyping and Product Design**: Developing the ability to design and produce functional and decorative products from recycled materials.\n\n- **Project Management**: Collaborating with different entities (Vertidos Cero Association and AIMPLAS) and managing resources efficiently to support a circular economy initiative."
},
{
"role": "user",

View File

@ -82,10 +82,11 @@ export const extract_learned_skills = () => {
model: "gpt-4o",
preferences: "none",
mode: "completion",
prompt: "Analyze the following tutorial and identify all the skills that a person would learn or improve by completing this project. Return as JSON with this structure:\n\n{\n \"gainedSkills\": [\n {\n \"name\": \"Skill name\",\n \"category\": \"Technical, Design, Manual, etc.\",\n \"description\": \"Brief description of how this skill is developed\"\n }\n ],\n \"learningOutcomes\": [\n \"Broader outcomes or knowledge gained from completing the project\"\n ],\n \"possibleExtensions\": [\n \"How this project could be extended to learn more advanced skills\"\n ]\n}\n\nReturn only the JSON. No introductions or explanations.",
prompt: "Analyze the following tutorial and identify all the skills that a person would learn or improve by completing this project. No introductions or explanations. Return as Markdown chapter with a bullet list, max. 5.",
filters: "code"
};
}
export const templates = {
simple: template_simple,
code_simple: template_code_simple,
@ -97,6 +98,7 @@ export const templates = {
required_skills: extract_required_skills,
learned_skills: extract_learned_skills
}
/**
*
* @param content : content to filter

View File

@ -15,13 +15,15 @@ import { sync as read } from "@polymech/fs/read";
import { createHTMLComponent, createMarkdownComponent } from "@/base/index.js";
import { translate } from "@/base/i18n.js";
import { applyFilters, shortenUrl } from "@/model/howto.js";
import { extract, references } from "@/base/kbot.js";
import { extract, extract_learned_skills, references } from "@/base/kbot.js";
import {
HOWTO_FILES_WEB,
HOWTO_FILES_ABS,
I18N_SOURCE_LANGUAGE,
HOWTO_COMPLETE_RESOURCES,
HOWTO_COMPLETE_SKILLS
} from "config/config.js";
import { filter } from "@/base/kbot.js";
interface Props {
howto: IHowto;
@ -80,13 +82,22 @@ let howto_resources = exists(howto_resources_path)
? read(howto_resources_path, "string") || howto_resources_default
: howto_resources_default;
const contentAll = `${howto.title} \n Description : ${howto.description} \n Steps: ${howto.steps.map((s) => s.text).join("\n")} \n`;
if (HOWTO_COMPLETE_RESOURCES) {
const contentAll = `${howto.title} \n Description : ${howto.description} \n Steps: ${howto.steps.map((s) => s.text).join("\n")} \n`;
const keywords = (await extract(contentAll)) as string;
const references_extra = await references(keywords);
howto_resources = `${howto_resources}\n${references_extra}`;
}
if (HOWTO_COMPLETE_SKILLS) {
const references_extra = await filter(contentAll,'learned_skills')
howto_resources = `${howto_resources}\n\n ${references_extra}`
}
const Resources = component(howto_resources);
---
<BaseLayout class="markdown-content bg-gray-100">

View File

@ -26,6 +26,7 @@ export const HOWTO_FILTER_LLM = true
export const HOWTO_ANNOTATIONS = true
export const HOWTO_ANNOTATIONS_CACHE = true
export const HOWTO_COMPLETE_RESOURCES = false
export const HOWTO_COMPLETE_SKILLS = true
export const HOWTO_MIGRATION = () => path.resolve(resolve("./data/last.json"))
export const HOWTO_ROOT_INTERN = () => path.resolve(resolve("./public/resources/howtos"))

View File

@ -0,0 +1,10 @@
import { got } from 'got'
import { createWriteStream } from 'fs';
export const download = async (url, outputPath) => {
const stream = createWriteStream(outputPath);
got.stream(url).pipe(stream);
return new Promise((resolve, reject) => {
stream.on('finish', () => resolve(`File downloaded: ${outputPath}`));
stream.on('error', reject);
});
}

View File

@ -16,6 +16,9 @@ export * from './filters.js'
import { filter as language } from "@/base/kbot.js";
import { IHowto, IImage, ITag, ITEM_TYPE } from './howto-model.js';
import type { IAnnotation } from "./annotation.js"
import { AnnotationMode, generateCacheKey, cacheAnnotation, getCachedAnnotation } from './annotation.js';
import { blacklist } from './filters.js'
import { download } from './download.js'
import {
@ -26,7 +29,8 @@ import {
default_image,
HOWTO_ROOT,
HOWTO_GLOB,
HOWTO_MIGRATION
HOWTO_MIGRATION,
HOWTO_ANNOTATIONS
} from "config/config.js";
import { logger } from '@/base/index.js'
@ -145,6 +149,15 @@ export const defaults = async (data: any, cwd: string, root: string) => {
return data;
}
const complete = async (item: IHowto) =>
{
if(!HOWTO_ANNOTATIONS){
return item
}
return item
}
const onStoreItem = async (store: any, ctx: LoaderContext) => {
const item = store.data.item as IHowto
item.steps = item.steps || []
@ -165,6 +178,7 @@ const onStoreItem = async (store: any, ctx: LoaderContext) => {
step.images = step.images.filter((image) => asset_local_abs(item, image))
})
item.files = await downloadFiles(item.slug, item)
await complete(item)
return item
}