prernajeet14 commited on
Commit
ebeb1f8
·
verified ·
1 Parent(s): 3bcb01b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -13
app.py CHANGED
@@ -144,25 +144,31 @@ class CodingCopilot:
144
 
145
  # Build specialized prompts based on request type
146
  if is_continuation:
147
- prompt = f"""You are an advanced coding assistant. The user is asking you to CONTINUE or EXTEND previous code.
148
-
149
- CRITICAL INSTRUCTIONS FOR CONTINUATION:
150
  1. Look at the previous conversation to understand what code was generated
151
  2. Continue from where the previous code left off - DO NOT start from the beginning
152
  3. Maintain the same coding style, structure, and patterns
153
  4. Add new functionality or complete incomplete sections
154
  5. Generate substantial code (aim for 500-2000+ lines if needed)
155
- 6. Ensure the continuation integrates seamlessly with previous code
 
 
 
 
 
 
 
 
156
 
157
  User's continuation request: {message}
158
 
159
  {file_status}
160
 
161
- {f"Code files content for reference:\n```\n{file_content}\n```" if file_content else ""}
162
 
163
  {context}
164
 
165
- Based on the previous conversation, continue the code generation. Do NOT restart - pick up exactly where the previous response left off and continue building upon it. Provide substantial, complete code sections."""
166
 
167
  else:
168
  # Determine if this is a code generation request
@@ -170,36 +176,44 @@ Based on the previous conversation, continue the code generation. Do NOT restart
170
  is_generation = any(keyword in message.lower() for keyword in generation_keywords)
171
 
172
  if is_generation:
173
- prompt = f"""You are an advanced coding assistant specialized in generating comprehensive, production-ready code.
174
-
175
- CRITICAL INSTRUCTIONS FOR CODE GENERATION:
176
  1. Generate COMPLETE, COMPREHENSIVE code - aim for 500-3000+ lines when appropriate
177
  2. Include ALL necessary components: classes, functions, error handling, documentation
178
  3. Create fully functional, production-ready applications
179
  4. Add comprehensive comments and docstrings
180
  5. Include proper imports, dependencies, and structure
181
  6. Don't truncate or abbreviate - provide the FULL implementation
182
- 7. If the project is large, focus on core functionality but make it complete
 
 
 
 
 
 
 
 
183
 
184
  User's request: {message}
185
 
186
  {file_status}
187
 
188
- {f"Reference code files:\n```\n{file_content}\n```" if file_content else ""}
189
 
190
  {context}
191
 
192
- Generate comprehensive, complete code that fully implements the requested functionality. Provide extensive code with proper structure, documentation, and all necessary components."""
193
 
194
  else:
195
  # Regular analysis/chat prompt
 
 
196
  prompt = f"""You are an advanced coding assistant. Provide detailed, comprehensive responses.
197
 
198
  User's request: {message}
199
 
200
  {file_status}
201
 
202
- {f"Code files content:\n```\n{file_content}\n```" if file_content else ""}
203
 
204
  {context}
205
 
 
144
 
145
  # Build specialized prompts based on request type
146
  if is_continuation:
147
+ continuation_instructions = """CRITICAL INSTRUCTIONS FOR CONTINUATION:
 
 
148
  1. Look at the previous conversation to understand what code was generated
149
  2. Continue from where the previous code left off - DO NOT start from the beginning
150
  3. Maintain the same coding style, structure, and patterns
151
  4. Add new functionality or complete incomplete sections
152
  5. Generate substantial code (aim for 500-2000+ lines if needed)
153
+ 6. Ensure the continuation integrates seamlessly with previous code"""
154
+
155
+ file_content_section = f"\nCode files content for reference:\n```\n{file_content}\n```" if file_content else ""
156
+
157
+ final_instruction = "Based on the previous conversation, continue the code generation. Do NOT restart - pick up exactly where the previous response left off and continue building upon it. Provide substantial, complete code sections."
158
+
159
+ prompt = f"""You are an advanced coding assistant. The user is asking you to CONTINUE or EXTEND previous code.
160
+
161
+ {continuation_instructions}
162
 
163
  User's continuation request: {message}
164
 
165
  {file_status}
166
 
167
+ {file_content_section}
168
 
169
  {context}
170
 
171
+ {final_instruction}"""
172
 
173
  else:
174
  # Determine if this is a code generation request
 
176
  is_generation = any(keyword in message.lower() for keyword in generation_keywords)
177
 
178
  if is_generation:
179
+ generation_instructions = """CRITICAL INSTRUCTIONS FOR CODE GENERATION:
 
 
180
  1. Generate COMPLETE, COMPREHENSIVE code - aim for 500-3000+ lines when appropriate
181
  2. Include ALL necessary components: classes, functions, error handling, documentation
182
  3. Create fully functional, production-ready applications
183
  4. Add comprehensive comments and docstrings
184
  5. Include proper imports, dependencies, and structure
185
  6. Don't truncate or abbreviate - provide the FULL implementation
186
+ 7. If the project is large, focus on core functionality but make it complete"""
187
+
188
+ file_content_section = f"\nReference code files:\n```\n{file_content}\n```" if file_content else ""
189
+
190
+ final_instruction = "Generate comprehensive, complete code that fully implements the requested functionality. Provide extensive code with proper structure, documentation, and all necessary components."
191
+
192
+ prompt = f"""You are an advanced coding assistant specialized in generating comprehensive, production-ready code.
193
+
194
+ {generation_instructions}
195
 
196
  User's request: {message}
197
 
198
  {file_status}
199
 
200
+ {file_content_section}
201
 
202
  {context}
203
 
204
+ {final_instruction}"""
205
 
206
  else:
207
  # Regular analysis/chat prompt
208
+ file_content_section = f"\nCode files content:\n```\n{file_content}\n```" if file_content else ""
209
+
210
  prompt = f"""You are an advanced coding assistant. Provide detailed, comprehensive responses.
211
 
212
  User's request: {message}
213
 
214
  {file_status}
215
 
216
+ {file_content_section}
217
 
218
  {context}
219