Izza-shahzad-13 commited on
Commit
d851e86
·
verified ·
1 Parent(s): 4363122

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -1,9 +1,15 @@
1
  import streamlit as st
2
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
  import torch
 
4
 
5
- # Hugging Face Token for Authentication
6
- HUGGINGFACE_TOKEN = "your_hugging_face_token_here" # Replace with your token
 
 
 
 
 
7
 
8
  # Function to load model and tokenizer (local or Hugging Face with token)
9
  def load_model(model_path):
 
1
  import streamlit as st
2
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
  import torch
4
+ import os
5
 
6
+ # Retrieve the Hugging Face token from environment variable
7
+ HUGGINGFACE_TOKEN = os.getenv("HF_ACCESS_TOKEN")
8
+
9
+ # Check if the token is available
10
+ if not HUGGINGFACE_TOKEN:
11
+ st.error("Hugging Face token not found. Please set the HUGGINGFACE_TOKEN environment variable.")
12
+ st.stop() # Stop the app if the token is not found
13
 
14
  # Function to load model and tokenizer (local or Hugging Face with token)
15
  def load_model(model_path):