Spaces:
Runtime error
Runtime error
hereoncollab
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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):
|