Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
# Load your model and tokenizer
|
5 |
-
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-chat")
|
6 |
-
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-chat")
|
7 |
|
8 |
# Load a content moderation pipeline
|
9 |
moderation_pipeline = pipeline("text-classification", model="typeform/mobilebert-uncased-mnli")
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
3 |
+
import os
|
4 |
+
|
5 |
+
|
6 |
+
# Retrieve the token from environment variables
|
7 |
+
huggingface_token = os.getenv('LLAMA_ACCES_TOKEN')
|
8 |
+
|
9 |
+
# Use the token with from_pretrained
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-chat", use_auth_token=huggingface_token)
|
11 |
+
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-chat", use_auth_token=huggingface_token)
|
12 |
|
|
|
|
|
|
|
13 |
|
14 |
# Load a content moderation pipeline
|
15 |
moderation_pipeline = pipeline("text-classification", model="typeform/mobilebert-uncased-mnli")
|