MoHamdyy commited on
Commit
691964f
·
1 Parent(s): e832862

updated retrevial logic

Browse files
Files changed (1) hide show
  1. app.py +4 -30
app.py CHANGED
@@ -5,21 +5,16 @@ from core.llm_handler import get_simple_issue_suggestion, plan_onboarding_kit_co
5
  from core.kit_generator import generate_kit_from_plan
6
  import utils.config_loader
7
 
8
- # --- NEW/UPDATED CONSTANTS ---
9
- # (Incorporating your suggestions and expanding slightly)
10
  CURATED_TOPIC_SLUGS = sorted(list(set([
11
- # Your suggestions (some are single, some multi-word)
12
  "javascript", "css", "config", "python", "html", "cli", "typescript", "tailwindcss", "github config", "llm", # "github config"
13
  "deep neural networks", "deep learning", "neural network", # Changed to spaces
14
  "tensorflow", "pytorch", "ml",
15
  "distributed systems", # Changed to spaces
16
 
17
- # Broad Categories (changed to spaces where appropriate)
18
  "web development", "mobile development", "game development", "machine learning",
19
  "data science", "artificial intelligence", "devops", "cybersecurity", "blockchain",
20
  "iot", "cloud computing", "big data", "robotics", "bioinformatics", "ar vr", # "ar vr" might be better as "augmented reality", "virtual reality" or keep as is if it's a common tag
21
  "natural language processing", "computer vision", "data visualization",
22
- # Specific Technologies & Frameworks
23
  "react", "angular", "vue", "nextjs", "nodejs", "svelte",
24
  "django", "flask", "spring", "dotnet", "ruby on rails", # "ruby on rails"
25
  "android", "ios", "flutter", "react native", # "react native"
@@ -37,10 +32,9 @@ CURATED_LANGUAGE_SLUGS = sorted([
37
  "assembly", "matlab", "groovy", "julia", "ocaml", "pascal", "fortran", "lisp",
38
  "prolog", "erlang", "f#", "zig", "nim", "crystal", "svelte", "vue" # Svelte/Vue also as languages for their specific file types
39
  ])
40
- # --- END NEW/UPDATED CONSTANTS ---
41
 
42
 
43
- # --- MODIFIED FUNCTION: find_and_suggest_issues ---
44
  def find_and_suggest_issues(
45
  selected_language: str | None, # From language dropdown
46
  selected_curated_topics: list[str] | None, # From topics dropdown (multiselect)
@@ -48,7 +42,6 @@ def find_and_suggest_issues(
48
  ):
49
  print(f"Gradio app received language: '{selected_language}', curated_topics: {selected_curated_topics}, custom_topics: '{custom_topics_str}'")
50
 
51
- # --- Default error/empty returns for 8 outputs ---
52
  # issues_markdown, llm_suggestion, raw_issues_state,
53
  # dropdown_update, button_update, controls_section_update, display_section_update,
54
  # language_searched_state
@@ -67,7 +60,6 @@ def find_and_suggest_issues(
67
  gr.update(visible=False), gr.update(visible=False),
68
  lang or ""
69
  )
70
- # ---
71
 
72
  if not selected_language: # Language is now from a dropdown, should always have a value if user interacts
73
  return ("Please select a programming language.", None, None,
@@ -90,11 +82,6 @@ def find_and_suggest_issues(
90
 
91
  final_topics_list = list(final_topics_set) if final_topics_set else None
92
  print(f"Final parsed topics for search: {final_topics_list}")
93
- # --- End Combine topics ---
94
-
95
- # --- REMOVED: is_common_language and language_warning_for_llm logic ---
96
- # Since language comes from a curated dropdown, we assume it's "common" or valid.
97
- # The GitHub API will be the ultimate judge if it finds anything.
98
 
99
  fetched_issues_list = fetch_beginner_issues(
100
  language_to_search,
@@ -111,12 +98,11 @@ def find_and_suggest_issues(
111
  if not fetched_issues_list: # No issues found
112
  return no_issues_found_return_factory(language_to_search, ", ".join(final_topics_list) if final_topics_list else None)
113
 
114
- # --- REMOVED: issues_markdown_prefix related to uncommon language ---
115
- # This is no longer needed if language is from a curated dropdown.
116
 
117
  issues_display_list = []
118
  issue_titles_for_dropdown = []
119
- for i, issue in enumerate(fetched_issues_list[:5]): # Display up to 5
120
  title = issue.get('title', 'N/A')
121
  issues_display_list.append(
122
  f"{i+1}. **{title}**\n"
@@ -150,11 +136,7 @@ def find_and_suggest_issues(
150
  kit_dropdown_update, kit_button_visibility_update,
151
  kit_controls_section_update, kit_display_section_update,
152
  language_to_search) # Return the searched language for state
153
- # --- END MODIFIED FUNCTION ---
154
 
155
-
156
- # handle_kit_generation function (This function should be your last correct version)
157
- # ... (Ensure your full handle_kit_generation is here)
158
  def handle_kit_generation(selected_issue_title_with_num: str, current_issues_state: list[dict], language_searched_state: str ):
159
  checklist_update_on_error = gr.update(value=[], visible=False)
160
  if not selected_issue_title_with_num or not current_issues_state:
@@ -192,17 +174,13 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
192
 
193
  with gr.Row():
194
  with gr.Column(scale=1): # Input column
195
- # --- MODIFIED Language Input to Dropdown ---
196
  lang_dropdown_input = gr.Dropdown(
197
  label="Programming Language (*)",
198
  choices=CURATED_LANGUAGE_SLUGS,
199
  value=CURATED_LANGUAGE_SLUGS[CURATED_LANGUAGE_SLUGS.index("python")] if "python" in CURATED_LANGUAGE_SLUGS else CURATED_LANGUAGE_SLUGS[0] if CURATED_LANGUAGE_SLUGS else None, # Default to python or first in list
200
  interactive=True,
201
- # allow_custom_value=True # Consider this if you want users to type languages not in the list
202
  )
203
- # --- END MODIFIED Language Input ---
204
-
205
- # --- NEW/MODIFIED Topics Input ---
206
  curated_topics_dropdown = gr.Dropdown(
207
  label="Select Common Topics (Optional, Multi-Select)",
208
  choices=CURATED_TOPIC_SLUGS,
@@ -213,7 +191,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
213
  label="Or, Add Custom Topics (Optional, comma-separated slugs)",
214
  placeholder="e.g., my-niche-topic, another-custom-tag"
215
  )
216
- # --- END NEW/MODIFIED Topics Input ---
217
 
218
  find_button = gr.Button("🔍 Find Beginner Issues", variant="primary")
219
 
@@ -251,12 +228,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
251
  interactive=True,
252
  visible=False # Starts hidden
253
  )
254
- # --- END Using INITIAL_CHECKLIST_ITEMS ---
255
 
256
  raw_issues_state = gr.State([])
257
  language_searched_state = gr.State("")
258
 
259
- # --- MODIFIED find_button.click inputs ---
260
  find_button.click(
261
  fn=find_and_suggest_issues,
262
  inputs=[lang_dropdown_input, curated_topics_dropdown, custom_topics_input], # UPDATED
@@ -267,7 +242,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
267
  language_searched_state
268
  ]
269
  )
270
- # --- END MODIFIED find_button.click ---
271
 
272
  generate_kit_button.click(
273
  fn=handle_kit_generation,
 
5
  from core.kit_generator import generate_kit_from_plan
6
  import utils.config_loader
7
 
 
 
8
  CURATED_TOPIC_SLUGS = sorted(list(set([
 
9
  "javascript", "css", "config", "python", "html", "cli", "typescript", "tailwindcss", "github config", "llm", # "github config"
10
  "deep neural networks", "deep learning", "neural network", # Changed to spaces
11
  "tensorflow", "pytorch", "ml",
12
  "distributed systems", # Changed to spaces
13
 
 
14
  "web development", "mobile development", "game development", "machine learning",
15
  "data science", "artificial intelligence", "devops", "cybersecurity", "blockchain",
16
  "iot", "cloud computing", "big data", "robotics", "bioinformatics", "ar vr", # "ar vr" might be better as "augmented reality", "virtual reality" or keep as is if it's a common tag
17
  "natural language processing", "computer vision", "data visualization",
 
18
  "react", "angular", "vue", "nextjs", "nodejs", "svelte",
19
  "django", "flask", "spring", "dotnet", "ruby on rails", # "ruby on rails"
20
  "android", "ios", "flutter", "react native", # "react native"
 
32
  "assembly", "matlab", "groovy", "julia", "ocaml", "pascal", "fortran", "lisp",
33
  "prolog", "erlang", "f#", "zig", "nim", "crystal", "svelte", "vue" # Svelte/Vue also as languages for their specific file types
34
  ])
 
35
 
36
 
37
+
38
  def find_and_suggest_issues(
39
  selected_language: str | None, # From language dropdown
40
  selected_curated_topics: list[str] | None, # From topics dropdown (multiselect)
 
42
  ):
43
  print(f"Gradio app received language: '{selected_language}', curated_topics: {selected_curated_topics}, custom_topics: '{custom_topics_str}'")
44
 
 
45
  # issues_markdown, llm_suggestion, raw_issues_state,
46
  # dropdown_update, button_update, controls_section_update, display_section_update,
47
  # language_searched_state
 
60
  gr.update(visible=False), gr.update(visible=False),
61
  lang or ""
62
  )
 
63
 
64
  if not selected_language: # Language is now from a dropdown, should always have a value if user interacts
65
  return ("Please select a programming language.", None, None,
 
82
 
83
  final_topics_list = list(final_topics_set) if final_topics_set else None
84
  print(f"Final parsed topics for search: {final_topics_list}")
 
 
 
 
 
85
 
86
  fetched_issues_list = fetch_beginner_issues(
87
  language_to_search,
 
98
  if not fetched_issues_list: # No issues found
99
  return no_issues_found_return_factory(language_to_search, ", ".join(final_topics_list) if final_topics_list else None)
100
 
101
+
 
102
 
103
  issues_display_list = []
104
  issue_titles_for_dropdown = []
105
+ for i, issue in enumerate(fetched_issues_list[:5]):
106
  title = issue.get('title', 'N/A')
107
  issues_display_list.append(
108
  f"{i+1}. **{title}**\n"
 
136
  kit_dropdown_update, kit_button_visibility_update,
137
  kit_controls_section_update, kit_display_section_update,
138
  language_to_search) # Return the searched language for state
 
139
 
 
 
 
140
  def handle_kit_generation(selected_issue_title_with_num: str, current_issues_state: list[dict], language_searched_state: str ):
141
  checklist_update_on_error = gr.update(value=[], visible=False)
142
  if not selected_issue_title_with_num or not current_issues_state:
 
174
 
175
  with gr.Row():
176
  with gr.Column(scale=1): # Input column
 
177
  lang_dropdown_input = gr.Dropdown(
178
  label="Programming Language (*)",
179
  choices=CURATED_LANGUAGE_SLUGS,
180
  value=CURATED_LANGUAGE_SLUGS[CURATED_LANGUAGE_SLUGS.index("python")] if "python" in CURATED_LANGUAGE_SLUGS else CURATED_LANGUAGE_SLUGS[0] if CURATED_LANGUAGE_SLUGS else None, # Default to python or first in list
181
  interactive=True,
 
182
  )
183
+
 
 
184
  curated_topics_dropdown = gr.Dropdown(
185
  label="Select Common Topics (Optional, Multi-Select)",
186
  choices=CURATED_TOPIC_SLUGS,
 
191
  label="Or, Add Custom Topics (Optional, comma-separated slugs)",
192
  placeholder="e.g., my-niche-topic, another-custom-tag"
193
  )
 
194
 
195
  find_button = gr.Button("🔍 Find Beginner Issues", variant="primary")
196
 
 
228
  interactive=True,
229
  visible=False # Starts hidden
230
  )
 
231
 
232
  raw_issues_state = gr.State([])
233
  language_searched_state = gr.State("")
234
 
 
235
  find_button.click(
236
  fn=find_and_suggest_issues,
237
  inputs=[lang_dropdown_input, curated_topics_dropdown, custom_topics_input], # UPDATED
 
242
  language_searched_state
243
  ]
244
  )
 
245
 
246
  generate_kit_button.click(
247
  fn=handle_kit_generation,