Spaces:
Build error
Build error
SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files5 unmodified lines678910111217 unmodified lines30313233343536373 unmodified lines414243444546479 unmodified lines575859605 unmodified lines# Load the model using Accelerate for memory optimization@st.cache_resource()def load_model():MODEL_NAME = "codellama/CodeLlama-7b-hf" # Model nametokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)# Load model with accelerate to optimize for memory usage17 unmodified linescode_generator = load_model()# Streamlit UIst.title("CodeLlama-7B Code Bot 🚀")st.subheader("Generate code snippets using CodeLlama-7b-hf optimized for CPU")# User inputprompt = st.text_area("Enter a coding prompt (e.g., 'Write a Python function to sort a list'): ")3 unmodified linesif prompt.strip():st.info("Generating code... Please wait ⏳")try:# Generate code using the CodeLlama modelresponse = code_generator(prompt,max_length=512, # Increase for longer code generation9 unmodified lineselse:st.warning("Please enter a prompt.")st.caption("Powered by CodeLlama-7B | Streamlit UI | CPU Optimized")5 unmodified lines678910111217 unmodified lines30313233343536373 unmodified lines414243444546479 unmodified lines575859605 unmodified lines# Load the model using Accelerate for memory optimization@st.cache_resource()def load_model():MODEL_NAME = "huggingface/CodeGen-2B" # Updated model nametokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)# Load model with accelerate to optimize for memory usage17 unmodified linescode_generator = load_model()# Streamlit UIst.title("CodeGen-2B Code Bot 🚀")st.subheader("Generate code snippets using Hugging Face CodeGen-2B")# User inputprompt = st.text_area("Enter a coding prompt (e.g., 'Write a Python function to sort a list'): ")3 unmodified linesif prompt.strip():st.info("Generating code... Please wait ⏳")try:# Generate code using the CodeGen-2B modelresponse = code_generator(prompt,max_length=512, # Increase for longer code generation9 unmodified lineselse:st.warning("Please enter a prompt.")st.caption("Created by Shamil")
app.py+5-5