@@ -6,6 +6,72 @@ def get_installed_packages():
6
6
return {dist .metadata ["Name" ].lower (): dist .version for dist in distributions ()}
7
7
8
8
9
+ # Kaggle competition packages - based on usage frequency
10
+ PYTHON_BASE_PACKAGES = ["catboost" , "lightgbm" , "numpy" , "optuna" , "pandas" , "scikit-learn" , "scipy" , "shap" , "xgboost" ]
11
+
12
+ PYTHON_ADVANCED_PACKAGES = [
13
+ "accelerate" ,
14
+ "albumentations" ,
15
+ "category_encoders" ,
16
+ "cudf-cu12" ,
17
+ "cuml-cu12" ,
18
+ "datasets" ,
19
+ "featuretools" ,
20
+ "imbalanced-learn" ,
21
+ "opencv-python" ,
22
+ "pillow" ,
23
+ "polars" ,
24
+ "sentence-transformers" ,
25
+ "spacy" ,
26
+ "tensorflow" ,
27
+ "timm" ,
28
+ "tokenizers" ,
29
+ "torch" ,
30
+ "torchvision" ,
31
+ "transformers" ,
32
+ ]
33
+
34
+ PYTHON_AUTO_ML_PACKAGES = ["autogluon" ]
35
+
36
+
37
+ def get_available_packages_prompt ():
38
+ """Generate prompt template for dynamically detected available packages"""
39
+ installed_packages = get_installed_packages ()
40
+
41
+ # Check which packages are actually installed
42
+ base_available = [pkg for pkg in PYTHON_BASE_PACKAGES if pkg .lower () in installed_packages ]
43
+ advanced_available = [pkg for pkg in PYTHON_ADVANCED_PACKAGES if pkg .lower () in installed_packages ]
44
+ automl_available = [pkg for pkg in PYTHON_AUTO_ML_PACKAGES if pkg .lower () in installed_packages ]
45
+
46
+ # Build prompt
47
+ prompt_parts = ["Available packages in environment:\n " ]
48
+
49
+ if base_available :
50
+ prompt_parts .append ("【Basic Libraries】(core tools for most competitions):" )
51
+ prompt_parts .append (f"- { ', ' .join (base_available )} " )
52
+ prompt_parts .append ("" )
53
+
54
+ if advanced_available :
55
+ prompt_parts .append ("【Advanced Tools】(specialized for specific domains):" )
56
+ prompt_parts .append (f"- { ', ' .join (advanced_available )} " )
57
+ prompt_parts .append ("" )
58
+
59
+ if automl_available :
60
+ prompt_parts .append ("【AutoML Tools】(automated machine learning):" )
61
+ prompt_parts .append (f"- { ', ' .join (automl_available )} " )
62
+ prompt_parts .append ("" )
63
+
64
+ prompt_parts .append ("Choose appropriate tool combinations based on the competition type." )
65
+
66
+ return "\n " .join (prompt_parts ).strip ()
67
+
68
+
69
+ def get_all_available_packages ():
70
+ """Get flattened list of all packages"""
71
+ all_packages = PYTHON_BASE_PACKAGES + PYTHON_ADVANCED_PACKAGES + PYTHON_AUTO_ML_PACKAGES
72
+ return sorted (set (all_packages ))
73
+
74
+
9
75
def print_filtered_packages (installed_packages , filtered_packages ):
10
76
to_print = []
11
77
for package_name in filtered_packages :
@@ -26,24 +92,8 @@ def get_python_packages():
26
92
# Example: `python package_info.py pandas torch scikit-learn`
27
93
# If no extra arguments are provided we fall back to the original default list
28
94
# to keep full backward-compatibility.
29
- packages_list = [ # default packages
30
- "transformers" ,
31
- "accelerate" ,
32
- "torch" ,
33
- "tensorflow" ,
34
- "pandas" ,
35
- "numpy" ,
36
- "scikit-learn" ,
37
- "scipy" ,
38
- "xgboost" ,
39
- "sklearn" ,
40
- "lightgbm" ,
41
- "vtk" ,
42
- "opencv-python" ,
43
- "keras" ,
44
- "matplotlib" ,
45
- "pydicom" ,
46
- ]
95
+ # Use our Kaggle-optimized package list as default
96
+ packages_list = get_all_available_packages ()
47
97
if len (sys .argv ) > 1 :
48
98
packages_list = list (set (packages_list ) | set (sys .argv [1 :]))
49
99
@@ -61,4 +111,8 @@ def get_python_packages():
61
111
62
112
63
113
if __name__ == "__main__" :
64
- get_python_packages ()
114
+ # Check for special argument to get prompt instead of package list
115
+ if len (sys .argv ) > 1 and sys .argv [1 ] == "--prompt" :
116
+ print (get_available_packages_prompt ())
117
+ else :
118
+ get_python_packages ()
0 commit comments