Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix openai protocols and pass top_k, min_p #2499

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/sglang/srt/openai_api/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ def v1_generate_request(
"stop": request.stop,
"stop_token_ids": request.stop_token_ids,
"top_p": request.top_p,
"top_k": request.top_k,
"min_p": request.min_p,
"presence_penalty": request.presence_penalty,
"frequency_penalty": request.frequency_penalty,
"repetition_penalty": request.repetition_penalty,
Expand Down Expand Up @@ -926,6 +928,8 @@ def v1_chat_generate_request(
"stop": stop,
"stop_token_ids": request.stop_token_ids,
"top_p": request.top_p,
"top_k": request.top_k,
"min_p": request.min_p,
"presence_penalty": request.presence_penalty,
"frequency_penalty": request.frequency_penalty,
"repetition_penalty": request.repetition_penalty,
Expand Down
14 changes: 9 additions & 5 deletions python/sglang/srt/openai_api/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,19 @@ class CompletionRequest(BaseModel):
temperature: float = 1.0
top_p: float = 1.0
user: Optional[str] = None
lora_path: Optional[Union[List[Optional[str]], Optional[str]]] = None

# Extra parameters for SRT backend only and will be ignored by OpenAI models.
json_schema: Optional[str] = None
regex: Optional[str] = None
top_k: int = -1
min_p: float = 0.0
min_tokens: int = 0
regex: Optional[str] = None
json_schema: Optional[str] = None
repetition_penalty: float = 1.0
stop_token_ids: Optional[List[int]] = None
no_stop_trim: bool = False
ignore_eos: bool = False
skip_special_tokens: bool = True
lora_path: Optional[Union[List[Optional[str]], Optional[str]]] = None


class CompletionResponseChoice(BaseModel):
Expand Down Expand Up @@ -276,14 +278,16 @@ class ChatCompletionRequest(BaseModel):
user: Optional[str] = None

# Extra parameters for SRT backend only and will be ignored by OpenAI models.
lora_path: Optional[Union[List[Optional[str]], Optional[str]]] = None
regex: Optional[str] = None
top_k: int = -1
min_p: float = 0.0
min_tokens: int = 0
regex: Optional[str] = None
repetition_penalty: float = 1.0
stop_token_ids: Optional[List[int]] = None
no_stop_trim: bool = False
ignore_eos: bool = False
skip_special_tokens: bool = True
lora_path: Optional[Union[List[Optional[str]], Optional[str]]] = None


class ChatMessage(BaseModel):
Expand Down
Loading