Skip to content

Commit e8fa50f

Browse files
committed
initial commit replace basemodel types
Signed-off-by: Andrew Xia <[email protected]>
1 parent 86daa87 commit e8fa50f

File tree

3 files changed

+104
-96
lines changed

3 files changed

+104
-96
lines changed

vllm/entrypoints/openai/api_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from fastapi.exceptions import RequestValidationError
3030
from fastapi.middleware.cors import CORSMiddleware
3131
from fastapi.responses import JSONResponse, Response, StreamingResponse
32-
from openai import BaseModel
3332
from prometheus_client import make_asgi_app
3433
from prometheus_fastapi_instrumentator import Instrumentator
3534
from starlette.concurrency import iterate_in_threadpool
@@ -71,7 +70,9 @@
7170
RerankRequest, RerankResponse,
7271
ResponsesRequest,
7372
ResponsesResponse, ScoreRequest,
74-
ScoreResponse, TokenizeRequest,
73+
ScoreResponse,
74+
StreamingResponsesResponse,
75+
TokenizeRequest,
7576
TokenizeResponse,
7677
TranscriptionRequest,
7778
TranscriptionResponse,
@@ -579,8 +580,8 @@ async def show_version():
579580

580581

581582
async def _convert_stream_to_sse_events(
582-
generator: AsyncGenerator[BaseModel,
583-
None]) -> AsyncGenerator[str, None]:
583+
generator: AsyncGenerator[StreamingResponsesResponse, None]
584+
) -> AsyncGenerator[str, None]:
584585
"""Convert the generator to a stream of events in SSE format"""
585586
async for event in generator:
586587
event_type = getattr(event, 'type', 'unknown')

vllm/entrypoints/openai/protocol.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@
1818
from openai.types.chat.chat_completion_message import (
1919
Annotation as OpenAIAnnotation)
2020
# yapf: enable
21-
from openai.types.responses import (ResponseFunctionToolCall,
22-
ResponseInputItemParam, ResponseOutputItem,
23-
ResponsePrompt, ResponseReasoningItem,
24-
ResponseStatus)
21+
from openai.types.responses import (
22+
ResponseCodeInterpreterCallCodeDeltaEvent,
23+
ResponseCodeInterpreterCallCodeDoneEvent,
24+
ResponseCodeInterpreterCallCompletedEvent,
25+
ResponseCodeInterpreterCallInProgressEvent,
26+
ResponseCodeInterpreterCallInterpretingEvent, ResponseCompletedEvent,
27+
ResponseContentPartAddedEvent, ResponseContentPartDoneEvent,
28+
ResponseFunctionToolCall, ResponseInProgressEvent, ResponseInputItemParam,
29+
ResponseOutputItem, ResponseOutputItemAddedEvent,
30+
ResponseOutputItemDoneEvent, ResponsePrompt, ResponseReasoningItem,
31+
ResponseReasoningTextDeltaEvent, ResponseReasoningTextDoneEvent,
32+
ResponseStatus, ResponseWebSearchCallCompletedEvent,
33+
ResponseWebSearchCallInProgressEvent, ResponseWebSearchCallSearchingEvent)
2534

2635
# Backward compatibility for OpenAI client versions
2736
try: # For older openai versions (< 1.100.0)
@@ -251,6 +260,26 @@ def get_logits_processors(processors: Optional[LogitsProcessors],
251260
ResponseReasoningItem,
252261
ResponseFunctionToolCall]
253262

263+
StreamingResponsesResponse: TypeAlias = Union[
264+
# ResponseCreatedEvent,
265+
ResponseInProgressEvent,
266+
ResponseCompletedEvent,
267+
ResponseOutputItemAddedEvent,
268+
ResponseOutputItemDoneEvent,
269+
ResponseContentPartAddedEvent,
270+
ResponseContentPartDoneEvent,
271+
ResponseReasoningTextDeltaEvent,
272+
ResponseReasoningTextDoneEvent,
273+
ResponseCodeInterpreterCallInProgressEvent,
274+
ResponseCodeInterpreterCallCodeDeltaEvent,
275+
ResponseWebSearchCallInProgressEvent,
276+
ResponseWebSearchCallSearchingEvent,
277+
ResponseWebSearchCallCompletedEvent,
278+
ResponseCodeInterpreterCallCodeDoneEvent,
279+
ResponseCodeInterpreterCallInterpretingEvent,
280+
ResponseCodeInterpreterCallCompletedEvent,
281+
]
282+
254283

255284
class ResponsesRequest(OpenAIBaseModel):
256285
# Ordered by official OpenAI API documentation

0 commit comments

Comments
 (0)