Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,15 +73,22 @@ class CodeCopilot:
|
|
| 73 |
|
| 74 |
|
| 75 |
def generate_suggestions(self, patterns):
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
if patterns['function_def']
|
| 79 |
-
suggestions.append("๐ Consider
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"""
|