Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,16 @@ def load_healthcare_ner_pipeline():
|
|
13 |
"""Load the Hugging Face pipeline for Healthcare NER."""
|
14 |
global ner_pipeline
|
15 |
if ner_pipeline is None:
|
|
|
|
|
|
|
|
|
|
|
16 |
ner_pipeline = pipeline(
|
17 |
"token-classification",
|
18 |
model="TypicaAI/HealthcareNER-Fr",
|
19 |
aggregation_strategy="first", # Groups B- and I- tokens into entities
|
20 |
-
use_auth_token=
|
21 |
-
|
22 |
)
|
23 |
return ner_pipeline
|
24 |
|
|
|
13 |
"""Load the Hugging Face pipeline for Healthcare NER."""
|
14 |
global ner_pipeline
|
15 |
if ner_pipeline is None:
|
16 |
+
|
17 |
+
token = os.getenv("HFTOKEN") # Retrieve token from environment variable
|
18 |
+
if not token:
|
19 |
+
raise ValueError("HF_TOKEN is not set. Please add it to the Secrets in your Space settings.")
|
20 |
+
|
21 |
ner_pipeline = pipeline(
|
22 |
"token-classification",
|
23 |
model="TypicaAI/HealthcareNER-Fr",
|
24 |
aggregation_strategy="first", # Groups B- and I- tokens into entities
|
25 |
+
use_auth_token=token # Use the token for gated models
|
|
|
26 |
)
|
27 |
return ner_pipeline
|
28 |
|