Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def save_context(self, details, workflow_manage):

def execute(self, stt_model_id, audio, model_params_setting=None, **kwargs) -> NodeResult:
workspace_id = self.workflow_manage.get_body().get('workspace_id')
stt_model = get_model_instance_by_model_workspace_id(stt_model_id, workspace_id, **model_params_setting)
stt_model = get_model_instance_by_model_workspace_id(stt_model_id, workspace_id, **(model_params_setting or {}))
audio_list = audio
self.context['audio_list'] = audio

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is generally correct but could be optimized slightly. Here's a refined version:

@@ -23,8 +23,8 @@
 
     def execute(self, stt_model_id, audio, model_params_setting=None, **kwargs) -> NodeResult:
         workspace_id = self.workflow_manage.get_body().get('workspace_id')
-        if not model_params_setting:
-            model_params_setting = {}
         stt_model = get_model_instance_by_model_workspace_id(stt_model_id, workspace_id, **(model_params_setting or {}))
         audio_list = audio
         self.context['audio_list'] = audio

Optimization suggestions:

  • Added if condition to check if model_params_setting is None.
  • Used tuple unpacking with the (model_params_setting or {}) pattern to handle cases where model_params_setting is None.
  • Improved readability by moving the assignment of self.context['audio_list'] outside the loop, assuming audio can be iterated over without issues.

These changes ensure that the function handles missing parameters more gracefully.

Expand Down