rootxhacker commited on
Commit
a82f85a
·
verified ·
1 Parent(s): 41edfc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -119,7 +119,7 @@ Now, review the following code using this approach:
119
  """
120
 
121
  # Concatenate the prompt with the code to analyze
122
- query = few_shot_prompt + "\n\n" + code_to_analyze + "\n\nProvide a detailed review following the structure above, including understanding the code, identifying potential security issues, identifying potential logic vulnerabilities, and offering specific suggestions for improvement. Start each section with its number and title, e.g., '1. Understanding the code:'"
123
 
124
  full_result = get_completion(query, model, tokenizer)
125
 
@@ -128,14 +128,17 @@ Now, review the following code using this approach:
128
  processed_lines = []
129
  relevant_sections = ['1. Understanding the code:', '2. Potential security issues:', '3. Potential logic vulnerabilities:', 'Suggestions:']
130
  in_relevant_section = False
 
131
 
132
  for line in lines:
133
  if any(section in line for section in relevant_sections):
 
 
134
  in_relevant_section = True
135
  processed_lines.append(line)
136
- elif in_relevant_section and line.strip():
137
  processed_lines.append(line)
138
- elif in_relevant_section and not line.strip():
139
  in_relevant_section = False
140
 
141
  result = "\n".join(processed_lines).strip()
 
119
  """
120
 
121
  # Concatenate the prompt with the code to analyze
122
+ query = few_shot_prompt + "\n\n" + code_to_analyze + "\n\nProvide a detailed review of the above code following the structure in the example, including understanding the code, identifying potential security issues, identifying potential logic vulnerabilities, and offering specific suggestions for improvement. Start each section with its number and title, e.g., '1. Understanding the code:'"
123
 
124
  full_result = get_completion(query, model, tokenizer)
125
 
 
128
  processed_lines = []
129
  relevant_sections = ['1. Understanding the code:', '2. Potential security issues:', '3. Potential logic vulnerabilities:', 'Suggestions:']
130
  in_relevant_section = False
131
+ found_first_section = False
132
 
133
  for line in lines:
134
  if any(section in line for section in relevant_sections):
135
+ if not found_first_section:
136
+ found_first_section = True
137
  in_relevant_section = True
138
  processed_lines.append(line)
139
+ elif found_first_section and in_relevant_section and line.strip():
140
  processed_lines.append(line)
141
+ elif found_first_section and in_relevant_section and not line.strip():
142
  in_relevant_section = False
143
 
144
  result = "\n".join(processed_lines).strip()