Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiannis128 committed Jan 19, 2024
1 parent bdfeb67 commit 8dc6b25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ urllib3 = "==1.26.15"
yarl = "==1.9.2"
libclang = "*"
clang = "*"
text-generation = "*"
langchain = "*"
langchain-openai = "*"

Expand Down
23 changes: 10 additions & 13 deletions esbmc_ai_lib/base_chat_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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

0 comments on commit 8dc6b25

Please sign in to comment.