From 88c14d3d04b124e0088b9bb98344e8f6078f1535 Mon Sep 17 00:00:00 2001 From: bittersweet1999 <148421775+bittersweet1999@users.noreply.github.com> Date: Fri, 24 May 2024 23:28:56 +0800 Subject: [PATCH] add support for lmdeploy api judge (#1193) --- opencompass/models/openai_api.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/opencompass/models/openai_api.py b/opencompass/models/openai_api.py index 47a942df..d6d7e070 100644 --- a/opencompass/models/openai_api.py +++ b/opencompass/models/openai_api.py @@ -184,8 +184,12 @@ class OpenAI(BaseAPIModel): messages.append(msg) # Hold out 100 tokens due to potential errors in tiktoken calculation - max_out_len = min( - max_out_len, context_window - self.get_token_len(str(input)) - 100) + try: + max_out_len = min( + max_out_len, + context_window - self.get_token_len(str(input)) - 100) + except KeyError: + max_out_len = max_out_len if max_out_len <= 0: return ''