Skip to content

Commit

Permalink
adds error handling for too long diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraschauer committed Jul 4, 2024
1 parent 607b630 commit 6d37089
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions prospector/llm/llm_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import validators
from langchain_core.language_models.llms import LLM
from langchain_core.output_parsers import StrOutputParser
from requests import HTTPError

from datamodel.commit import Commit
from llm.instantiation import create_model_instance
Expand Down Expand Up @@ -95,6 +96,12 @@ def classify_commit(
)
logger.info(f"LLM returned is_relevant={is_relevant}")

except HTTPError as e:
# if the diff is too big, a 400 error is returned -> silently ignore by returning False for this commit
status_code = e.response.status_code
if status_code == 400:
return False
raise RuntimeError(f"Prompt-model chain could not be invoked: {e}")
except Exception as e:
raise RuntimeError(f"Prompt-model chain could not be invoked: {e}")

Expand Down

0 comments on commit 6d37089

Please sign in to comment.