Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import threading
|
|
8 |
import re
|
9 |
import unittest
|
10 |
from urllib.parse import urlparse
|
|
|
11 |
|
12 |
import pandas as pd
|
13 |
from selenium import webdriver
|
@@ -34,6 +35,8 @@ from dotenv import load_dotenv
|
|
34 |
from huggingface_hub import login
|
35 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
36 |
|
|
|
|
|
37 |
def load_model(): # Define load_model() first
|
38 |
"""
|
39 |
Loads the openLlama model and tokenizer once and returns the pipeline.
|
@@ -66,9 +69,10 @@ chat_pipeline = load_model() # Now call load_model()
|
|
66 |
nlp = AutoTokenizer.from_pretrained("bert-base-uncased")
|
67 |
|
68 |
HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
|
|
69 |
if not HUGGINGFACE_TOKEN:
|
70 |
raise ValueError("HUGGINGFACE_TOKEN is not set in the environment variables.")
|
71 |
-
|
72 |
login(token=HUGGINGFACE_TOKEN)
|
73 |
|
74 |
|
|
|
8 |
import re
|
9 |
import unittest
|
10 |
from urllib.parse import urlparse
|
11 |
+
import spaces
|
12 |
|
13 |
import pandas as pd
|
14 |
from selenium import webdriver
|
|
|
35 |
from huggingface_hub import login
|
36 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
37 |
|
38 |
+
|
39 |
+
@spaces()
|
40 |
def load_model(): # Define load_model() first
|
41 |
"""
|
42 |
Loads the openLlama model and tokenizer once and returns the pipeline.
|
|
|
69 |
nlp = AutoTokenizer.from_pretrained("bert-base-uncased")
|
70 |
|
71 |
HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
72 |
+
|
73 |
if not HUGGINGFACE_TOKEN:
|
74 |
raise ValueError("HUGGINGFACE_TOKEN is not set in the environment variables.")
|
75 |
+
add_to_git_credential=True
|
76 |
login(token=HUGGINGFACE_TOKEN)
|
77 |
|
78 |
|