Waseem7711 commited on
Commit
822b0d9
1 Parent(s): b51e4ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -9,11 +9,8 @@ from dotenv import load_dotenv
9
  # Load environment variables
10
  load_dotenv()
11
 
12
-
13
-
14
-
15
- # Retrieve Hugging Face API token from environment variables (if accessing private models)
16
- HF_API_TOKEN = os.getenv("HF_API_TOKEN") # Ensure you set this in Hugging Face Secrets
17
 
18
  # Streamlit app setup
19
  st.title('Llama2 Chatbot Deployment on Hugging Face Spaces')
@@ -27,13 +24,13 @@ def load_model():
27
  """
28
  tokenizer = AutoTokenizer.from_pretrained(
29
  "meta-llama/Llama-2-7b-chat-hf",
30
- use_auth_token= use your api key # Remove if the model is public
31
  )
32
  model = AutoModelForCausalLM.from_pretrained(
33
  "meta-llama/Llama-2-7b-chat-hf",
34
  torch_dtype=torch.float16, # Use float16 for reduced memory usage
35
  device_map="auto",
36
- use_auth_token=HF_API_TOKEN # Remove if the model is public
37
  )
38
  return tokenizer, model
39
 
 
9
  # Load environment variables
10
  load_dotenv()
11
 
12
+ # Retrieve Hugging Face API token from environment variables
13
+ HF_API_TOKEN = os.getenv("HF_API_TOKEN")
 
 
 
14
 
15
  # Streamlit app setup
16
  st.title('Llama2 Chatbot Deployment on Hugging Face Spaces')
 
24
  """
25
  tokenizer = AutoTokenizer.from_pretrained(
26
  "meta-llama/Llama-2-7b-chat-hf",
27
+ use_auth_token=HF_API_TOKEN # Use the secret token
28
  )
29
  model = AutoModelForCausalLM.from_pretrained(
30
  "meta-llama/Llama-2-7b-chat-hf",
31
  torch_dtype=torch.float16, # Use float16 for reduced memory usage
32
  device_map="auto",
33
+ use_auth_token=HF_API_TOKEN # Use the secret token
34
  )
35
  return tokenizer, model
36