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 5, 2024
1 parent 7fa396c commit f15a5ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 0 additions & 4 deletions prospector/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ def main(argv): # noqa: C901
limit_candidates=config.max_candidates,
# ignore_adv_refs=config.ignore_refs,
use_llm_repository_url=config.llm_service.use_llm_repository_url,
<<<<<<< HEAD
enabled_rules=config.enabled_rules,
=======
use_llm_rules=config.llm_service.use_llm_rules,
>>>>>>> 2c0b7be (marks working version)
)

if config.preprocess_only:
Expand Down
7 changes: 7 additions & 0 deletions prospector/llm/llm_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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 @@ -103,6 +104,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
6 changes: 0 additions & 6 deletions prospector/rules/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from abc import abstractmethod
from typing import List, Tuple

import requests

from datamodel.advisory import AdvisoryRecord
from datamodel.commit import Commit, apply_ranking
from llm.llm_service import LLMService
Expand Down Expand Up @@ -419,13 +417,9 @@ def apply(
self,
candidate: Commit,
) -> bool:
<<<<<<< HEAD
return LLMService().classify_commit(
candidate.diff, candidate.repository, candidate.message
)
=======
return LLMService().classify_commit(candidate.diff)
>>>>>>> 5924313 (adds function and rule for commit classification)


RULES_PHASE_1: List[Rule] = [
Expand Down

0 comments on commit f15a5ad

Please sign in to comment.