[Bugfix][Frontend] Only echo the assistant turn in batched chat completions (#52529)

Signed-off-by: Kaif <kaifkohari10@gmail.com>
Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
Kaif Kohari
2026-08-29 09:44:17 -07:00
committed by GitHub
co-authored by Cyrus Leung
parent 5b0e5b69ac
commit 7fbfca2670
2 changed files with 106 additions and 1 deletions
@@ -291,7 +291,11 @@ class OpenAIServingChatBatch(OpenAIServingChat):
if request.echo:
conversation = all_conversations[prompt_idx]
last_msg_content: str | list[dict[str, str]] = ""
if conversation and "content" in conversation[-1]:
if (
conversation
and "content" in conversation[-1]
and conversation[-1].get("role") == role
):
last_msg_content = conversation[-1]["content"] or ""
if isinstance(last_msg_content, list):
last_msg_content = "\n".join(