hereoncollab commited on
Commit
4309fc8
·
verified ·
1 Parent(s): 279e516

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -1,7 +1,18 @@
 
1
  import gradio as gr
2
  from transformers import pipeline
 
3
 
4
- # Initialize the text generation pipeline with the Gemma 2-2B IT model
 
 
 
 
 
 
 
 
 
5
  pipe = pipeline("text-generation", model="google/gemma-2-2b-it")
6
 
7
  def generate_response(user_input):
 
1
+ import os
2
  import gradio as gr
3
  from transformers import pipeline
4
+ from huggingface_hub import login
5
 
6
+ # Read the token from the environment variable
7
+ HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
8
+
9
+ # Authenticate with Hugging Face
10
+ if HUGGINGFACE_TOKEN:
11
+ login(token=HUGGINGFACE_TOKEN)
12
+ else:
13
+ raise ValueError("Hugging Face token not found in environment variables.")
14
+
15
+ # Initialize the text generation pipeline
16
  pipe = pipeline("text-generation", model="google/gemma-2-2b-it")
17
 
18
  def generate_response(user_input):