From d4bc29e9112eedf6b95877179ab6d30fed2460e3 Mon Sep 17 00:00:00 2001 From: I748376 Date: Tue, 2 Jul 2024 13:03:14 +0000 Subject: [PATCH] adds error handling for too long diffs --- prospector/llm/llm_service.py | 7 +++++++ prospector/rules/rules.py | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/prospector/llm/llm_service.py b/prospector/llm/llm_service.py index 6140f874d..1134794e3 100644 --- a/prospector/llm/llm_service.py +++ b/prospector/llm/llm_service.py @@ -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 @@ -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}") diff --git a/prospector/rules/rules.py b/prospector/rules/rules.py index b39ed975b..996ee9a5e 100644 --- a/prospector/rules/rules.py +++ b/prospector/rules/rules.py @@ -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 @@ -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] = [