Spaces:
Sleeping
Sleeping
update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import transformers
|
| 3 |
import torch
|
| 4 |
-
import os
|
| 5 |
import time
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# Initialize the model and tokenizer using Hugging Face pipeline
|
| 8 |
model_id = "meta-llama/Meta-Llama-3.1-70B"
|
| 9 |
-
pipeline = transformers.pipeline("text-generation", model=model_id)
|
| 10 |
|
| 11 |
def generate_response(prompt):
|
| 12 |
# Generate a response using the pipeline
|
|
|
|
| 1 |
+
import os
|
| 2 |
import streamlit as st
|
| 3 |
import transformers
|
| 4 |
import torch
|
|
|
|
| 5 |
import time
|
| 6 |
|
| 7 |
+
# Read Hugging Face API Token from environment variable
|
| 8 |
+
hf_token = os.getenv("HUGGING_FACE_API_TOKEN")
|
| 9 |
+
if not hf_token:
|
| 10 |
+
st.error("Hugging Face API token not found. Please set the HUGGING_FACE_API_TOKEN environment variable.")
|
| 11 |
+
st.stop()
|
| 12 |
+
|
| 13 |
# Initialize the model and tokenizer using Hugging Face pipeline
|
| 14 |
model_id = "meta-llama/Meta-Llama-3.1-70B"
|
| 15 |
+
pipeline = transformers.pipeline("text-generation", model=model_id, use_auth_token=hf_token)
|
| 16 |
|
| 17 |
def generate_response(prompt):
|
| 18 |
# Generate a response using the pipeline
|