Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,23 @@ client = InferenceClient(model=HF_MODEL, token=HF_TOKEN)
|
|
10 |
# Persistent bot knowledge state
|
11 |
bot_knowledge = {"dataset": None}
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Train chatbot by setting the dataset
|
15 |
def train_chatbot(dataset):
|
|
|
10 |
# Persistent bot knowledge state
|
11 |
bot_knowledge = {"dataset": None}
|
12 |
|
13 |
+
def load_model(hf_token):
|
14 |
+
"""Loads the model and tokenizer using the provided Hugging Face token."""
|
15 |
+
global model, tokenizer
|
16 |
+
|
17 |
+
# Set the token for Hugging Face authentication
|
18 |
+
HfFolder.save_token(hf_token, 'huggingface')
|
19 |
+
|
20 |
+
# Load the model
|
21 |
+
try:
|
22 |
+
with gr.Progress() as progress:
|
23 |
+
progress(0, "Loading model...")
|
24 |
+
model = AutoModelForCausalLM.from_pretrained(DEFAULT_MODEL)
|
25 |
+
tokenizer = AutoTokenizer.from_pretrained(DEFAULT_MODEL)
|
26 |
+
progress(100, "Model loaded successfully!")
|
27 |
+
return "Model loaded successfully!"
|
28 |
+
except Exception as e:
|
29 |
+
return f"Error loading model: {str(e)}"
|
30 |
|
31 |
# Train chatbot by setting the dataset
|
32 |
def train_chatbot(dataset):
|