Skip to content

Fix web-ui #3997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/train/embedding/train_gte.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ swift sft \
--train_type lora \
--dataset 'sentence-transformers/stsb' \
--torch_dtype bfloat16 \
--num_train_epochs 10 \
--num_train_epochs 1 \
--per_device_train_batch_size 2 \
--per_device_eval_batch_size 1 \
--gradient_accumulation_steps $(expr 64 / $nproc_per_node) \
Expand Down
10 changes: 8 additions & 2 deletions swift/ui/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def wrapper(*args, **kwargs):
if builder is not None:
choices = base_builder.choice(elem_id)
if choices:
choices = [str(choice) if choice is not None else None for choice in choices]
kwargs['choices'] = choices

if not isinstance(self, (Tab, TabItem, Accordion)) and 'interactive' not in kwargs: # noqa
Expand Down Expand Up @@ -259,10 +260,15 @@ def set_lang(cls, lang):
def get_choices_from_dataclass(dataclass):
choice_dict = {}
for f in fields(dataclass):
default_value = f.default
if 'MISSING_TYPE' in str(default_value):
default_value = None
if 'choices' in f.metadata:
choice_dict[f.name] = f.metadata['choices']
choice_dict[f.name] = list(f.metadata['choices'])
if 'Literal' in str(f.type) and typing.get_args(f.type):
choice_dict[f.name] = typing.get_args(f.type)
choice_dict[f.name] = list(typing.get_args(f.type))
if f.name in choice_dict and default_value not in choice_dict[f.name]:
choice_dict[f.name].insert(0, default_value)
return choice_dict

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion swift/ui/llm_export/llm_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,4 @@ def export_model(cls, *args):
run_command, export_args, log_file = cls.export(*args)
os.system(run_command)
time.sleep(2)
return gr.update(open=True), ExportRuntime.refresh_tasks(log_file), [None]
return gr.update(open=True), ExportRuntime.refresh_tasks(log_file)
Loading