Dinuk-Di commited on
Commit
e169104
·
1 Parent(s): 46f621c

Model updated

Browse files
Files changed (1) hide show
  1. app/model.py +7 -0
app/model.py CHANGED
@@ -8,8 +8,15 @@ if not os.getenv("HUGGINGFACEHUB_API_TOKEN"):
8
  "Set this as a secret in your HuggingFace Space or .env file.")
9
 
10
  def load_model(repo_id: str, max_length: int = 512, temperature: float = 0.5):
 
 
 
 
 
 
11
  llm = HuggingFaceEndpoint(
12
  repo_id=repo_id,
 
13
  task="text-generation",
14
  max_new_tokens=max_length,
15
  do_sample=temperature > 0,
 
8
  "Set this as a secret in your HuggingFace Space or .env file.")
9
 
10
  def load_model(repo_id: str, max_length: int = 512, temperature: float = 0.5):
11
+ # Retrieve the token (Hugging Face Spaces automatically exposes HF_TOKEN if you link your space to your token)
12
+ hf_token = os.getenv("HUGGINGFACEHUB_API_TOKEN") or os.getenv("HF_TOKEN")
13
+
14
+ if not hf_token:
15
+ print("CRITICAL ERROR: No API Token found! Make sure you added your HUGGINGFACEHUB_API_TOKEN or HF_TOKEN in Space Secrets.")
16
+
17
  llm = HuggingFaceEndpoint(
18
  repo_id=repo_id,
19
+ huggingfacehub_api_token=hf_token,
20
  task="text-generation",
21
  max_new_tokens=max_length,
22
  do_sample=temperature > 0,