Skip to content

Commit

Permalink
Update OpenAI API (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
wisclmy0611 authored Jul 20, 2024
1 parent 49c5e0e commit e3046ea
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/sglang/srt/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from enum import IntEnum, auto
from typing import Dict, List, Optional, Tuple, Union

from sglang.srt.openai_protocol import ChatCompletionRequest
from sglang.srt.openai_api.protocol import ChatCompletionRequest


class SeparatorStyle(IntEnum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
register_conv_template,
)
from sglang.srt.managers.io_struct import GenerateReqInput
from sglang.srt.openai_protocol import (
from sglang.srt.openai_api.protocol import (
ChatCompletionRequest,
ChatCompletionResponse,
ChatCompletionResponseChoice,
Expand Down Expand Up @@ -106,6 +106,7 @@ async def v1_completions(tokenizer_manager, raw_request: Request):
"frequency_penalty": request.frequency_penalty,
"regex": request.regex,
"n": request.n,
"ignore_eos": request.ignore_eos,
},
return_logprob=request.logprobs is not None and request.logprobs > 0,
top_logprobs_num=request.logprobs if request.logprobs is not None else 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class CompletionRequest(BaseModel):

# Extra parameters for SRT backend only and will be ignored by OpenAI models.
regex: Optional[str] = None
ignore_eos: Optional[bool] = False


class CompletionResponseChoice(BaseModel):
Expand Down
4 changes: 2 additions & 2 deletions python/sglang/srt/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
from sglang.srt.managers.detokenizer_manager import start_detokenizer_process
from sglang.srt.managers.io_struct import GenerateReqInput
from sglang.srt.managers.tokenizer_manager import TokenizerManager
from sglang.srt.openai_api_adapter import (
from sglang.srt.openai_api.adapter import (
load_chat_template_for_openai_api,
v1_chat_completions,
v1_completions,
)
from sglang.srt.openai_protocol import ModelCard, ModelList
from sglang.srt.openai_api.protocol import ModelCard, ModelList
from sglang.srt.server_args import PortArgs, ServerArgs
from sglang.srt.utils import (
API_KEY_HEADER_NAME,
Expand Down
2 changes: 1 addition & 1 deletion python/sglang/test/test_conversation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from sglang.srt.conversation import generate_chat_conv
from sglang.srt.managers.openai_protocol import (
from sglang.srt.managers.openai_api.protocol import (
ChatCompletionMessageContentImagePart,
ChatCompletionMessageContentImageURL,
ChatCompletionMessageContentTextPart,
Expand Down
2 changes: 1 addition & 1 deletion python/sglang/test/test_openai_protocol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sglang.srt.managers.openai_protocol import (
from sglang.srt.managers.openai_api.protocol import (
ChatCompletionMessageContentImagePart,
ChatCompletionMessageContentImageURL,
ChatCompletionMessageContentTextPart,
Expand Down

0 comments on commit e3046ea

Please sign in to comment.