Skip to content

Commit

Permalink
🚑 parse func bug fix
Browse files Browse the repository at this point in the history
Signed-off-by: Abhi.B <[email protected]>
  • Loading branch information
Abhi.B authored and Abhi.B committed Jun 26, 2024
1 parent c5d1099 commit 1cb224a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/instructlab/sdg/llmblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Local
from .block import Block
from .logger_config import setup_logger
from typing import Any, Dict, Union

Check warning on line 11 in src/instructlab/sdg/llmblock.py

View workflow job for this annotation

GitHub Actions / lint

W0611: Unused Union imported from typing (unused-import)

logger = setup_logger(__name__)

Expand Down Expand Up @@ -56,9 +57,8 @@ def _parse(self, generated_string) -> dict:
pattern = re.escape(start_tag) + r"(.*?)" + re.escape(end_tag)
all_matches = re.findall(pattern, generated_string, re.DOTALL)
matches[output_col] = (
[match.strip() for match in all_matches] if all_matches else None
[match.strip() for match in all_matches] if all_matches else []
)

return matches

def _generate(self, samples, **gen_kwargs) -> list:
Expand Down Expand Up @@ -123,7 +123,7 @@ def __init__(self, block_name, config_paths, client, model_id, output_cols, sele

def _parse(self, generated_string):
if self.parser_name == 'default':

Check warning on line 125 in src/instructlab/sdg/llmblock.py

View workflow job for this annotation

GitHub Actions / lint

R1705: Unnecessary "elif" after "return", remove the leading "el" from "elif" (no-else-return)
return matches
return super()._parse(generated_string)
elif self.parser_name == 'multi-line-logical-section':
return {self.output_cols[0]: self.extract_multiline_logical_section(generated_string)}

Expand Down

0 comments on commit 1cb224a

Please sign in to comment.