Thota02 commited on
Commit
22ed5d0
1 Parent(s): 41ad847

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -7,11 +7,20 @@ from transformers import pipeline
7
  # Configure logging
8
  logging.basicConfig(level=logging.DEBUG)
9
 
10
- # Set Hugging Face token
11
- os.environ['HUGGINGFACEHUB_API_TOKEN'] = hf_token
12
- # Load Hugging Face model
 
 
 
 
 
 
 
 
 
13
  MODEL_NAME = "mistralai/Mistral-Large-Instruct-2407"
14
- llm_pipeline = pipeline("text-generation", model=MODEL_NAME)
15
 
16
  # Load datasets
17
  def load_datasets():
 
7
  # Configure logging
8
  logging.basicConfig(level=logging.DEBUG)
9
 
10
+
11
+ # Retrieve Hugging Face API token from environment variables
12
+ HUGGINGFACEHUB_API_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN")
13
+ if not HUGGINGFACEHUB_API_TOKEN:
14
+ logging.error("Hugging Face API token is missing or invalid.")
15
+ st.error("Hugging Face API token is missing or invalid.")
16
+ st.stop()
17
+
18
+ # Now you can use HUGGINGFACEHUB_API_TOKEN in your code, for example:
19
+ from transformers import pipeline
20
+
21
+ # Load the model using the Hugging Face API token
22
  MODEL_NAME = "mistralai/Mistral-Large-Instruct-2407"
23
+ llm_pipeline = pipeline("text-generation", model=MODEL_NAME, use_auth_token=HUGGINGFACEHUB_API_TOKEN)
24
 
25
  # Load datasets
26
  def load_datasets():