Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,16 +30,16 @@ st.header("Ask Me Any Coding Question!")
|
|
| 30 |
|
| 31 |
# Load model and tokenizer (either from local directory or Hugging Face Hub)
|
| 32 |
model_name = repo_name # Use the repo name if the model is on Hugging Face Hub, else use local dir
|
|
|
|
| 33 |
|
| 34 |
-
# Check if the model is uploaded to Hugging Face Hub
|
| 35 |
if os.path.exists(model_dir):
|
| 36 |
-
# Load the model and tokenizer from local directory
|
| 37 |
-
model = AutoModelForCausalLM.from_pretrained(model_dir,
|
| 38 |
-
tokenizer = AutoTokenizer.from_pretrained(model_dir)
|
| 39 |
else:
|
| 40 |
-
# Load the model from Hugging Face Hub
|
| 41 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 42 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 43 |
|
| 44 |
# User input: Coding question
|
| 45 |
question = st.text_input("Enter your coding question:")
|
|
|
|
| 30 |
|
| 31 |
# Load model and tokenizer (either from local directory or Hugging Face Hub)
|
| 32 |
model_name = repo_name # Use the repo name if the model is on Hugging Face Hub, else use local dir
|
| 33 |
+
token = "<HUGGINGFACE_TOKEN>" # Replace with your Hugging Face token if the model is private
|
| 34 |
|
|
|
|
| 35 |
if os.path.exists(model_dir):
|
| 36 |
+
# Load the model and tokenizer from the local directory
|
| 37 |
+
model = AutoModelForCausalLM.from_pretrained(model_dir, use_auth_token=token)
|
| 38 |
+
tokenizer = AutoTokenizer.from_pretrained(model_dir, use_auth_token=token)
|
| 39 |
else:
|
| 40 |
+
# Load the model from Hugging Face Hub
|
| 41 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=token)
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=token)
|
| 43 |
|
| 44 |
# User input: Coding question
|
| 45 |
question = st.text_input("Enter your coding question:")
|