SPBhai commited on
Commit
fe97556
·
verified ·
1 Parent(s): 02c66bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -10,12 +10,19 @@ from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
10
  from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
11
 
12
  import os
 
13
  from huggingface_hub import login
14
 
15
- # Authenticate using your Hugging Face token stored as 'SP_7'
16
- hf_token = os.getenv("SP_7") # Reads the token from the environment variable
 
 
 
17
  if hf_token is None:
18
- raise ValueError("Hugging Face token 'SP_7' is not set in the environment variables.")
 
 
 
19
 
20
  # Log in to Hugging Face
21
  login(token=hf_token)
 
10
  from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
11
 
12
  import os
13
+ from dotenv import load_dotenv
14
  from huggingface_hub import login
15
 
16
+ # Load environment variables from the .env file
17
+ load_dotenv()
18
+
19
+ # Read the Hugging Face token
20
+ hf_token = os.getenv("SP_7")
21
  if hf_token is None:
22
+ raise ValueError(
23
+ "Hugging Face token 'SP_7' is not set in the environment variables. "
24
+ "Ensure it is defined in the .env file."
25
+ )
26
 
27
  # Log in to Hugging Face
28
  login(token=hf_token)