chaos4455 commited on
Commit
3fbd71c
ยท
verified ยท
1 Parent(s): 4d822ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +143 -156
app.py CHANGED
@@ -1,15 +1,14 @@
1
  import streamlit as st
2
  import google.generativeai as genai
3
  import re
4
- import datetime
5
  import os
6
- import yaml
7
 
8
  # Secret key and Google Gemini API configuration
9
  API_KEY = st.secrets["GOOGLE_API_KEY"]
10
 
11
  # Page configuration
12
- st.set_page_config(page_title="โš™๏ธ Gemini2 Puppet Bolt Gen Pro", page_icon="โš™๏ธ", layout="wide")
13
 
14
  # --- Helper Functions ---
15
  def send_message_to_model(message, model_name, temperature, top_p, top_k, max_tokens):
@@ -34,92 +33,82 @@ def send_message_to_model(message, model_name, temperature, top_p, top_k, max_to
34
  st.error(f"โŒ Error communicating with the AI: {e}")
35
  return None
36
 
37
- def generate_puppet_bolt_plan(prompt_base, detail_level, os_type, security_level, model_name, temperature, top_p, top_k, max_tokens, prompt_detail, encoding, add_header, log_level, bolt_user, bolt_ssh_pass, custom_requirements, specific_details, target_nodes_description, task_type, task_code, parameters_description):
38
- """Generates a Puppet Bolt plan based on user settings."""
39
  prompt = f"""
40
- You are an expert automation engineer specializing in Puppet Bolt. Your task is to generate a complete, secure, and efficient Puppet Bolt plan based on the following description:
41
-
42
- **Goal:** Create the most complete, detailed, efficient, and secure Puppet Bolt plan possible, considering all variables, edge cases, and potential scenarios.
43
-
44
- **Plan Description:** {prompt_base}
45
-
46
- **Detail Level:** {detail_level}
47
- **Security Level:** {security_level}
48
- **Prompt Detail Level**:{prompt_detail}
49
- **Operating System:** {os_type}
50
- **Target Nodes:** {target_nodes_description if target_nodes_description else "None"}
51
- **Bolt User:** {bolt_user if bolt_user else "root"}
52
- **Bolt SSH Password:** {bolt_ssh_pass if bolt_ssh_pass else "None"}
53
- **Parameters:** {parameters_description if parameters_description else "None"}
54
- **Custom Requirements:** {custom_requirements if custom_requirements else "None"}
55
- **Specific Details:** {specific_details if specific_details else "None"}
56
- **Task Type:** {task_type}
57
- **Task Code:** {task_code if task_code else "None"}
58
-
59
- **Response Format:**
60
- - Respond in Markdown format, including a YAML code block with its original formatting, without line breaks.
61
- - The YAML code block must be delimited by ```yaml and ```.
62
- - Do not include comments, explanations, or any other text outside the code block, unless the prompt requires.
63
- - The code must maintain its full vertical formatting, respecting indentation and line breaks.
64
- - The code must be realistic, using real-world examples, data, and situations.
65
- - The plan must use advanced Bolt resources, such as tasks, parameters, variables, functions, conditionals, loops and targets when necessary.
66
- -The plan must use the `run_task` function to execute the tasks.
67
- -The plan must use a valid node target.
68
- - Explore different approaches, techniques, and advanced practices, always prioritizing security and efficiency.
69
- - The plan must use native Bolt functions and modules instead of others.
70
- - Unless the user specifies otherwise, use the most current and secure versions of the modules, using bolt and following best practices.
71
- - If the description asks to create a file, the plan should create the file directly in the file system and not use a screen output for this.
72
- - If the description asks to read a file, the plan should read the file directly from the file system and not use a screen input for this.
73
- - Use incremental reasoning to add improvements, expansions, and considerations to your code.
74
- - Use the history of the conversations so that the response is incremental.
75
-
76
- **Log Level**:{log_level}
77
-
78
- **Important:**
79
- - Generate only one plan at a time.
80
- - Create the longest, most complete, and detailed code possible to cover a wide range of possibilities and scenarios.
81
- - Consider all the details of the request, expanding the response and improving the configuration.
82
- - If the prompt does not include parameters, but if the user add a variable in a code block, create a task parameter to use that variable.
83
- - If the prompt includes parameters, create a task parameter to use that parameters.
84
- """
85
  response = send_message_to_model(prompt, model_name, temperature, top_p, top_k, max_tokens)
86
  return response
87
 
88
- def parse_and_save_yml(ai_code, short_title, encoding, add_header):
89
- """Parses the markdown and saves the Puppet Bolt plan as .yml."""
90
- match = re.search(r'```yaml\s*(.*?)\s*```', ai_code, re.DOTALL | re.IGNORECASE)
91
- if match:
92
- yml_code = match.group(1).strip()
93
- else:
94
- yml_code = ai_code.strip()
95
-
96
- try:
97
- yaml.safe_load(yml_code)
98
- except yaml.YAMLError as e:
99
- st.error(f"โŒ Generated YAML is invalid: {e}")
100
- return None, None
 
 
 
 
 
101
 
 
 
102
 
103
- file_name = f"bolt_{short_title}.yml"
104
-
105
- if add_header:
106
- current_date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
107
- header = f"""#===============================================================================
108
- # Puppet Bolt Plan Generated by Google Gemini 2 Bolt Gen Pro
109
- # Date: {current_date}
110
- # Author: Elias Andrade AKA Chaos4455
111
- #===============================================================================\n"""
112
- yml_code = header + yml_code
113
-
114
- with open(file_name, "w", encoding=encoding) as f:
115
- f.write(yml_code)
116
-
117
- return file_name, yml_code
118
 
119
 
120
  def main():
121
- st.title("โš™๏ธ Gemini2 Puppet Bolt Gen Pro by [Elias Andrade](https://github.com/chaos4455)")
122
- st.markdown("Generate advanced Puppet Bolt plans with ease! ๐Ÿš€")
123
  st.markdown("---")
124
 
125
  # Layout in columns (sidebar and main area)
@@ -135,96 +124,94 @@ def main():
135
  top_k = st.slider("Top K", min_value=1, max_value=100, value=40, step=1, help="Adjust the AI's number of candidate tokens.")
136
  max_tokens = st.number_input("๐Ÿ“ Max Tokens", min_value=128, max_value=8192, value=8192, step=128, help="Adjust the maximum size of the response.")
137
 
138
- with st.expander("๐Ÿ“ Prompt Settings"):
139
- prompt_presets = st.selectbox("๐ŸŽฏ Predefined Prompts", ["None", "Install packages", "Run commands", "Manage services", "Manage files", "System Updates", "Copy Files"], index=0, help="Choose a predefined prompt.")
140
- prompt_detail = st.selectbox("๐Ÿง Prompt Detail", ["More descriptive", "Default", "Concise"], index=1, help="Defines the level of detail of the prompt")
141
-
142
- with st.expander("โš™๏ธ Puppet Bolt Settings"):
143
- os_type = st.selectbox(
144
- "๐Ÿ’ป Operating System",
145
- [
146
- "Linux", "Windows", "Other"
147
- ],
148
- index=0, help="Choose the target operating system."
149
- )
150
-
151
- bolt_user = st.text_input("๐Ÿ‘ค Bolt User", value="root", help="User for Bolt SSH connection")
152
- bolt_ssh_pass = st.text_input("๐Ÿ”‘ Bolt SSH Password", type="password", help="Password for Bolt SSH connection (Use with caution)")
153
-
154
- encoding = st.selectbox("๐Ÿ”ค Encoding", ["utf-8", "ansi"], index=0, help="Choose the encoding of the .yml file.")
155
- add_header = st.checkbox("๐Ÿ“œ Add Header", value=True, help="Add a header with information in the .yml file.")
156
- log_level = st.selectbox("๐Ÿ—‚๏ธ Logging Level", ["Detailed", "Default", "Minimum"], index=1, help="Defines the detail level of logs.")
157
- security_level = st.radio("Security Level", ["High", "Medium", "Low"], index=1)
158
- custom_requirements = st.text_input("Custom Requirements", placeholder="Ex: Use specific modules, parameters", help="Add specific requirements for the generated plan.")
159
- specific_details = st.text_input("Specific Details", placeholder="Ex: Specific configurations, edge cases", help="Add specific details for plan generation.")
160
-
161
- detail_level = st.selectbox("Detail Level", ["More detailed", "Default", "More concise"], index=1)
162
-
163
- with st.expander("๐Ÿ”จ Task Settings"):
164
- task_type = st.selectbox("๐ŸŽฏ Task Type", ["command", "script", "puppet"], index = 0, help="Type of task")
165
- task_code = st.text_area("๐Ÿ“‹ Task Code", placeholder="Command or Code for the task", help="Enter your command, script or Puppet code")
166
- parameters_description = st.text_input("๐Ÿงฐ Parameters Description", placeholder="List of parameters for the task", help="Enter the parameters needed for this task")
 
 
 
 
 
 
 
 
 
 
 
167
 
168
  with col2:
169
- # User's base prompt
170
- prompt_base = st.text_input("Describe the Puppet Bolt Plan:", placeholder="Ex: Execute a command to check disk space on all Linux servers, and save the output on /tmp/output.txt", key="prompt_base")
171
- target_nodes_description = st.text_input("Target Nodes Description (text format, IP(s), Range or CIDR):", placeholder="Ex: all servers in the 192.168.0.0/24 network",key="target_nodes")
172
-
173
- if prompt_presets != "None":
174
- if prompt_base:
175
- prompt_base = f"{prompt_presets} , {prompt_base}"
176
- else:
177
- prompt_base = prompt_presets;
178
- if st.button("โœจ Generate Puppet Bolt Plan"):
179
- if not prompt_base:
180
- st.error("โš ๏ธ Please enter a plan description.")
181
  return
182
-
183
- if task_type != "command" and not task_code:
184
- st.error("โš ๏ธ Please enter the code for the task.")
185
- return
186
-
187
- with st.spinner("โณ Generating plan..."):
188
- ai_code = generate_puppet_bolt_plan(
189
- prompt_base,
190
- detail_level,
191
- os_type,
192
- security_level,
193
  model_name,
194
  temperature,
195
  top_p,
196
  top_k,
197
  max_tokens,
198
- prompt_detail,
199
- encoding,
200
- add_header,
201
- log_level,
202
- bolt_user,
203
- bolt_ssh_pass,
204
  custom_requirements,
205
  specific_details,
206
- target_nodes_description,
207
- task_type,
208
- task_code,
209
- parameters_description
210
  )
211
 
212
  if ai_code:
213
- st.markdown("### โœ… Generated Plan:")
214
- st.code(ai_code, language="yaml")
215
-
216
- short_title = prompt_base[:30].strip().replace(" ", "_").lower()
217
- file_name_yml, yml_code = parse_and_save_yml(ai_code, short_title, encoding, add_header)
218
-
219
- if file_name_yml and yml_code: #check if the file was generated
220
- st.download_button(
221
- label="โฌ‡๏ธ Download Plan (.yml)",
222
- data=yml_code,
223
- file_name=file_name_yml,
224
- mime="application/x-yaml",
225
- )
 
226
  else:
227
- st.error("โŒ Error generating the plan. Check the connection with the AI and try again.")
 
228
 
229
  if __name__ == "__main__":
230
  main()
 
1
  import streamlit as st
2
  import google.generativeai as genai
3
  import re
 
4
  import os
5
+ import platform
6
 
7
  # Secret key and Google Gemini API configuration
8
  API_KEY = st.secrets["GOOGLE_API_KEY"]
9
 
10
  # Page configuration
11
+ st.set_page_config(page_title="๐Ÿโœจ Gemini2 Pip Gen Pro", page_icon="๐Ÿโœจ", layout="wide")
12
 
13
  # --- Helper Functions ---
14
  def send_message_to_model(message, model_name, temperature, top_p, top_k, max_tokens):
 
33
  st.error(f"โŒ Error communicating with the AI: {e}")
34
  return None
35
 
36
+ def generate_pip_command(prompt_base, model_name, temperature, top_p, top_k, max_tokens, selected_libraries, selected_groups, custom_requirements, specific_details, pip_options, target_os):
37
+ """Generates a pip command based on user settings."""
38
  prompt = f"""
39
+ You are an expert Python development assistant. Your task is to generate a complete and efficient pip command based on the following description:
40
+
41
+ **Goal:** Create the most complete, detailed, and efficient pip install command possible, considering all variables, edge cases, and potential scenarios.
42
+
43
+ **Target Operating System:** {target_os}
44
+
45
+ **Command Description:** {prompt_base}
46
+
47
+ **Selected Libraries:** {selected_libraries if selected_libraries else "None"}
48
+ **Selected Groups:** {selected_groups if selected_groups else "None"}
49
+ **Custom Requirements:** {custom_requirements if custom_requirements else "None"}
50
+ **Specific Details:** {specific_details if specific_details else "None"}
51
+ **Pip Options:** {pip_options if pip_options else "None"}
52
+
53
+ **Response Format:**
54
+ - Respond in Markdown format, including a pip command code block, a bash code block and powershell code block with its original formatting, without line breaks.
55
+ - The pip command code block must be delimited by ```pip and ```.
56
+ - The bash code block must be delimited by ```bash and ```.
57
+ - The powershell code block must be delimited by ```powershell and ```.
58
+ - Do not include comments, explanations, or any other text outside the code block.
59
+ - The code must maintain its full vertical formatting, respecting indentation and line breaks.
60
+ - Explore different approaches, techniques, and advanced practices, always prioritizing security and efficiency.
61
+ - Use advanced pip resources such as version constraints, index options, and requirements files when necessary.
62
+ - If a specific version of a library is specified, use it.
63
+ - Unless the user specifies otherwise, use the most current versions of the libraries and pip, using and following best practices.
64
+ - Use incremental reasoning to add improvements, expansions, and considerations to your code.
65
+ - Use the history of the conversations so that the response is incremental.
66
+ - If the target OS is Windows, use pip commands compatible with Windows, and if the target OS is Linux, use pip commands compatible with Linux
67
+
68
+ **Important:**
69
+ - Generate only one command at a time.
70
+ - Create the longest, most complete, and detailed command possible to cover a wide range of possibilities and scenarios.
71
+ - Consider all the details of the request, expanding the response and improving the command.
72
+ - If the prompt asks to install a library that is not in a given group, install it in the command, but include in the prompt that library is not in the selected groups.
73
+ - If a version of a library is specified, install it using a version constraint.
74
+ - Consider if the user needs a requirements.txt file or not and if needed use it in your command.
75
+ """
76
+
 
 
 
 
 
 
 
77
  response = send_message_to_model(prompt, model_name, temperature, top_p, top_k, max_tokens)
78
  return response
79
 
80
+ def parse_and_save_code(ai_code, short_title):
81
+ """Parses the markdown and saves the code."""
82
+ pip_match = re.search(r'```pip\s*(.*?)\s*```', ai_code, re.DOTALL | re.IGNORECASE)
83
+ bash_match = re.search(r'```bash\s*(.*?)\s*```', ai_code, re.DOTALL | re.IGNORECASE)
84
+ ps1_match = re.search(r'```powershell\s*(.*?)\s*```', ai_code, re.DOTALL | re.IGNORECASE)
85
+
86
+ pip_code = pip_match.group(1).strip() if pip_match else ai_code.strip()
87
+ bash_code = bash_match.group(1).strip() if bash_match else None
88
+ ps1_code = ps1_match.group(1).strip() if ps1_match else None
89
+
90
+ base_file_name = f"pip_command_{short_title}"
91
+
92
+ files = {}
93
+
94
+ files["pip"]= {"name":f"{base_file_name}.txt", "code":pip_code}
95
+
96
+ if bash_code:
97
+ files["bash"]= {"name":f"{base_file_name}.sh", "code":bash_code}
98
 
99
+ if ps1_code:
100
+ files["powershell"]= {"name":f"{base_file_name}.ps1", "code":ps1_code}
101
 
102
+ for key, value in files.items():
103
+ with open(value["name"], "w") as f:
104
+ f.write(value["code"])
105
+
106
+ return files
 
 
 
 
 
 
 
 
 
 
107
 
108
 
109
  def main():
110
+ st.title("๐Ÿโœจ Gemini2 Pip Gen Pro by [Elias Andrade](https://github.com/chaos4455)")
111
+ st.markdown("Generate advanced pip install commands with ease! ๐Ÿš€")
112
  st.markdown("---")
113
 
114
  # Layout in columns (sidebar and main area)
 
124
  top_k = st.slider("Top K", min_value=1, max_value=100, value=40, step=1, help="Adjust the AI's number of candidate tokens.")
125
  max_tokens = st.number_input("๐Ÿ“ Max Tokens", min_value=128, max_value=8192, value=8192, step=128, help="Adjust the maximum size of the response.")
126
 
127
+ with st.expander("๐Ÿ“ Libraries & Groups"):
128
+ available_libraries = {
129
+ "๐Ÿ“Š Data Analysis": ["pandas", "numpy", "scipy", "matplotlib", "seaborn", "plotly", "bokeh", "statsmodels", "scikit-image", "geopandas", "altair", "holoviews", "datashader", "missingno", "vaex", "dask", "xarray", "polars", "arrow", "numba", "cudf", "cupy", "streamz", "panel", "hvplot"],
130
+ "๐Ÿง  Machine Learning": ["scikit-learn", "tensorflow", "torch", "keras", "xgboost", "lightgbm", "catboost", "pytorch-lightning", "transformers", "optuna", "mlflow", "gradio", "huggingface-hub", "sentence-transformers", "fastai", "librosa", "gensim", "spacy", "nltk", "opencv-python", "imbalanced-learn", "sktime", "umap-learn", "fairlearn", "shap", "eli5", "snorkel", "thinc"],
131
+ "๐Ÿ•ธ๏ธ Web Development": ["flask", "fastapi", "django", "requests", "beautifulsoup4", "aiohttp", "uvicorn", "gunicorn", "jinja2", "starlette", "websockets", "flask-restful", "django-rest-framework", "scrapy", "selenium", "playwright", "httpx", "rich", "pyramid", "bottle", "tornado", "dash", "plotly-dash", "streamlit", "gradio"],
132
+ "๐Ÿ—„๏ธ Database": ["sqlalchemy", "psycopg2", "pymongo", "mysql-connector-python", "sqlite3", "redis", "cassandra-driver", "pyodbc", "aiosqlite", "kafka-python", "motor", "neo4j", "influxdb", "elasticsearch", "pyarrow", "clickhouse-driver", "arangodb", "couchbase", "dgraph-python", "tinydb", "dataset"],
133
+ "โ˜๏ธ Cloud": ["boto3", "google-cloud-storage", "azure-storage-blob", "kubernetes", "docker", "apache-libcloud", "pulumi", "awscli", "google-cloud-sdk", "azure-cli", "terraform", "openstack", "ansible", "salt", "chef", "cdktf", "serverless", "aws-cdk", "google-cloud-build", "azure-pipelines", "docker-compose", "moto", "localstack"],
134
+ "๐Ÿค– IA & LLM": ["langchain", "openai", "diffusers", "sentence-transformers", "stable-diffusion", "huggingface-hub", "pyannote-audio", "whisper", "nltk", "spacy", "transformers", "accelerate", "datasets", "einops", "faiss-cpu", "bitsandbytes", "peft", "trl", "haystack", "llama-index", "deepsparse", "nanogpt", "autogpt", "babyagi","ml-agents", "tensorboardx"],
135
+ "๐Ÿ› ๏ธ Dev Tools": ["pytest", "flake8", "mypy", "black", "isort", "pylint", "tox", "pre-commit", "bandit", "coverage", "virtualenv", "pipenv", "poetry", "invoke", "nox", "twine", "wheel", "setuptools", "build", "debugpy", "pyinstrument", "memory-profiler", "cProfile", "pdbpp", "ipython"],
136
+ "โš™๏ธ Data Engineering": ["apache-airflow", "dask", "luigi", "pyspark", "ray", "prefect", "dbt-core", "pandas-gbq", "petl", "sqlalchemy-redshift", "fugue", "ibis-framework", "mindsdb", "koalas", "vaex-core", "feast", "flink", "beam", "kafka-python", "clickhouse-driver", "superset", "metabase", "trino"],
137
+ "๐ŸŒ Networking": ["requests", "httpx", "socketio", "paramiko", "netmiko", "scapy", "dnspython", "asyncssh", "tqdm", "gevent", "websocket-client", "pyserial", "grpcio", "aiozmq", "uvloop", "aiofiles", "urllib3", "fastsocket", "twisted", "aiohttp-socks", "aioredis", "websockets"],
138
+ "๐Ÿ”’ Security": ["cryptography", "pyjwt", "requests-oauthlib", "paramiko", "pyOpenSSL", "passlib", "hashlib", "bcrypt", "python-nmap", "sqlmap", "scapy", "yara-python", "pwn", "mitmproxy", "themis", "pycryptodome", "tpm2-py", "pyspy", "volatility3", "pefile", "dpkt"],
139
+ "๐ŸŽจ GUI": ["tkinter", "pyqt5", "kivy", "wxpython", "pygame", "dearpygui", "pyglet", "flet", "toga", "eel", "qt-material", "pyside6", "pywebview", "guizero", "remif", "taipy"],
140
+ "๐Ÿงช Testing": ["unittest", "pytest-cov", "hypothesis", "behave", "locust", "nose", "selenium", "playwright", "mock", "freezegun", "ddt", "tox", "robotframework", "hypothesis", "vcrpy", "responses", "faker", "factory-boy", "coveragepy", "parameterized"],
141
+ "๐Ÿงฐ Utilities": ["click", "typer", "argparse", "rich", "tqdm", "colorama", "schedule", "python-dotenv", "shutil", "pathlib", "arrow", "toml", "json5", "xmltodict", "humanize", "pendulum", "inflect", "unidecode", "boltons", "delegator.py"],
142
+ "๐Ÿ“š Documentation": ["sphinx", "mkdocs", "pdoc", "readthedocs-sphinx-search", "numpydoc", "docutils", "recommonmark", "sphinx-rtd-theme", "furo", "m2r2", "autoapi", "plantuml", "pycco", "doc8", "griffe", "mistletoe", "marko"],
143
+ "๐ŸŽฎ Game Dev": ["pygame", "pyglet", "arcade", "panda3d", "ursina", "cocos2d", "renpy", "pyopengl", "cymunk", "pytmx", "pybox2d", "pymunk", "moderngl", "glumpy", "glfw", "sdl2"],
144
+ "๐Ÿ’น Finance": ["numpy-financial", "pandas-datareader", "scikit-portfolio", "yfinance", "finmarketpy", "quantstats", "TA-Lib", "riskfolio-optimization", "alphalens", "pyfolio", "zipline", "backtrader", "quantlib-python", "pyfin", "quandl", "vnpy"],
145
+ "๐Ÿค– Robotics": ["rospy", "pybullet", "mujoco-py", "open3d", "numpy-stl", "pyserial", "opencv-python", "pymavlink", "robotframework", "webots", "vpython", "transforms3d", "trimesh", "pyrealsense2", "aiortc", "gymnasium", "stable-baselines3"],
146
+ "๐Ÿงฌ Bioinformatics": ["biopython", "scikit-bio", "pysam", "pandas-genomics", "statsmodels", "pybedtools", "matplotlib", "seaborn", "pyteomics", "networkx", "pyfaidx", "lifelines", "ngslib", "bcbio-nextgen", "scanpy", "anndata", "gseapy", "deepchem", "methylpy"],
147
+ "๐Ÿ”ญ Astronomy": ["astropy", "astroquery", "scikit-image", "photutils", "pyephem", "poliastro", "pyvista", "vtk", "healpy", "astroplan", "specutils", "sunpy", "gwpy", "lhorizon", "dustmaps", "reproject", "pymc3", "celerite"],
148
+ "๐Ÿ—บ๏ธ Geospatial": ["geopandas", "rasterio", "shapely", "pyproj", "fiona", "cartopy", "folium", "geopy", "earthpy", "descartes", "osmnx", "geohash", "momepy", "pyvista", "whitebox", "earthengine-api", "gisalchemist", "mapclassify", "spatialpandas"],
149
+ "๐Ÿ’ก IoT": ["pyserial", "paho-mqtt", "RPi.GPIO", "smbus2", "pysnmp", "can-utils", "zeroconf", "asyncio", "bluepy", "adafruit-circuitpython", "iotconnect", "thinger-io", "micropython", "homeassistant", "openhab", "tasmota", "esphome", "nodemcu"],
150
+ "๐Ÿ’ป System": ["psutil", "subprocess32", "watchdog", "inotify", "pywin32", "sh", "delegator.py", "appdirs", "click", "typer", "pathlib", "colorama", "fire", "daemonize", "lsof", "ruamel.yaml", "py-cpuinfo", "platformdirs"]
151
+ }
152
+
153
+ selected_libraries = {}
154
+ for group, libraries in available_libraries.items():
155
+ selected_libraries[group] = st.multiselect(f"{group} ", libraries, default=[],key=f"lib_{group}")
156
+
157
+ selected_groups = st.multiselect("๐Ÿ—‚๏ธ Groups", list(available_libraries.keys()), default=[], help="Choose groups to include libraries.")
158
+
159
+
160
+ with st.expander("โš™๏ธ Pip Settings"):
161
+ custom_requirements = st.text_input("โž• Custom Libraries:", placeholder="Specific libraries or versions (e.g., requests==2.28.1, numpy>=1.23.0)", help="List specific libraries and versions.")
162
+ specific_details = st.text_input("โ„น๏ธ Specific Details", placeholder="Special pip install options, edge cases", help="Add specific details for the pip command generation.")
163
+ pip_options = st.text_input("โš™๏ธ Pip Options", placeholder="Add custom pip options like --index-url or --no-cache", help="Add custom options to your pip command")
164
+ target_os = st.selectbox("๐ŸŽฏ Target OS", ["Linux ๐Ÿง", "Windows ๐ŸชŸ"], index=0, help="Choose the target Operating System.")
165
+
166
+
167
 
168
  with col2:
169
+ # User's base prompt
170
+ prompt_base = st.text_input("๐Ÿ“ Describe the Pip Command:", placeholder="Ex: Install all libraries for web development and data analysis", key="prompt_base")
171
+
172
+ if st.button("โœจ Generate Pip Command"):
173
+ if not prompt_base and not selected_libraries and not selected_groups and not custom_requirements:
174
+ st.error("โš ๏ธ Please enter a command description or select libraries/groups")
 
 
 
 
 
 
175
  return
176
+
177
+ selected_libs = []
178
+ for group in selected_groups:
179
+ selected_libs.extend(selected_libraries[group])
180
+
181
+ with st.spinner("โณ Generating command..."):
182
+ ai_code = generate_pip_command(
183
+ prompt_base,
 
 
 
184
  model_name,
185
  temperature,
186
  top_p,
187
  top_k,
188
  max_tokens,
189
+ selected_libs,
190
+ selected_groups,
 
 
 
 
191
  custom_requirements,
192
  specific_details,
193
+ pip_options,
194
+ target_os
 
 
195
  )
196
 
197
  if ai_code:
198
+ st.markdown("### โœ… Generated Command:")
199
+ st.code(ai_code, language="text") #to output all codes
200
+
201
+ short_title = prompt_base[:30].strip().replace(" ", "_").lower()
202
+ files = parse_and_save_code(ai_code, short_title)
203
+
204
+ for key, value in files.items():
205
+ st.download_button(
206
+ label=f"โฌ‡๏ธ Download Command (.{(key)})",
207
+ data=value["code"],
208
+ file_name=value["name"],
209
+ mime="text/plain",
210
+ )
211
+
212
  else:
213
+ st.error("โŒ Error generating the command. Check the connection with the AI and try again.")
214
+
215
 
216
  if __name__ == "__main__":
217
  main()