Spaces:
Running
Running
pri2k
commited on
Commit
·
ec7f722
1
Parent(s):
face833
Remove login(), pass token to SentenceTransformer
Browse files
app.py
CHANGED
@@ -1,20 +1,16 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from pydantic import BaseModel
|
3 |
from sentence_transformers import SentenceTransformer
|
4 |
-
import torch
|
5 |
import os
|
6 |
-
from huggingface_hub import login
|
7 |
-
|
8 |
-
# Log in using the HF_TOKEN environment variable
|
9 |
-
hf_token = os.getenv("HF_TOKEN")
|
10 |
-
if hf_token:
|
11 |
-
login(token=hf_token)
|
12 |
-
else:
|
13 |
-
raise ValueError("HF_TOKEN not found. Make sure it's set in your Space variables.")
|
14 |
|
15 |
app = FastAPI()
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
class InputText(BaseModel):
|
20 |
text: str
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from pydantic import BaseModel
|
3 |
from sentence_transformers import SentenceTransformer
|
|
|
4 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
8 |
+
hf_token = os.getenv("HF_TOKEN")
|
9 |
+
if not hf_token:
|
10 |
+
raise ValueError("HF_TOKEN not set in environment variables.")
|
11 |
+
|
12 |
+
# Pass token while loading the model
|
13 |
+
model = SentenceTransformer("mental/mental-bert-base-uncased", use_auth_token=hf_token)
|
14 |
|
15 |
class InputText(BaseModel):
|
16 |
text: str
|