From 8dc6b25aead4bcbd532378f60f03392737a437b9 Mon Sep 17 00:00:00 2001 From: Yiannis Charalambous Date: Fri, 19 Jan 2024 14:02:19 +0000 Subject: [PATCH] Update --- Pipfile | 1 - esbmc_ai_lib/base_chat_interface.py | 23 ++++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Pipfile b/Pipfile index 6b5264c..bb2d246 100644 --- a/Pipfile +++ b/Pipfile @@ -22,7 +22,6 @@ urllib3 = "==1.26.15" yarl = "==1.9.2" libclang = "*" clang = "*" -text-generation = "*" langchain = "*" langchain-openai = "*" diff --git a/esbmc_ai_lib/base_chat_interface.py b/esbmc_ai_lib/base_chat_interface.py index 4bb70f4..4680682 100644 --- a/esbmc_ai_lib/base_chat_interface.py +++ b/esbmc_ai_lib/base_chat_interface.py @@ -13,7 +13,6 @@ ) from openai import InternalServerError -from text_generation.errors import UnknownError, ValidationError from .config import ChatPromptSettings from .chat_response import ChatResponse, FinishReason @@ -87,14 +86,15 @@ def send_message(self, message: str) -> ChatResponse: message=response_message, total_tokens=cb.total_tokens, ) - except ValidationError as e: - # HFTextGen - response = ChatResponse( - finish_reason=FinishReason.length, - # NOTE Show the total tokens of the model instead of 0 - # (no token counting currently...) - total_tokens=self.ai_model.tokens, - ) + # FIXME + # except TokenLimitExceededException as e: + # # HFTextGen + # response = ChatResponse( + # finish_reason=FinishReason.length, + # # NOTE Show the total tokens of the model instead of 0 + # # (no token counting currently...) + # total_tokens=self.ai_model.tokens, + # ) except InternalServerError as e: # OpenAI model error handling. if e.code == AIModelOpenAI.context_length_exceeded_error: @@ -104,11 +104,8 @@ def send_message(self, message: str) -> ChatResponse: ) else: raise - except UnknownError as e: - # HFTextGen + except Exception as e: print(f"There was an unkown error when generating a response: {e}") exit(1) - except Exception: - raise return response