Sujal Shah commited on
Commit
e25bb28
Β·
1 Parent(s): d41a4ac

feat: better prompt enhancement

Browse files
Files changed (2) hide show
  1. README.md +1 -1
  2. app/routes/api.enhancer.ts +21 -2
README.md CHANGED
@@ -31,6 +31,7 @@ https://thinktank.ottomator.ai
31
  - βœ… Ability to revert code to earlier version (@wonderwhy-er)
32
  - βœ… Cohere Integration (@hasanraiyan)
33
  - βœ… Dynamic model max token length (@hasanraiyan)
 
34
  - ⬜ **HIGH PRIORITY** - Prevent Bolt from rewriting files as often (file locking and diffs)
35
  - ⬜ **HIGH PRIORITY** - Better prompting for smaller LLMs (code window sometimes doesn't start)
36
  - ⬜ **HIGH PRIORITY** - Load local projects into the app
@@ -43,7 +44,6 @@ https://thinktank.ottomator.ai
43
  - ⬜ Vertex AI Integration
44
  - ⬜ Deploy directly to Vercel/Netlify/other similar platforms
45
  - ⬜ Prompt caching
46
- - ⬜ Better prompt enhancing
47
  - ⬜ Have LLM plan the project in a MD file for better results/transparency
48
  - ⬜ VSCode Integration with git-like confirmations
49
  - ⬜ Upload documents for knowledge - UI design templates, a code base to reference coding style, etc.
 
31
  - βœ… Ability to revert code to earlier version (@wonderwhy-er)
32
  - βœ… Cohere Integration (@hasanraiyan)
33
  - βœ… Dynamic model max token length (@hasanraiyan)
34
+ - βœ… Better prompt enhancing (@SujalXplores)
35
  - ⬜ **HIGH PRIORITY** - Prevent Bolt from rewriting files as often (file locking and diffs)
36
  - ⬜ **HIGH PRIORITY** - Better prompting for smaller LLMs (code window sometimes doesn't start)
37
  - ⬜ **HIGH PRIORITY** - Load local projects into the app
 
44
  - ⬜ Vertex AI Integration
45
  - ⬜ Deploy directly to Vercel/Netlify/other similar platforms
46
  - ⬜ Prompt caching
 
47
  - ⬜ Have LLM plan the project in a MD file for better results/transparency
48
  - ⬜ VSCode Integration with git-like confirmations
49
  - ⬜ Upload documents for knowledge - UI design templates, a code base to reference coding style, etc.
app/routes/api.enhancer.ts CHANGED
@@ -44,9 +44,28 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) {
44
  content:
45
  `[Model: ${model}]\n\n[Provider: ${providerName}]\n\n` +
46
  stripIndents`
 
 
 
47
  I want you to improve the user prompt that is wrapped in \`<original_prompt>\` tags.
48
 
49
- IMPORTANT: Only respond with the improved prompt and nothing else!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  <original_prompt>
52
  ${message}
@@ -79,7 +98,7 @@ async function enhancerAction({ context, request }: ActionFunctionArgs) {
79
  },
80
  });
81
 
82
- const transformedStream = result.toAIStream().pipeThrough(transformStream);
83
 
84
  return new StreamingTextResponse(transformedStream);
85
  } catch (error: unknown) {
 
44
  content:
45
  `[Model: ${model}]\n\n[Provider: ${providerName}]\n\n` +
46
  stripIndents`
47
+ You are a professional prompt engineer specializing in crafting precise, effective prompts.
48
+ Your task is to enhance prompts by making them more specific, actionable, and effective.
49
+
50
  I want you to improve the user prompt that is wrapped in \`<original_prompt>\` tags.
51
 
52
+ For valid prompts:
53
+ - Make instructions explicit and unambiguous
54
+ - Add relevant context and constraints
55
+ - Remove redundant information
56
+ - Maintain the core intent
57
+ - Ensure the prompt is self-contained
58
+ - Use professional language
59
+
60
+ For invalid or unclear prompts:
61
+ - Respond with a clear, professional guidance message
62
+ - Keep responses concise and actionable
63
+ - Maintain a helpful, constructive tone
64
+ - Focus on what the user should provide
65
+ - Use a standard template for consistency
66
+
67
+ IMPORTANT: Your response must ONLY contain the enhanced prompt text.
68
+ Do not include any explanations, metadata, or wrapper tags.
69
 
70
  <original_prompt>
71
  ${message}
 
98
  },
99
  });
100
 
101
+ const transformedStream = result.toDataStream().pipeThrough(transformStream);
102
 
103
  return new StreamingTextResponse(transformedStream);
104
  } catch (error: unknown) {