Macdensten91 commited on
Commit
580a9ea
·
verified ·
1 Parent(s): 4002882

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -1,13 +1,23 @@
 
1
  import re
2
  import time
3
  import random
4
  import gradio as gr
5
  from huggingface_hub import InferenceClient
 
6
 
7
- # Initialize the InferenceClient (update the model and token as needed)
 
 
 
 
 
 
 
 
8
  client = InferenceClient(
9
  model="HuggingFaceH4/zephyr-7b-beta", # Change to your model if needed
10
- token="your_huggingface_api_token" # Replace with your Hugging Face API token
11
  )
12
 
13
  # Optional: Enable scraping if your site is deployed.
 
1
+ import os
2
  import re
3
  import time
4
  import random
5
  import gradio as gr
6
  from huggingface_hub import InferenceClient
7
+ from dotenv import load_dotenv
8
 
9
+ # Load environment variables from .env file
10
+ load_dotenv()
11
+
12
+ # Retrieve the Hugging Face API token from the environment
13
+ HF_TOKEN = os.environ.get("HF_TOKEN")
14
+ if not HF_TOKEN:
15
+ raise ValueError("Please set the HF_TOKEN environment variable in your .env file.")
16
+
17
+ # Initialize the InferenceClient (update the model as needed)
18
  client = InferenceClient(
19
  model="HuggingFaceH4/zephyr-7b-beta", # Change to your model if needed
20
+ token=HF_TOKEN
21
  )
22
 
23
  # Optional: Enable scraping if your site is deployed.