Spaces:
Build error
Build error
SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files5 unmodified lines6789910111217 unmodified lines303132333433343536373 unmodified lines41424344444546479 unmodified lines57585960605 unmodified lines# Load the model using Accelerate for memory optimization@st.cache_resource()def load_model(): MODEL_NAME = "codellama/CodeLlama-7b-hf" # Model name MODEL_NAME = "huggingface/CodeGen-2B" # Updated model name tokenizer = 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")st.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 lines if prompt.strip(): st.info("Generating code... Please wait ⏳") try: # Generate code using the CodeLlama model # Generate code using the CodeGen-2B model response = code_generator( prompt, max_length=512, # Increase for longer code generation9 unmodified lines else: st.warning("Please enter a prompt.")
st.caption("Powered by CodeLlama-7B | Streamlit UI | CPU Optimized")st.caption("Created by Shamil")app.py+5-5