JSenkCC commited on
Commit
1b0d970
·
verified ·
1 Parent(s): ed484aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -12
app.py CHANGED
@@ -287,35 +287,42 @@ def identify_required_functions(project_path, functionality_description):
287
 
288
  def extract_cleaned_gemini_output(gemini_output):
289
  """
290
- Extracts and formats the cleaned output from Gemini to send to Qwen.
291
  Args:
292
- gemini_output (str): The output returned by Gemini.
293
  Returns:
294
- str: Cleaned and formatted output for Qwen.
295
  """
296
  lines = gemini_output.splitlines()
297
  cleaned_output = []
298
- in_functions_section = False
299
 
300
  for line in lines:
301
  line = line.strip()
302
 
303
- # Include only relevant sections
304
- if line.startswith("Project Summary:") or line.startswith("Functionality:"):
 
305
  cleaned_output.append(line)
306
- elif line.startswith("Functions:"):
307
  cleaned_output.append(line)
308
- in_functions_section = True
309
- elif in_functions_section and line.startswith("-public"):
 
 
310
  cleaned_output.append(line)
311
- elif in_functions_section and not line.startswith("-"):
312
- # Exit functions section when encountering non-relevant lines
313
- in_functions_section = False
 
 
 
314
 
315
  return "\n".join(cleaned_output)
316
 
317
 
318
 
 
319
  def split_into_chunks(content, chunk_size=1000):
320
  """Splits large content into smaller chunks."""
321
  return [content[i:i + chunk_size] for i in range(0, len(content), chunk_size)]
 
287
 
288
  def extract_cleaned_gemini_output(gemini_output):
289
  """
290
+ Extracts and formats the cleaned output from Gemini to send to Qwen or display to the user.
291
  Args:
292
+ gemini_output (str): The raw output returned by Gemini.
293
  Returns:
294
+ str: Cleaned and formatted output.
295
  """
296
  lines = gemini_output.splitlines()
297
  cleaned_output = []
298
+ capture = False # Flag to determine whether to capture the lines
299
 
300
  for line in lines:
301
  line = line.strip()
302
 
303
+ # Start capturing from "Project Summary:" and include only relevant sections
304
+ if line.startswith("Project Summary:"):
305
+ capture = True
306
  cleaned_output.append(line)
307
+ elif line.startswith("Functionality:") or line.startswith("Functionality Flow:"):
308
  cleaned_output.append(line)
309
+ elif line.startswith("Function Documentation:"):
310
+ cleaned_output.append(line)
311
+ elif line.startswith("Functions:"):
312
+ capture = True # Start capturing function definitions
313
  cleaned_output.append(line)
314
+ elif capture:
315
+ # Capture relevant content under active sections
316
+ if line.startswith("-public") or line.startswith("-private"):
317
+ cleaned_output.append(line)
318
+ elif not line: # Stop capturing on empty lines after a valid section
319
+ capture = False
320
 
321
  return "\n".join(cleaned_output)
322
 
323
 
324
 
325
+
326
  def split_into_chunks(content, chunk_size=1000):
327
  """Splits large content into smaller chunks."""
328
  return [content[i:i + chunk_size] for i in range(0, len(content), chunk_size)]