akhil2808 commited on
Commit
bd3c158
·
verified ·
1 Parent(s): f1b9210

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -6,8 +6,17 @@ import gradio as gr
6
  import spaces
7
  import torch
8
  from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
 
9
  from huggingface_hub import login
10
- login(token="HUGGINGFACE_API_TOKEN")
 
 
 
 
 
 
 
 
11
 
12
  MAX_MAX_NEW_TOKENS = 2048
13
  DEFAULT_MAX_NEW_TOKENS = 1024
 
6
  import spaces
7
  import torch
8
  from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
9
+ import os
10
  from huggingface_hub import login
11
+
12
+ # Load the API token from the environment variables
13
+ api_token = os.getenv('HUGGINGFACE_API_TOKEN')
14
+ if not api_token:
15
+ raise ValueError("No Hugging Face API token found. Please set the HUGGING_FACE_API_TOKEN environment variable.")
16
+
17
+ # Log in to Hugging Face Hub
18
+ login(token=api_token, add_to_git_credential=True)
19
+
20
 
21
  MAX_MAX_NEW_TOKENS = 2048
22
  DEFAULT_MAX_NEW_TOKENS = 1024