kbot templates

This commit is contained in:
lovebird 2025-04-01 19:30:55 +02:00
parent 1833ce2c2e
commit 7f00b301c2
7 changed files with 14 additions and 15 deletions

View File

@ -23,7 +23,7 @@
"format": "unix-time"
}
],
"default": "2025-04-01T16:27:18.441Z"
"default": "2025-04-01T17:24:12.665Z"
},
"description": {
"type": "string",

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
"messages": [
{
"role": "user",
"content": "Return a list of max. 10 keywords that can be used for SEO purposes, separated by commas (dont comment, just the list) : \n\nText to process:\nThis guide outlines the process for cutting HDPE sheets using an X-Carve CNC machine.\n\nFor a detailed demonstration, watch the video with subtitles: [Watch Video](https://www.youtube.com/watch?v=4LrrFz802To)\n\n\nUser Location: Mexico City, Mexico\n\nFor this step, measure the plastic sheet's height, width, and thickness. The X-Carve machine uses the CAM software Easel, which is very user-friendly for CNC milling. Easel allows you to simulate your material and includes HDPE 2-Colors in its material options.\n\nUsing clamps, secure the sheet to the table.\n\nOpen a vector design program like Inkscape to create or download a vector file from a suitable online resource.\n\nDownload the SVG file and import it into Easel.\n\nWith the file ready, select the desired width for carving or cutting. Follow these steps to begin:\n\n- Ensure the sheet is secured.\n- Specify the cutting tool, using a 1/8 inch (3.175 mm) flat flute bit.\n- Set the machine's origin point to the bottom left corner.\n- Raise the bit and activate the CNC Router.\n\nAnd then the process starts!\n\nTake your glasses or object, post-process them, and show the results to friends and family.\n\nYou can attempt this project with various CNC machines, including manual routers or saws, as demonstrated in this video: [YouTube Link](https://youtu.be/gxkcffQD3eQ). Sharing your work supports community growth.\n\nPlease share your ideas and comments."
"content": "Create a concise description for SEO meta (around 150-160 characters) from the text below. \n Disregard any links or image references. \n Return only the final meta description, no extra commentary.\n\nText to process:\nThis tutorial demonstrates the process of cutting HDPE sheets using an X-Carve CNC.\n\nFor a complete video in Spanish with subtitles, visit: [YouTube Video](https://www.youtube.com/watch?v=4LrrFz802To)\n\n\nUser Location: Mexico City, Mexico\n\nTo proceed, measure your plastic sheet: height, width, and thickness. Our X-Carve machine operates with the CAM software Easel, which I find to be user-friendly for CNC milling.\n\nEasel allows you to simulate the material, and it includes HDPE in its cutting material list.\n\n## Instructions for Securing a Sheet with CNC Clamps\n\nTo secure the sheet to the table, use the CNC clamps from the X-Carve.\n\nOpen a vector design program like Inkscape to create or download a vector file from [The Noun Project](https://thenounproject.com).\n\nDownload the SVG file and import it into Easel.\n\nWith the file ready, select the desired cutting width and proceed to cut using the wizard:\n- Ensure the sheet is secured.\n- Specify the cutting bit; a 1/8 inch (3.175 mm) flat flute bit is used.\n- Set the machine's 0-0 coordinate, typically the lower left corner.\n- Raise the bit, and start the CNC Router.\n\n### Tutorial Step: Showcasing Your Finished Object\n\nNow, finish post-processing your glasses or object, and share it with others.\n\nYou can attempt this project using various CNC machines, including manual routers or saws, as demonstrated in this [video](https://youtu.be/gxkcffQD3eQ). Sharing your work contributes to community development.\n\nShare your ideas and comments."
},
{
"role": "user",

View File

@ -3,8 +3,9 @@ import { sync as read } from "@polymech/fs/read";
import { sync as exists } from "@polymech/fs/exists";
import { z } from "zod";
import { logger } from "./index.js";
import { resolveVariables } from "@polymech/commons/variables"
import { OptionsSchema } from "@polymech/kbot-d"
// Type definitions
const InstructionSchema = z.object({
flag: z.string(),
text: z.string()
@ -21,7 +22,6 @@ export interface TemplateProps extends IKBotTask {
renderer?: string;
}
const TemplateConfigSchema = z.object({
router: z.string().optional(),
_router: z.string().optional(),
@ -33,15 +33,12 @@ const TemplateConfigSchema = z.object({
});
type TemplateConfig = z.infer<typeof TemplateConfigSchema>;
const LLMConfigSchema = z.object({
options: z.record(TemplateConfigSchema),
options: z.record(OptionsSchema()),
instructions: InstructionSetSchema.optional(),
defaults: z.record(z.array(z.string())).optional()
});
type LLMConfig = z.infer<typeof LLMConfigSchema>;
export const enum TemplateContext {
COMMONS = 'commons',
HOWTO = 'howto',
@ -111,7 +108,7 @@ const createTemplate = (config: LLMConfig, name: string, defaults: Partial<Templ
const merged = {
...template,
...opts,
prompt
prompt: template.prompt || prompt
};
return merged
}

View File

@ -25,6 +25,9 @@ export const filter = async (content: string, tpl: string = 'howto', opts: Props
if (!templates[tpl]) {
return content;
}
if(context==='howto'){
//debugger
}
const template = typeof templates[tpl] === 'function' ? templates[tpl]() : templates[tpl];
const options = getFilterOptions(content, template, opts);
const cache_key_obj = {
@ -45,7 +48,7 @@ export const filter = async (content: string, tpl: string = 'howto', opts: Props
if (cached && LLM_CACHE) {
return cached;
}
logger.info(`kbot: template:${tpl} : context:${context} @ ${options.model} : ${content.substring(0, 20)}`)
logger.info(`kbot: template:${tpl} : context:${context} @ ${options.model}`)
const result = await run(options);
if (!result || !result[0]) {
logger.error(`No result for ${content.substring(0, 20)}`)
@ -62,7 +65,7 @@ export const filter = async (content: string, tpl: string = 'howto', opts: Props
}
}
await set_cached_object({ ca_options }, 'kbot', result[0], {});
logger.debug(`caching result for "${content.substring(0, 20)}..."`)
logger.info(`kbot-result: template:${tpl} : context:${context} @ ${options.model} : ${result[0]}`)
return result[0] as string;
};
export const template_filter = async (text: string, template: string, context: TemplateContext = TemplateContext.COMMONS) => {

View File

@ -6,7 +6,7 @@ import { sanitizeUri } from 'micromark-util-sanitize-uri'
// LLM
export const LLM_CACHE = false
export const LLM_CACHE = true
export const OSR_ROOT = () => path.resolve(resolve("${OSR_ROOT}"))

View File

@ -25,8 +25,7 @@
"model": "perplexity/sonar-deep-research",
"preferences": "none",
"mode": "completion",
"prompt": "Extract the required tools: software, hardware from the following tutorial.Return as Markdown chapters (H3) with very short bullet points (not bold), max. 5 per category.",
"filters": "code"
"prompt": "Extract the required tools: software, hardware from the following tutorial. Return as Markdown chapters (H3) with very short bullet points (not bold), max. 5 per category ."
},
"requiredSkills": {
"router": "openai",