Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
refactor: clean code for align
Browse files Browse the repository at this point in the history
  • Loading branch information
dsdanielpark committed Mar 13, 2024
1 parent b36f1db commit e7e58b1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions gemini/src/misc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def extract_code(text: str) -> str:
Returns:
str or list of str: A single code snippet string if only one is found, otherwise a list of all extracted code snippets. Returns the original text if no snippets are found.
"""
if not text:
return []

snippets = []
start_pattern = "```"
end_pattern = "```"
Expand Down
4 changes: 3 additions & 1 deletion gemini/src/parser/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _parse_candidates(self, candidates_data: Dict) -> Dict:
candidate_dict = {
"rcid": candidate_data[0],
"text": candidate_data[1][0],
"code": extract_code(candidate_data[1][0]),
"code": self._parse_code(candidate_data[1][0]),
"web_images": web_images,
"generated_images": generated_images,
}
Expand Down Expand Up @@ -181,4 +181,6 @@ def _parse_generated_images(self, images_data: Dict) -> Dict:
]

def _parse_code(self, text):
if not text:
return []
return extract_code(text)

0 comments on commit e7e58b1

Please sign in to comment.