From aa1d18e70db6051c7b630be14559b76f7dd0e90e Mon Sep 17 00:00:00 2001 From: babayaga Date: Wed, 26 Mar 2025 17:51:59 +0100 Subject: [PATCH] prompt templates : contexts --- src/base/kbot-contexts.ts | 30 +++++++++ src/config/templates/common.json | 65 ++++++++++++++++++++ src/config/templates/commons.json | 52 ++++++++++++++++ src/config/templates/directory.json | 62 +++++++++++++++++++ src/config/templates/howto.json | 87 +++++++++++++++++++++++++++ src/config/templates/marketplace.json | 28 +++++++++ 6 files changed, 324 insertions(+) create mode 100644 src/base/kbot-contexts.ts create mode 100644 src/config/templates/common.json create mode 100644 src/config/templates/commons.json create mode 100644 src/config/templates/directory.json create mode 100644 src/config/templates/howto.json create mode 100644 src/config/templates/marketplace.json diff --git a/src/base/kbot-contexts.ts b/src/base/kbot-contexts.ts new file mode 100644 index 0000000..7ad73a6 --- /dev/null +++ b/src/base/kbot-contexts.ts @@ -0,0 +1,30 @@ +export const enum TemplateContext { + COMMON = 'common', + HOWTO = 'howto', + DIRECTORY = 'directory', + MARKETPLACE = 'marketplace' +} + +export interface TemplateContextConfig { + path: string; + description: string; +} + +export const TEMPLATE_CONTEXTS: Record = { + [TemplateContext.COMMON]: { + path: './src/config/templates/common.json', + description: 'Common language and utility templates' + }, + [TemplateContext.HOWTO]: { + path: './src/config/templates/howto.json', + description: 'Tutorial and guide related templates' + }, + [TemplateContext.DIRECTORY]: { + path: './src/config/templates/directory.json', + description: 'Directory and listing related templates' + }, + [TemplateContext.MARKETPLACE]: { + path: './src/config/templates/marketplace.json', + description: 'Marketplace and commerce related templates' + } +}; \ No newline at end of file diff --git a/src/config/templates/common.json b/src/config/templates/common.json new file mode 100644 index 0000000..d8b6ac0 --- /dev/null +++ b/src/config/templates/common.json @@ -0,0 +1,65 @@ +{ + "templates": { + "simple": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "keywords": { + "router": "openai", + "model": "google/gemini-exp-1206:free", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "references": { + "router": "openai", + "model": "google/gemini-exp-1206:free", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "codeSimple": { + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "research": { + "router": "openai", + "model": "gpt-4.5-preview", + "mode": "completion", + "preferences": "none", + "filters": "code" + } + }, + "instructions": { + "tone": [ + { "flag": "formal", "text": "Use formal and professional language" }, + { "flag": "casual", "text": "Use casual and friendly language" }, + { "flag": "technical", "text": "Use technical and precise language" } + ], + "content": [ + { "flag": "spellCheck", "text": "Ensure proper spelling and grammar" }, + { "flag": "removeEmojis", "text": "Remove any emojis or informal symbols" }, + { "flag": "removePersonalPrefs", "text": "Remove personal preferences and subjective statements" }, + { "flag": "shorten", "text": "Keep responses concise and to the point" } + ], + "moderation": [ + { "flag": "mafiaFilter", "text": "Filter out inappropriate or harmful content" }, + { "flag": "deprogramming", "text": "Remove any manipulative or biased content" } + ], + "format": [ + { "flag": "markdown", "text": "Format response in Markdown" }, + { "flag": "plain", "text": "Use plain text formatting" } + ] + }, + "defaults": { + "tone": ["formal"], + "content": ["spellCheck", "removeEmojis", "removePersonalPrefs", "shorten"], + "moderation": ["mafiaFilter", "deprogramming"], + "format": ["markdown"] + } +} \ No newline at end of file diff --git a/src/config/templates/commons.json b/src/config/templates/commons.json new file mode 100644 index 0000000..c611f4e --- /dev/null +++ b/src/config/templates/commons.json @@ -0,0 +1,52 @@ +{ + "templates": { + "simple": { + "router": "openai", + "model": "gpt-4o", + "preferences": "none", + "mode": "completion" + }, + "codeSimple": { + "model": "gpt-4o", + "preferences": "none", + "mode": "completion" + }, + "research": { + "router": "openai", + "model": "gpt-4.5-preview", + "preferences": "none", + "mode": "completion" + } + }, + "instructions": { + "tone": [ + { "flag": "formal", "text": "use a formal tone" }, + { "flag": "friendly", "text": "be friendly and approachable" } + ], + "content": [ + { "flag": "spellCheck", "text": "spell check the text, fix any errors" }, + { "flag": "removeEmojis", "text": "remove emojis" }, + { "flag": "removePersonalPrefs", "text": "remove personal preferences or biases" }, + { "flag": "removeRedundancy", "text": "remove redundancy, eg: we attached the files" }, + { "flag": "shorten", "text": "shorten text if possible but preserve personality" } + ], + "moderation": [ + { "flag": "mafiaFilter", "text": "remove references to preciousplastic, bazar and Discord" }, + { "flag": "deprogramming", "text": "remove any brain/green washing, eg: sustainable, circular, recycling ... inflated prospects" } + ], + "context": [ + { "flag": "makerTutorials", "text": "Context: howto tutorials, for makers" }, + { "flag": "units", "text": "Convert units, from metric to imperial and vice versa (in braces)" } + ], + "format": [ + { "flag": "markdown", "text": "dont comment just return as Markdown" } + ] + }, + "defaults": { + "tone": ["formal"], + "content": ["spellCheck", "removeEmojis", "removePersonalPrefs", "shorten"], + "moderation": ["mafiaFilter", "deprogramming"], + "context": ["makerTutorials", "units"], + "format": ["markdown"] + } +} \ No newline at end of file diff --git a/src/config/templates/directory.json b/src/config/templates/directory.json new file mode 100644 index 0000000..8758a7d --- /dev/null +++ b/src/config/templates/directory.json @@ -0,0 +1,62 @@ +{ + "templates": { + "categoryList": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "itemDetails": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "searchSuggestions": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "relatedItems": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "categoryDescription": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "itemComparison": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + } + }, + "instructions": { + "context": [ + { "flag": "categorization", "text": "Focus on proper categorization and organization" }, + { "flag": "metadata", "text": "Include relevant metadata and attributes" }, + { "flag": "relationships", "text": "Highlight relationships between items" }, + { "flag": "searchability", "text": "Optimize for search and discovery" } + ], + "format": [ + { "flag": "structured", "text": "Use structured data format" }, + { "flag": "hierarchical", "text": "Show hierarchical relationships" } + ] + }, + "defaults": { + "context": ["categorization", "metadata", "relationships", "searchability"], + "format": ["structured", "hierarchical"] + } +} \ No newline at end of file diff --git a/src/config/templates/howto.json b/src/config/templates/howto.json new file mode 100644 index 0000000..1b14829 --- /dev/null +++ b/src/config/templates/howto.json @@ -0,0 +1,87 @@ +{ + "templates": { + "keywords": { + "_router": "openai", + "model": "google/gemini-exp-1206:free", + "preferences": "none", + "mode": "completion", + "prompt": "Return a list of max. 10 keywords that can be used for SEO purposes, separated by commas (dont comment, just the list) : " + }, + "references": { + "_router": "openai", + "model": "google/gemini-exp-1206:free", + "preferences": "none", + "mode": "completion", + "prompt": "Return a list of useful references (only with links), as Markdown, grouped : Articles, Books, Papers, Youtube, Opensource Designs, ... Dont comment !", + "filters": "code" + }, + "toolsAndHardware": { + "router_": "openai", + "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), with links, max. 5.", + "filters": "code" + }, + "requiredSkills": { + "router": "openai", + "model": "gpt-4o", + "preferences": "none", + "mode": "completion", + "prompt": "Analyze the following tutorial and identify all the skills that a person would need in order to complete the project. Return as JSON with this structure:\n\n{\n \"skills\": [\n {\n \"name\": \"Skill name\", \n \"level\": \"Beginner, Intermediate, or Advanced\", \n \"description\": \"Brief description of where/how this skill is needed\"\n }\n ],\n \"prerequisiteKnowledge\": [\n \"Background knowledge or familiarity with concepts\"\n ],\n \"safetyConsiderations\": [\n \"Any safety considerations or precautions needed\"\n ]\n}\n\nReturn only the JSON. No introductions or explanations.", + "filters": "code" + }, + "learnedSkills": { + "router": "openai", + "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, modest, humble, simple - dont enflate (sustainable, recylcing, ...), Return as Markdown chapter (H2) with very short bullet points (not bold), max. 5.", + "filters": "code" + }, + "local": { + "model": "perplexity/sonar-deep-research", + "preferences": "none", + "mode": "completion", + "prompt": "Markdown chapter (h4) with a list of local resources, services & suppliers, max. 5, with links,group by category. dont comment, just the list", + "filters": "code" + }, + "difficulty": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "timeEstimate": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + }, + "prerequisites": { + "router": "openai", + "model": "gpt-4o", + "mode": "completion", + "preferences": "none", + "filters": "code" + } + }, + "instructions": { + "context": [ + { "flag": "makerTutorials", "text": "Focus on maker and DIY tutorial content" }, + { "flag": "units", "text": "Include relevant units and measurements" }, + { "flag": "safety", "text": "Include safety considerations and warnings" }, + { "flag": "troubleshooting", "text": "Include common issues and solutions" } + ], + "format": [ + { "flag": "stepByStep", "text": "Format as clear step-by-step instructions" }, + { "flag": "checklist", "text": "Include progress checkpoints" } + ] + }, + "defaults": { + "context": ["makerTutorials", "units", "safety", "troubleshooting"], + "format": ["stepByStep", "checklist"] + } +} \ No newline at end of file diff --git a/src/config/templates/marketplace.json b/src/config/templates/marketplace.json new file mode 100644 index 0000000..3de2762 --- /dev/null +++ b/src/config/templates/marketplace.json @@ -0,0 +1,28 @@ +{ + "templates": { + "productDescription": { + "router": "openai", + "model": "gpt-4o", + "preferences": "none", + "mode": "completion", + "prompt": "Write a clear and concise product description that highlights the key features and benefits. Include technical specifications where relevant.", + "filters": "code" + }, + "pricingAnalysis": { + "router": "openai", + "model": "gpt-4o", + "preferences": "none", + "mode": "completion", + "prompt": "Analyze the market value and suggest a competitive price range for this product. Consider materials, manufacturing costs, and market positioning.", + "filters": "code" + }, + "marketResearch": { + "router": "openai", + "model": "perplexity/sonar-deep-research", + "preferences": "none", + "mode": "completion", + "prompt": "Provide market research insights including target audience, competitors, and market trends. Format as Markdown sections.", + "filters": "code" + } + } +} \ No newline at end of file