mohith96 commited on
Commit
6b8e0d3
·
verified ·
1 Parent(s): 0dadcd6

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +26 -21
src/streamlit_app.py CHANGED
@@ -10,28 +10,33 @@ task = st.text_input("Enter the task you are working on (e.g., data analysis, ma
10
  python_version = st.selectbox("Select your Python version:", options=["3.7", "3.8", "3.9", "3.10", "3.11","3.12"], index=3)
11
 
12
  # File uploader widget
13
- with open('libraries.txt','r') as f:
14
- libraries = f.read()
 
 
 
 
15
 
16
- if st.button("Generate pip command"):
17
- if imported_libraries:
18
- library = imported_libraries
19
- with st.spinner("Summarizing imported libraries"):
20
- try:
21
- summary = llm_lib_summarizer_v1(import_string=library, api_key=api_key)
22
- st.subheader("Summary of Libraries:")
23
- st.code(summary)
 
24
 
25
- except Exception as e:
26
- st.error(f"An error occurred: {e}")
27
 
28
- with st.spinner("Generating ideal pip install command..."):
29
- try:
30
- st.subheader(f"Generated pip install command for python version {python_version}")
31
- command = llm_lib_installer_v1(imported_libs=summary, python_version=python_version, task=task, api_key=api_key, libraries=libraries)
32
- st.markdown(command)
33
- except Exception as e:
34
- st.error(f"An error occurred: {e}")
35
- else:
36
- st.error("Please enter the libraries you imported in the colab notebook.")
37
 
 
10
  python_version = st.selectbox("Select your Python version:", options=["3.7", "3.8", "3.9", "3.10", "3.11","3.12"], index=3)
11
 
12
  # File uploader widget
13
+ uploaded_file = st.file_uploader("Choose a file", type=["txt"])
14
+
15
+ if uploaded_file is not None:
16
+ st.success(f"File uploaded: {uploaded_file.name}")
17
+
18
+ libraries = uploaded_file.read().decode('utf-8')
19
 
20
+ if st.button("Generate pip command"):
21
+ if imported_libraries and uploaded_file:
22
+ library = imported_libraries
23
+ libraries = uploaded_file.read().decode('utf-8')
24
+ with st.spinner("Summarizing imported libraries"):
25
+ try:
26
+ summary = llm_lib_summarizer_v1(import_string=library, api_key=api_key)
27
+ st.subheader("Summary of Libraries:")
28
+ st.code(summary)
29
 
30
+ except Exception as e:
31
+ st.error(f"An error occurred: {e}")
32
 
33
+ with st.spinner("Generating ideal pip install command..."):
34
+ try:
35
+ st.subheader(f"Generated pip install command for python version {python_version}")
36
+ command = llm_lib_installer_v1(imported_libs=summary, python_version=python_version, task=task, api_key=api_key, libraries=libraries)
37
+ st.markdown(command)
38
+ except Exception as e:
39
+ st.error(f"An error occurred: {e}")
40
+ else:
41
+ st.error("Please enter the libraries you imported in the colab notebook.")
42