iammahmads commited on
Commit
f2d1e8c
ยท
verified ยท
1 Parent(s): b390e55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -73,15 +73,22 @@ class CodeCopilot:
73
 
74
 
75
  def generate_suggestions(self, patterns):
76
- """Generate suggestions based on detected patterns"""
77
- suggestions = []
78
- if patterns['function_def'] > 3:
79
- suggestions.append("๐Ÿ” Consider breaking down into smaller functions or using a class structure.")
80
- if patterns['loop'] > 2:
81
- suggestions.append("๐Ÿ”„ You might benefit from list comprehensions or map/filter functions.")
82
- if patterns['conditional'] > 3:
83
- suggestions.append("โš– Complex conditionals might be simplified using polymorphism or strategy pattern.")
84
- return "\n".join(suggestions) if suggestions else "No specific suggestions at this time."
 
 
 
 
 
 
 
85
 
86
  def process_input(self, user_input):
87
  """Process user input and generate response"""
 
73
 
74
 
75
  def generate_suggestions(self, patterns):
76
+ suggestions = []
77
+
78
+ if patterns['function_def'] >= 1:
79
+ suggestions.append("๐Ÿ” Consider organizing related functions into classes.")
80
+
81
+ if patterns['loop'] >= 1:
82
+ suggestions.append("๐Ÿ”„ Try using list comprehensions or built-in functions like `map()` where appropriate.")
83
+
84
+ if patterns['conditional'] >= 2:
85
+ suggestions.append("โš– Consider simplifying conditionals using design patterns or helper functions.")
86
+
87
+ if sum(patterns.values()) == 0:
88
+ suggestions.append("๐Ÿง No recognizable code patterns found. Try pasting a complete code block.")
89
+
90
+ return "\n".join(suggestions)
91
+
92
 
93
  def process_input(self, user_input):
94
  """Process user input and generate response"""