Empereur-Pirate commited on
Commit
b7c9474
·
verified ·
1 Parent(s): 576130b

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -0
main.py CHANGED
@@ -6,6 +6,14 @@ from pydantic import BaseModel
6
  from typing import Optional, Any
7
  import torch
8
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextStreamer, GenerationConfig
 
 
 
 
 
 
 
 
9
 
10
  # Authentication
11
  from huggingface_hub import interpreter_login
 
6
  from typing import Optional, Any
7
  import torch
8
  from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextStreamer, GenerationConfig
9
+ import os
10
+
11
+ try:
12
+ # Attempt to fetch the token from the environment variable set in Spaces
13
+ HUGGINGFACE_TOKEN = os.environ['HF_ACCESS_TOKEN']
14
+ except KeyError:
15
+ print('The environment variable "HF_ACCESS_TOKEN" is not found. Please configure it correctly in your Space.')
16
+ sys.exit(1)
17
 
18
  # Authentication
19
  from huggingface_hub import interpreter_login