Skip to content

Commit 60718fa

Browse files
tastelikefeettastelikefeet
andauthored
Fix web-ui (#3997)
Co-authored-by: tastelikefeet <[email protected]>
1 parent 84bf004 commit 60718fa

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

examples/train/embedding/train_gte.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ swift sft \
1111
--train_type lora \
1212
--dataset 'sentence-transformers/stsb' \
1313
--torch_dtype bfloat16 \
14-
--num_train_epochs 10 \
14+
--num_train_epochs 1 \
1515
--per_device_train_batch_size 2 \
1616
--per_device_eval_batch_size 1 \
1717
--gradient_accumulation_steps $(expr 64 / $nproc_per_node) \

swift/ui/base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def wrapper(*args, **kwargs):
3232
if builder is not None:
3333
choices = base_builder.choice(elem_id)
3434
if choices:
35+
choices = [str(choice) if choice is not None else None for choice in choices]
3536
kwargs['choices'] = choices
3637

3738
if not isinstance(self, (Tab, TabItem, Accordion)) and 'interactive' not in kwargs: # noqa
@@ -259,10 +260,15 @@ def set_lang(cls, lang):
259260
def get_choices_from_dataclass(dataclass):
260261
choice_dict = {}
261262
for f in fields(dataclass):
263+
default_value = f.default
264+
if 'MISSING_TYPE' in str(default_value):
265+
default_value = None
262266
if 'choices' in f.metadata:
263-
choice_dict[f.name] = f.metadata['choices']
267+
choice_dict[f.name] = list(f.metadata['choices'])
264268
if 'Literal' in str(f.type) and typing.get_args(f.type):
265-
choice_dict[f.name] = typing.get_args(f.type)
269+
choice_dict[f.name] = list(typing.get_args(f.type))
270+
if f.name in choice_dict and default_value not in choice_dict[f.name]:
271+
choice_dict[f.name].insert(0, default_value)
266272
return choice_dict
267273

268274
@staticmethod

swift/ui/llm_export/llm_export.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,4 @@ def export_model(cls, *args):
188188
run_command, export_args, log_file = cls.export(*args)
189189
os.system(run_command)
190190
time.sleep(2)
191-
return gr.update(open=True), ExportRuntime.refresh_tasks(log_file), [None]
191+
return gr.update(open=True), ExportRuntime.refresh_tasks(log_file)

0 commit comments

Comments
 (0)