From aef26f1c683858fa828cce945732653143113470 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 1 Dec 2024 19:02:52 -0500 Subject: [PATCH] prompt enhanchment --- README.md | 2 +- app/routes/api.enhancer.ts | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6590ab2..91eae02 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ https://thinktank.ottomator.ai - ✅ Load local projects into the app (@wonderwhy-er) - ✅ Together Integration (@mouimet-infinisoft) - ✅ Mobile friendly (@qwikode) +- ✅ Better prompt enhancing (@SujalXplores) - ⬜ **HIGH PRIORITY** - ALMOST DONE - Attach images to prompts (@atrokhym) - ⬜ **HIGH PRIORITY** - Prevent Bolt from rewriting files as often (file locking and diffs) - ⬜ **HIGH PRIORITY** - Better prompting for smaller LLMs (code window sometimes doesn't start) @@ -43,7 +44,6 @@ https://thinktank.ottomator.ai - ⬜ Perplexity Integration - ⬜ Vertex AI Integration - ⬜ Deploy directly to Vercel/Netlify/other similar platforms -- ⬜ Better prompt enhancing - ⬜ Have LLM plan the project in a MD file for better results/transparency - ⬜ VSCode Integration with git-like confirmations - ⬜ Upload documents for knowledge - UI design templates, a code base to reference coding style, etc. diff --git a/app/routes/api.enhancer.ts b/app/routes/api.enhancer.ts index 77e6f2f..caebae0 100644 --- a/app/routes/api.enhancer.ts +++ b/app/routes/api.enhancer.ts @@ -44,9 +44,25 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) { content: `[Model: ${model}]\n\n[Provider: ${providerName}]\n\n` + stripIndents` + You are a professional prompt engineer specializing in crafting precise, effective prompts. + Your task is to enhance prompts by making them more specific, actionable, and effective. I want you to improve the user prompt that is wrapped in \`\` tags. - IMPORTANT: Only respond with the improved prompt and nothing else! + For valid prompts: + - Make instructions explicit and unambiguous + - Add relevant context and constraints + - Remove redundant information + - Maintain the core intent + - Ensure the prompt is self-contained + - Use professional language + For invalid or unclear prompts: + - Respond with a clear, professional guidance message + - Keep responses concise and actionable + - Maintain a helpful, constructive tone + - Focus on what the user should provide + - Use a standard template for consistency + IMPORTANT: Your response must ONLY contain the enhanced prompt text. + Do not include any explanations, metadata, or wrapper tags. ${message} @@ -79,7 +95,7 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) { }, }); - const transformedStream = result.toAIStream().pipeThrough(transformStream); + const transformedStream = result.toDataStream().pipeThrough(transformStream); return new StreamingTextResponse(transformedStream); } catch (error: unknown) {