Update app.py
Browse files
app.py
CHANGED
@@ -14,13 +14,13 @@ import sentencepiece
|
|
14 |
import huggingface_hub
|
15 |
from transformers import TrainingArguments, Trainer
|
16 |
|
17 |
-
# Retrieve
|
18 |
-
|
19 |
-
if not
|
20 |
-
raise ValueError("
|
21 |
|
22 |
# Authenticate with Hugging Face
|
23 |
-
huggingface_hub.login(token=
|
24 |
|
25 |
# Model setup
|
26 |
MODEL_ID = "meta-llama/Llama-2-7b-hf"
|
@@ -143,7 +143,7 @@ def train_ui(files):
|
|
143 |
return "Training completed! Model saved to ./fine_tuned_llama_healthcare"
|
144 |
|
145 |
except Exception as e:
|
146 |
-
return f"Error: {str(e)}. Please check file format, dependencies, or
|
147 |
|
148 |
# Gradio UI
|
149 |
with gr.Blocks(title="Healthcare Fraud Detection Fine-Tuning") as demo:
|
|
|
14 |
import huggingface_hub
|
15 |
from transformers import TrainingArguments, Trainer
|
16 |
|
17 |
+
# Retrieve the token from Hugging Face Space secrets
|
18 |
+
llama = os.getenv("llama:levi put token here") # Token expected as env variable 'llama'
|
19 |
+
if not llama:
|
20 |
+
raise ValueError("llama token not found in environment variables. Please set it in Hugging Face Space secrets under 'Settings' > 'Secrets' as 'llama'.")
|
21 |
|
22 |
# Authenticate with Hugging Face
|
23 |
+
huggingface_hub.login(token=llama)
|
24 |
|
25 |
# Model setup
|
26 |
MODEL_ID = "meta-llama/Llama-2-7b-hf"
|
|
|
143 |
return "Training completed! Model saved to ./fine_tuned_llama_healthcare"
|
144 |
|
145 |
except Exception as e:
|
146 |
+
return f"Error: {str(e)}. Please check file format, dependencies, or the llama token."
|
147 |
|
148 |
# Gradio UI
|
149 |
with gr.Blocks(title="Healthcare Fraud Detection Fine-Tuning") as demo:
|