hashan-7 commited on
Commit
efa0658
·
verified ·
1 Parent(s): cb1a883

Update code

Browse files
Files changed (1) hide show
  1. code_router.py +23 -2
code_router.py CHANGED
@@ -1,4 +1,5 @@
1
  import re
 
2
  from schemas import CodeTaskType
3
 
4
 
@@ -10,8 +11,11 @@ GENERATE_PATTERNS = [
10
  r"\bmake\b",
11
  r"\bdevelop\b",
12
  r"\bimplement\b",
 
 
13
  ]
14
 
 
15
  FIX_PATTERNS = [
16
  r"\bfix\b",
17
  r"\bsolve\b",
@@ -25,8 +29,13 @@ FIX_PATTERNS = [
25
  r"\bcrash\b",
26
  r"\bfailed\b",
27
  r"\bproblem\b",
 
 
 
 
28
  ]
29
 
 
30
  EXPLAIN_PATTERNS = [
31
  r"\bexplain\b",
32
  r"\bwhat does this do\b",
@@ -34,8 +43,11 @@ EXPLAIN_PATTERNS = [
34
  r"\bdescribe\b",
35
  r"\bmeaning\b",
36
  r"\bunderstand\b",
 
 
37
  ]
38
 
 
39
  REFACTOR_PATTERNS = [
40
  r"\brefactor\b",
41
  r"\bclean\b",
@@ -44,16 +56,22 @@ REFACTOR_PATTERNS = [
44
  r"\bbetter\b",
45
  r"\bmake this cleaner\b",
46
  r"\bmake this better\b",
 
47
  ]
48
 
 
49
  REVIEW_PATTERNS = [
50
  r"\breview\b",
51
  r"\bcheck this code\b",
52
  r"\baudit\b",
53
  r"\binspect\b",
54
  r"\bcode review\b",
 
 
 
55
  ]
56
 
 
57
  MODIFICATION_PATTERNS = [
58
  r"\badd\b",
59
  r"\bupdate\b",
@@ -76,14 +94,17 @@ MODIFICATION_PATTERNS = [
76
  r"\bexception handling\b",
77
  r"\bmake it\b",
78
  r"\bturn this into\b",
 
79
  ]
80
 
 
81
  DIRECT_EXPLAIN_ONLY_PATTERNS = [
82
  r"\bexplain\b",
83
  r"\bwhat does this do\b",
84
  r"\bhow does this work\b",
85
  r"\bdescribe this code\b",
86
  r"\bhelp me understand\b",
 
87
  ]
88
 
89
 
@@ -137,7 +158,7 @@ def detect_task_type(
137
  if has_code and is_modification_request(normalized_message):
138
  return CodeTaskType.REFACTOR
139
 
140
- if contains_pattern(normalized_message, GENERATE_PATTERNS):
141
  return CodeTaskType.GENERATE
142
 
143
  if contains_pattern(normalized_message, EXPLAIN_PATTERNS) and not is_modification_request(normalized_message):
@@ -148,7 +169,7 @@ def detect_task_type(
148
  return CodeTaskType.REFACTOR
149
  return CodeTaskType.EXPLAIN
150
 
151
- if is_modification_request(normalized_message):
152
  return CodeTaskType.GENERATE
153
 
154
  return CodeTaskType.UNKNOWN
 
1
  import re
2
+
3
  from schemas import CodeTaskType
4
 
5
 
 
11
  r"\bmake\b",
12
  r"\bdevelop\b",
13
  r"\bimplement\b",
14
+ r"\bcreate from scratch\b",
15
+ r"\bstart a new\b",
16
  ]
17
 
18
+
19
  FIX_PATTERNS = [
20
  r"\bfix\b",
21
  r"\bsolve\b",
 
29
  r"\bcrash\b",
30
  r"\bfailed\b",
31
  r"\bproblem\b",
32
+ r"\bdoesn't work\b",
33
+ r"\bdoes not work\b",
34
+ r"\bthrowing\b",
35
+ r"\btraceback\b",
36
  ]
37
 
38
+
39
  EXPLAIN_PATTERNS = [
40
  r"\bexplain\b",
41
  r"\bwhat does this do\b",
 
43
  r"\bdescribe\b",
44
  r"\bmeaning\b",
45
  r"\bunderstand\b",
46
+ r"\bwalk me through\b",
47
+ r"\bcan you explain\b",
48
  ]
49
 
50
+
51
  REFACTOR_PATTERNS = [
52
  r"\brefactor\b",
53
  r"\bclean\b",
 
56
  r"\bbetter\b",
57
  r"\bmake this cleaner\b",
58
  r"\bmake this better\b",
59
+ r"\bclean up\b",
60
  ]
61
 
62
+
63
  REVIEW_PATTERNS = [
64
  r"\breview\b",
65
  r"\bcheck this code\b",
66
  r"\baudit\b",
67
  r"\binspect\b",
68
  r"\bcode review\b",
69
+ r"\bany issues\b",
70
+ r"\bis this okay\b",
71
+ r"\bfind problems\b",
72
  ]
73
 
74
+
75
  MODIFICATION_PATTERNS = [
76
  r"\badd\b",
77
  r"\bupdate\b",
 
94
  r"\bexception handling\b",
95
  r"\bmake it\b",
96
  r"\bturn this into\b",
97
+ r"\badd support for\b",
98
  ]
99
 
100
+
101
  DIRECT_EXPLAIN_ONLY_PATTERNS = [
102
  r"\bexplain\b",
103
  r"\bwhat does this do\b",
104
  r"\bhow does this work\b",
105
  r"\bdescribe this code\b",
106
  r"\bhelp me understand\b",
107
+ r"\bwalk me through\b",
108
  ]
109
 
110
 
 
158
  if has_code and is_modification_request(normalized_message):
159
  return CodeTaskType.REFACTOR
160
 
161
+ if contains_pattern(normalized_message, GENERATE_PATTERNS) and not has_code:
162
  return CodeTaskType.GENERATE
163
 
164
  if contains_pattern(normalized_message, EXPLAIN_PATTERNS) and not is_modification_request(normalized_message):
 
169
  return CodeTaskType.REFACTOR
170
  return CodeTaskType.EXPLAIN
171
 
172
+ if is_modification_request(normalized_message) and not has_code:
173
  return CodeTaskType.GENERATE
174
 
175
  return CodeTaskType.UNKNOWN