@@ -107,30 +107,34 @@ function processCode(
107107 let prompt : string = "" ;
108108 if ( action === "analyze" ) {
109109 prompt = `
110- You are an expert software engineer.
111- Given the Leetcode problem ${ problemTitle } and the associated code below, analyze it concisely and directly.
112- Provide the time complexity and the space complexity, both expressed in big O notation.
113- Offer a brief explanation(1 - 2 lines max) for each complexity analysis.
114- Keep your analysis direct and succinct.
110+ As an experienced software engineer, please analyze the Leetcode problem titled ${ problemTitle } and the accompanying code below.
111+ Your analysis should be concise and straightforward, providing both time and space complexity in big O notation.
112+ Please include a brief explanation (no more than 1-2 lines) for each complexity analysis.
113+ Space complexity should not include the output (return value) of the function.
114+ Your analysis should be direct and to the point.
115+ The code is provided below.
115116 ` ;
116117 infoMessage ! . textContent = 'Analyzing code complexity ...' ;
117118 analyzeCodeResponse ! . classList . remove ( 'hidden' ) ;
118119 fixCodeContainer ! . classList . add ( 'hidden' ) ;
119120 }
120121 else if ( action === "fix" ) {
121122 prompt = `
122- ChatGPT, in your capacity as a coding expert, I need your assistance with a LeetCode problem titled ${ problemTitle } .
123- If only the function definition is provided, your task is to generate the optimal solution for this problem.
124- Conversely, if the code is provided below, there is most likely error(s) in the code.
125- Please correct any potential issues that is preventing the submission f rom being accepted.
126- If the provided code is already correct and optimized, return it as is.
127- All code should be returned in plain text, with no usage of code blocks, and only essential inline comments are permitted.
123+ As a coding expert, I require your aid with a specific LeetCode problem called ${ problemTitle } .
124+ If you are given only the function definition, your task is to generate the best possible solution for this problem.
125+ On the other hand, if the code is already provided, there may be some errors that are preventing it from being accepted.
126+ Please identify and fix any potential issues in the code.
127+ If the provided code is already correct and optimized, please return it as is.
128+ All code should be returned in plain text format, with no usage of code blocks.
129+ Inline comments are permitted, but only if they are essential.
130+ The code is provided below.
131+
128132 ` ;
129133 infoMessage ! . textContent = 'Creating the solution ...' ;
130134 analyzeCodeResponse ! . classList . add ( 'hidden' ) ;
131135 fixCodeContainer ! . classList . remove ( 'hidden' ) ;
132136 }
133- prompt += '\n Heres the code \n ' + codeText ;
137+ prompt += '\n' + codeText ;
134138
135139 let response = '' ;
136140 chatGPTProvider . generateAnswer ( {
0 commit comments