File size: 1,944 Bytes
b8ef5a5
879b3b3
 
 
fe634be
879b3b3
 
 
 
 
 
 
 
 
 
 
 
 
ba50c04
879b3b3
fe634be
879b3b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b8ef5a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import streamlit as st
from library_summarizer import llm_lib_summarizer_v1
from command_generator import llm_lib_installer_v1

st.title("📂 Compatible Library Version Generator")

imported_libraries = st.text_area("Enter the libraries you are importing in your ipynb file:", height=200)
api_key = st.text_input("Enter your Groq API Key:", type="password")
task = st.text_input("Enter the task you are working on (e.g., data analysis, machine learning):", value="Basic ML task")
python_version = st.selectbox("Select your Python version:", options=["3.7", "3.8", "3.9", "3.10", "3.11","3.12"], index=3)

# File uploader widget
uploaded_file = st.file_uploader("Choose a file", type=["txt"])

if uploaded_file is not None:
    st.success(f"File uploaded: {uploaded_file.name}")

    # Read the file (decode for text files)
    libraries = uploaded_file.read().decode("utf-8")
    
if st.button("Generate pip command"):
    if imported_libraries and uploaded_file:
        library = imported_libraries
        libraries = uploaded_file.read().decode("utf-8")
        with st.spinner("Summarizing imported libraries"):
            try:
                summary = llm_lib_summarizer_v1(import_string=library, api_key=api_key)
                st.subheader("Summary of Libraries:")
                st.code(summary)

            except Exception as e:
                st.error(f"An error occurred: {e}")
                
        with st.spinner("Generating ideal pip install command..."):    
            try:
                st.subheader(f"Generated pip install command for python version {python_version}")
                command = llm_lib_installer_v1(imported_libs=summary, python_version=python_version, task=task, api_key=api_key, libraries=libraries)
                st.markdown(command)
            except Exception as e:
                st.error(f"An error occurred: {e}")
    else:
        st.error("Please enter text or upload a file.")