Spaces:
Runtime error
Runtime error
YaserDS-777
commited on
Commit
•
2602485
1
Parent(s):
42a71b8
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,16 @@ import gradio as gr
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
# Get the Hugging Face API token from environment variables
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Initialize the text generation pipeline with authentication
|
9 |
-
pipe = pipeline("text-generation", model="meta-llama/Meta-Llama-3.1-405B", use_auth_token=
|
10 |
|
11 |
# Define the function to generate text
|
12 |
def generate_text(prompt):
|
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
# Get the Hugging Face API token from environment variables
|
6 |
+
api_token = os.getenv("HUGGINGFACE_API_TOKEN")
|
7 |
+
|
8 |
+
# Check if the API token is set
|
9 |
+
|
10 |
+
print('-----------------',api_token,'-------------')
|
11 |
+
if not api_token:
|
12 |
+
raise ValueError("API token is not set. Please set the HUGGINGFACE_API_TOKEN environment variable.")
|
13 |
|
14 |
# Initialize the text generation pipeline with authentication
|
15 |
+
pipe = pipeline("text-generation", model="meta-llama/Meta-Llama-3.1-405B", use_auth_token=api_token)
|
16 |
|
17 |
# Define the function to generate text
|
18 |
def generate_text(prompt):
|