Skip to content

Commit

Permalink
Process empty messages from LLMs while extracting code
Browse files Browse the repository at this point in the history
  • Loading branch information
Anastasiia Grishina authored and Anastasiia Grishina committed Dec 4, 2023
1 parent cb079fa commit 39aa6c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions seidr/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def extract_codes(
language: Language | str
) -> str:
"""Extract code out of a message and (if Python) format it with black"""

try:
code_blocks = list(extract_from_buffer(StringIO(message_content)))
code_blocks = [code for code in code_blocks if not bool(code)]
except RuntimeError as e:
code_blocks = []

Expand Down Expand Up @@ -98,7 +98,7 @@ def query_llm(
# Assistants are trained to respond with one message.
# it is theoretically possible to get more than one message, but it is very unlikely.
assert all(len(r) == 1 for r in result.generations), "The models are expected to respond with one message"
result = [r[0].message.content for r in result.generations]
result = [r[0].message.content for r in result.generations if r[0].message.content]

if mode == "repair":
logging.info(f"Generating repair candidates for bug summary: \n{kwargs['bug_summary']}\n")
Expand Down

1 comment on commit 39aa6c8

@vadim0x60
Copy link
Owner

Choose a reason for hiding this comment

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

Doesn't line 43 always make the list empty? I was debugging a failing experiment and it traced back to this commit

Please sign in to comment.