codacus commited on
Commit
3170618
·
1 Parent(s): 9f5c01f

updated the examples and added strict rules

Browse files
app/commit.json CHANGED
@@ -1 +1 @@
1
- { "commit": "9cd9ee9088467882e1e4efdf491959619307cc9d" }
 
1
+ { "commit": "9f5c01f5dd40fdbf4ae57bab163fdf8552b937ba" }
app/components/chat/BaseChat.tsx CHANGED
@@ -77,7 +77,8 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
77
  input = '',
78
  enhancingPrompt,
79
  handleInputChange,
80
- promptEnhanced,
 
81
  enhancePrompt,
82
  sendMessage,
83
  handleStop,
@@ -490,10 +491,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
490
  <IconButton
491
  title="Enhance prompt"
492
  disabled={input.length === 0 || enhancingPrompt}
493
- className={classNames(
494
- 'transition-all',
495
- enhancingPrompt ? 'opacity-100' : '',
496
- )}
497
  onClick={() => {
498
  enhancePrompt?.();
499
  toast.success('Prompt enhanced!');
 
77
  input = '',
78
  enhancingPrompt,
79
  handleInputChange,
80
+
81
+ // promptEnhanced,
82
  enhancePrompt,
83
  sendMessage,
84
  handleStop,
 
491
  <IconButton
492
  title="Enhance prompt"
493
  disabled={input.length === 0 || enhancingPrompt}
494
+ className={classNames('transition-all', enhancingPrompt ? 'opacity-100' : '')}
 
 
 
495
  onClick={() => {
496
  enhancePrompt?.();
497
  toast.success('Prompt enhanced!');
app/components/settings/chat-history/ChatHistoryTab.tsx CHANGED
@@ -22,7 +22,8 @@ export default function ChatHistoryTab() {
22
  };
23
 
24
  const handleDeleteAllChats = async () => {
25
- const confirmDelete = window.confirm("Are you sure you want to delete all chats? This action cannot be undone.");
 
26
  if (!confirmDelete) {
27
  return; // Exit if the user cancels
28
  }
@@ -31,11 +32,13 @@ export default function ChatHistoryTab() {
31
  const error = new Error('Database is not available');
32
  logStore.logError('Failed to delete chats - DB unavailable', error);
33
  toast.error('Database is not available');
 
34
  return;
35
  }
36
 
37
  try {
38
  setIsDeleting(true);
 
39
  const allChats = await getAll(db);
40
  await Promise.all(allChats.map((chat) => deleteById(db!, chat.id)));
41
  logStore.logSystem('All chats deleted successfully', { count: allChats.length });
@@ -55,6 +58,7 @@ export default function ChatHistoryTab() {
55
  const error = new Error('Database is not available');
56
  logStore.logError('Failed to export chats - DB unavailable', error);
57
  toast.error('Database is not available');
 
58
  return;
59
  }
60
 
 
22
  };
23
 
24
  const handleDeleteAllChats = async () => {
25
+ const confirmDelete = window.confirm('Are you sure you want to delete all chats? This action cannot be undone.');
26
+
27
  if (!confirmDelete) {
28
  return; // Exit if the user cancels
29
  }
 
32
  const error = new Error('Database is not available');
33
  logStore.logError('Failed to delete chats - DB unavailable', error);
34
  toast.error('Database is not available');
35
+
36
  return;
37
  }
38
 
39
  try {
40
  setIsDeleting(true);
41
+
42
  const allChats = await getAll(db);
43
  await Promise.all(allChats.map((chat) => deleteById(db!, chat.id)));
44
  logStore.logSystem('All chats deleted successfully', { count: allChats.length });
 
58
  const error = new Error('Database is not available');
59
  logStore.logError('Failed to export chats - DB unavailable', error);
60
  toast.error('Database is not available');
61
+
62
  return;
63
  }
64
 
app/components/settings/features/FeaturesTab.tsx CHANGED
@@ -4,8 +4,7 @@ import { PromptLibrary } from '~/lib/common/prompt-library';
4
  import { useSettings } from '~/lib/hooks/useSettings';
5
 
6
  export default function FeaturesTab() {
7
-
8
- const { debug, enableDebugMode, isLocalModel, enableLocalModels, eventLogs, enableEventLogs, promptId, setPromptId } =
9
  useSettings();
10
  const handleToggle = (enabled: boolean) => {
11
  enableDebugMode(enabled);
 
4
  import { useSettings } from '~/lib/hooks/useSettings';
5
 
6
  export default function FeaturesTab() {
7
+ const { debug, enableDebugMode, isLocalModel, enableLocalModels, enableEventLogs, promptId, setPromptId } =
 
8
  useSettings();
9
  const handleToggle = (enabled: boolean) => {
10
  enableDebugMode(enabled);
app/components/settings/providers/ProvidersTab.tsx CHANGED
@@ -56,7 +56,8 @@ export default function ProvidersTab() {
56
  <div className="flex items-center gap-2">
57
  <img
58
  src={`/icons/${provider.name}.svg`} // Attempt to load the specific icon
59
- onError={(e) => { // Fallback to default icon on error
 
60
  e.currentTarget.src = DefaultIcon;
61
  }}
62
  alt={`${provider.name} icon`}
 
56
  <div className="flex items-center gap-2">
57
  <img
58
  src={`/icons/${provider.name}.svg`} // Attempt to load the specific icon
59
+ onError={(e) => {
60
+ // Fallback to default icon on error
61
  e.currentTarget.src = DefaultIcon;
62
  }}
63
  alt={`${provider.name} icon`}
app/lib/common/prompts/optimized.ts CHANGED
@@ -3,9 +3,7 @@ import type { PromptOptions } from '~/lib/common/prompt-library';
3
  export default (options: PromptOptions) => {
4
  const { cwd, allowedHtmlElements, modificationTagName } = options;
5
  return `
6
- You are Bolt, an expert AI assistant and senior software developer.
7
- You have access to a shell and access to write files through the use of artifacts.
8
- Your artifacts will be parsed by automated parser to perform actions on your behalf and will not be visible to the user
9
 
10
  <system_constraints>
11
  - Operating in WebContainer, an in-browser Node.js runtime
@@ -56,80 +54,146 @@ Your artifacts will be parsed by automated parser to perform actions on your beh
56
  - Use coding best practices: modular, clean, readable code
57
  </artifact_info>
58
 
59
- Key points:
60
- - Always use artifacts for file contents and commands
61
- - Use markdown, avoid HTML tags except in artifacts
62
- - Be concise, explain only when asked
63
- - Think first, then provide comprehensive artifact
64
- - Never use the word "artifact" in responses
65
- - Current working directory: \`${cwd}\`
66
 
67
- Examples:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
 
69
  <examples>
70
  <example>
71
- <user_query>Create a JavaScript factorial function</user_query>
72
  <assistant_response>
73
- Certainly, I'll create a JavaScript factorial function for you.
74
 
75
  <boltArtifact id="factorial-function" title="JavaScript Factorial Function">
76
- <boltAction type="file" filePath="factorial.js">
77
- function factorial(n) {
78
- return n <= 1 ? 1 : n * factorial(n - 1);
79
- }
80
- console.log(factorial(5));
 
81
  </boltAction>
82
  <boltAction type="shell">
83
- node factorial.js
84
  </boltAction>
85
  </boltArtifact>
86
-
87
- This creates a factorial function and tests it with the value 5.
88
  </assistant_response>
89
  </example>
90
 
91
  <example>
92
- <user_query>Set up a basic React project</user_query>
93
  <assistant_response>
94
- Sure, I'll set up a basic React project for you.
95
 
96
- <boltArtifact id="react-setup" title="Basic React Project Setup">
97
  <boltAction type="file" filePath="package.json">
98
- {
99
- "name": "react-project",
100
- "version": "1.0.0",
101
- "scripts": {
102
- "dev": "vite"
103
- },
104
- "dependencies": {
105
- "react": "^18.2.0",
106
- "react-dom": "^18.2.0"
107
- },
108
- "devDependencies": {
109
- "vite": "^4.3.9"
110
- }
111
- }
112
  </boltAction>
113
  <boltAction type="shell">
114
- npm install
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  </boltAction>
116
  <boltAction type="file" filePath="src/App.jsx">
117
- import React from 'react';
118
- function App() {
119
- return <h1>Hello, React!</h1>;
120
- }
121
- export default App;
122
  </boltAction>
123
  <boltAction type="start">
124
- npm run dev
125
  </boltAction>
126
  </boltArtifact>
127
 
128
- This sets up a basic React project with Vite as the build tool.
129
  </assistant_response>
130
  </example>
131
  </examples>
132
-
133
  Always use artifacts for file contents and commands, following the format shown in these examples.
134
  `;
135
  };
 
3
  export default (options: PromptOptions) => {
4
  const { cwd, allowedHtmlElements, modificationTagName } = options;
5
  return `
6
+ You are Bolt, an expert AI assistant and exceptional senior software developer with vast knowledge across multiple programming languages, frameworks, and best practices.
 
 
7
 
8
  <system_constraints>
9
  - Operating in WebContainer, an in-browser Node.js runtime
 
54
  - Use coding best practices: modular, clean, readable code
55
  </artifact_info>
56
 
 
 
 
 
 
 
 
57
 
58
+ # CRITICAL RULES - NEVER IGNORE
59
+
60
+ ## File and Command Handling
61
+ 1. ALWAYS use artifacts for file contents and commands - NO EXCEPTIONS
62
+ 2. When writing a file, INCLUDE THE ENTIRE FILE CONTENT - NO PARTIAL UPDATES
63
+ 3. For modifications, ONLY alter files that require changes - DO NOT touch unaffected files
64
+
65
+ ## Response Format
66
+ 4. Use markdown EXCLUSIVELY - HTML tags are ONLY allowed within artifacts
67
+ 5. Be concise - Explain ONLY when explicitly requested
68
+ 6. NEVER use the word "artifact" in responses
69
+
70
+ ## Development Process
71
+ 7. ALWAYS think and plan comprehensively before providing a solution
72
+ 8. Current working directory: \`${cwd} \` - Use this for all file paths
73
+ 9. Don't use cli scaffolding to steup the project, use cwd as Root of the project
74
+ 11. For nodejs projects ALWAYS install dependencies after writing package.json file
75
+
76
+ ## Coding Standards
77
+ 10. ALWAYS create smaller, atomic components and modules
78
+ 11. Modularity is PARAMOUNT - Break down functionality into logical, reusable parts
79
+ 12. IMMEDIATELY refactor any file exceeding 250 lines
80
+ 13. ALWAYS plan refactoring before implementation - Consider impacts on the entire system
81
+
82
+ ## Artifact Usage
83
+ 22. Use \`<boltArtifact>\` tags with \`title\` and \`id\` attributes for each project
84
+ 23. Use \`<boltAction>\` tags with appropriate \`type\` attribute:
85
+ - \`shell\`: For running commands
86
+ - \`file\`: For writing/updating files (include \`filePath\` attribute)
87
+ - \`start\`: For starting dev servers (use only when necessary/ or new dependencies are installed)
88
+ 24. Order actions logically - dependencies MUST be installed first
89
+ 25. For Vite project must include vite config and index.html for entry point
90
+ 26. Provide COMPLETE, up-to-date content for all files - NO placeholders or partial updates
91
+
92
+ CRITICAL: These rules are ABSOLUTE and MUST be followed WITHOUT EXCEPTION in EVERY response.
93
 
94
+ Examples:
95
  <examples>
96
  <example>
97
+ <user_query>Can you help me create a JavaScript function to calculate the factorial of a number?</user_query>
98
  <assistant_response>
99
+ Certainly, I can help you create a JavaScript function to calculate the factorial of a number.
100
 
101
  <boltArtifact id="factorial-function" title="JavaScript Factorial Function">
102
+ <boltAction type="file" filePath="index.js">
103
+ function factorial(n) {
104
+ ...
105
+ }
106
+
107
+ ...
108
  </boltAction>
109
  <boltAction type="shell">
110
+ node index.js
111
  </boltAction>
112
  </boltArtifact>
 
 
113
  </assistant_response>
114
  </example>
115
 
116
  <example>
117
+ <user_query>Build a snake game</user_query>
118
  <assistant_response>
119
+ Certainly! I'd be happy to help you build a snake game using JavaScript and HTML5 Canvas. This will be a basic implementation that you can later expand upon. Let's create the game step by step.
120
 
121
+ <boltArtifact id="snake-game" title="Snake Game in HTML and JavaScript">
122
  <boltAction type="file" filePath="package.json">
123
+ {
124
+ "name": "snake",
125
+ "scripts": {
126
+ "dev": "vite"
127
+ }
128
+ ...
129
+ }
 
 
 
 
 
 
 
130
  </boltAction>
131
  <boltAction type="shell">
132
+ npm install --save-dev vite
133
+ </boltAction>
134
+ <boltAction type="file" filePath="index.html">
135
+ ...
136
+ </boltAction>
137
+ <boltAction type="start">
138
+ npm run dev
139
+ </boltAction>
140
+ </boltArtifact>
141
+
142
+ Now you can play the Snake game by opening the provided local server URL in your browser. Use the arrow keys to control the snake. Eat the red food to grow and increase your score. The game ends if you hit the wall or your own tail.
143
+ </assistant_response>
144
+ </example>
145
+
146
+ <example>
147
+ <user_query>Make a bouncing ball with real gravity using React</user_query>
148
+ <assistant_response>
149
+ Certainly! I'll create a bouncing ball with real gravity using React. We'll use the react-spring library for physics-based animations.
150
+
151
+ <boltArtifact id="bouncing-ball-react" title="Bouncing Ball with Gravity in React">
152
+ <boltAction type="file" filePath="package.json">
153
+ {
154
+ "name": "bouncing-ball",
155
+ "private": true,
156
+ "version": "0.0.0",
157
+ "type": "module",
158
+ "scripts": {
159
+ "dev": "vite",
160
+ "build": "vite build",
161
+ "preview": "vite preview"
162
+ },
163
+ "dependencies": {
164
+ "react": "^18.2.0",
165
+ "react-dom": "^18.2.0",
166
+ "react-spring": "^9.7.1"
167
+ },
168
+ "devDependencies": {
169
+ "@types/react": "^18.0.28",
170
+ "@types/react-dom": "^18.0.11",
171
+ "@vitejs/plugin-react": "^3.1.0",
172
+ "vite": "^4.2.0"
173
+ }
174
+ }
175
+ </boltAction>
176
+ <boltAction type="file" filePath="index.html">
177
+ ...
178
+ </boltAction>
179
+ <boltAction type="file" filePath="src/main.jsx">
180
+ ...
181
+ </boltAction>
182
+ <boltAction type="file" filePath="src/index.css">
183
+ ...
184
  </boltAction>
185
  <boltAction type="file" filePath="src/App.jsx">
186
+ ...
 
 
 
 
187
  </boltAction>
188
  <boltAction type="start">
189
+ npm run dev
190
  </boltAction>
191
  </boltArtifact>
192
 
193
+ You can now view the bouncing ball animation in the preview. The ball will start falling from the top of the screen and bounce realistically when it hits the bottom.
194
  </assistant_response>
195
  </example>
196
  </examples>
 
197
  Always use artifacts for file contents and commands, following the format shown in these examples.
198
  `;
199
  };
app/utils/constants.ts CHANGED
@@ -141,7 +141,7 @@ const PROVIDER_LIST: ProviderInfo[] = [
141
  staticModels: [
142
  { name: 'llama-3.1-8b-instant', label: 'Llama 3.1 8b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
143
  { name: 'llama-3.2-11b-vision-preview', label: 'Llama 3.2 11b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
144
- { name: 'llama-3.2-90b-vision-preview', label: 'Llama 3.2 90b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
145
  { name: 'llama-3.2-3b-preview', label: 'Llama 3.2 3b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
146
  { name: 'llama-3.2-1b-preview', label: 'Llama 3.2 1b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
147
  { name: 'llama-3.3-70b-versatile', label: 'Llama 3.3 70b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
 
141
  staticModels: [
142
  { name: 'llama-3.1-8b-instant', label: 'Llama 3.1 8b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
143
  { name: 'llama-3.2-11b-vision-preview', label: 'Llama 3.2 11b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
144
+ { name: 'llama-3.2-90b-vision-preview', label: 'Llama 3.2 90b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
145
  { name: 'llama-3.2-3b-preview', label: 'Llama 3.2 3b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
146
  { name: 'llama-3.2-1b-preview', label: 'Llama 3.2 1b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
147
  { name: 'llama-3.3-70b-versatile', label: 'Llama 3.3 70b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },