Skip to content

Commit

Permalink
fix bug (#1320)
Browse files Browse the repository at this point in the history
  • Loading branch information
tastelikefeet authored Jul 8, 2024
1 parent f5b4585 commit 7562138
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions swift/llm/utils/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ def preprocess(self, d: Dict[str, Any]) -> Dict[str, Any]:
medias = self.parse_medias(d)
self.media_replacer(row, medias)
if self.media_type:
row[self.media_name] = medias
if not isinstance(self.media_key, str):
row[self.media_name] = medias
else:
row[self.media_key] = medias
return row

def __call__(self, dataset: HfDataset) -> HfDataset:
Expand Down Expand Up @@ -251,7 +254,10 @@ def preprocess(self, d: Dict[str, Any]) -> Dict[str, Any]:
medias = self.parse_medias(d)
self.media_replacer(row, medias)
if self.media_type:
row[self.media_name] = medias
if not isinstance(self.media_key, str):
row[self.media_name] = medias
else:
row[self.media_key] = medias
return row
except (AssertionError, SyntaxError):
if self.error_strategy == 'raise':
Expand Down Expand Up @@ -306,7 +312,10 @@ def preprocess(self, d: Dict[str, Any]) -> Dict[str, Any]:
medias = self.parse_medias(d)
self.media_replacer(row, medias)
if self.media_type:
row[self.media_name] = medias
if not isinstance(self.media_key, str):
row[self.media_name] = medias
else:
row[self.media_key] = medias
except Exception:
if self.error_strategy == 'raise':
raise ValueError(f'conversations: {conversations}')
Expand Down

0 comments on commit 7562138

Please sign in to comment.