Skip to content

Commit 6db040c

Browse files
committed
chatbot 12: try to pick the first mistral-* when swapping servers if current server not avail
1 parent 9bc5cb9 commit 6db040c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

notebooks/tps/chatbot/.teacher/chatbot-12.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,19 @@ def update_models(self, *, update=True):
356356
if current_model in available_models:
357357
self.model.value = current_model
358358
else:
359-
# xxx somehow the first model on GPU - all-minilm:22m-l6-v2-fp16
359+
# pick a mistral model by default
360+
for model in available_models:
361+
if model.startswith("mistral-"):
362+
self.model.value = model
363+
break
364+
# otherwise, pick the first model that not a 'all-...'
365+
# this is a workaround because somehow the first model on GPU
366+
# namely - all-minilm:22m-l6-v2-fp16
360367
# returns an error saying the model does not support generate
361-
# so, as a workaround, find the first model that does not start with all-
362-
self.model.value = next(
363-
model for model in available_models if not model.startswith("all-")
364-
)
368+
else:
369+
self.model.value = next(
370+
model for model in available_models if not model.startswith("all-")
371+
)
365372
# a subtle point here: because we call update_models in the constructor,
366373
# and because at that time the app is not yet in the page
367374
# we cannot call update() in that circumstance()

0 commit comments

Comments
 (0)