Skip to content

Commit 8d6da34

Browse files
committed
support anthropic endpoint
Signed-off-by: liuli <[email protected]>
1 parent 74119fb commit 8d6da34

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

vllm/entrypoints/anthropic/serving_messages.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,13 @@ async def message_stream_converter(
295295

296296
# last chunk including usage info
297297
if len(origin_chunk.choices) == 0:
298+
if content_block_started:
299+
stop_chunk = AnthropicStreamEvent(
300+
index=content_block_index,
301+
type="content_block_stop",
302+
)
303+
data = stop_chunk.model_dump_json(exclude_unset=True)
304+
yield f"data: {data}\n\n"
298305
chunk = AnthropicStreamEvent(
299306
type="message_delta",
300307
delta=AnthropicDelta(
@@ -381,15 +388,6 @@ async def message_stream_converter(
381388

382389
if origin_chunk.choices[0].finish_reason is not None:
383390
finish_reason = origin_chunk.choices[0].finish_reason
384-
385-
if content_block_started:
386-
stop_chunk = AnthropicStreamEvent(
387-
index=content_block_index,
388-
type="content_block_stop",
389-
)
390-
data = stop_chunk.model_dump_json(exclude_unset=True)
391-
yield f"data: {data}\n\n"
392-
content_block_started = False
393391
continue
394392

395393
else:

0 commit comments

Comments
 (0)