Skip to content

Commit dbb8804

Browse files
committed
fix: allow separate input/output budgets for T5 in context check
1 parent 587d5cf commit dbb8804

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

fastchat/serve/openai_api_server.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ async def check_length(request, prompt, max_tokens, worker_addr):
166166
{"model": request.model, "prompt": prompt},
167167
"count",
168168
)
169-
length = min(max_tokens, context_len - token_num)
169+
is_enc_dec = "t5" in request.model.lower()
170+
length = min(max_tokens, context_len if is_enc_dec else context_len - token_num)
170171

171-
if length <= 0:
172+
if (is_enc_dec and token_num > context_len) or length <= 0:
172173
return None, create_error_response(
173174
ErrorCode.CONTEXT_OVERFLOW,
174175
f"This model's maximum context length is {context_len} tokens. However, your messages resulted in {token_num} tokens. Please reduce the length of the messages.",

0 commit comments

Comments
 (0)