rohitghosh1763 commited on
Commit
d180fba
·
verified ·
1 Parent(s): c54bdd0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -1,10 +1,15 @@
1
  import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
3
 
4
- # Load the Llama model
 
 
 
 
5
  model_name = "meta-llama/Llama-3.2-3B-Instruct"
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForCausalLM.from_pretrained(model_name)
8
 
9
  # Define chatbot function
10
  def chat_with_llama(user_input):
 
1
  import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ import os
4
 
5
+ # Set Hugging Face token
6
+ # Replace this with your Hugging Face token or set it as an environment variable in Spaces settings.
7
+ hf_token = os.getenv("HF_TOKEN")
8
+
9
+ # Load the Llama model with authentication
10
  model_name = "meta-llama/Llama-3.2-3B-Instruct"
11
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=hf_token)
12
+ model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=hf_token)
13
 
14
  # Define chatbot function
15
  def chat_with_llama(user_input):