Skip to content

Commit

Permalink
refactor(gemini): set empty response when no candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
ganler committed May 19, 2024
1 parent 77c1782 commit ac3192f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions repoqa/provider/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ def generate_reply(
system_msg=system_msg,
)

assert (
len(replies.candidates) == n
), f"# replies = {len(replies.candidates)} != {n = }"
if len(replies.candidates) != n:
print(f"[WARNING] # replies = {len(replies.candidates)} != {n = }")

ret_texts = []
for candidate in replies.candidates:
Expand All @@ -45,4 +44,4 @@ def generate_reply(
ret_texts.append("")
print(f"{candidate.safety_ratings = }")

return ret_texts
return ret_texts + [""] * (n - len(ret_texts))

0 comments on commit ac3192f

Please sign in to comment.