-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REFACTOR] Move GenerationConfig to protocol (#2427)
This PR moves GenerationConfig to protocol. As we move towards OAI style API GenerationConfig becomes more like an internal API. This change reflects that and also removes duplicated definition of ResponseFormat and DebugConfig
- Loading branch information
Showing
21 changed files
with
95 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
"""Definitions of pydantic models for API entry points and configurations""" | ||
from . import openai_api_protocol | ||
"""Definitions of pydantic models for API entry points and configurations | ||
RequestProtocol = openai_api_protocol.CompletionRequest | ||
Note | ||
---- | ||
We use the following convention | ||
- filename_protocol If the classes can appear in an API endpoint | ||
- filename_config For other config classes | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Low-level generation config class""" | ||
# pylint: disable=missing-class-docstring, disable=too-many-instance-attributes | ||
from typing import Dict, List, Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
from .debug_protocol import DebugConfig | ||
from .openai_api_protocol import RequestResponseFormat | ||
|
||
|
||
class GenerationConfig(BaseModel): # pylint: | ||
"""The generation configuration dataclass. | ||
This is a config class used by Engine internally. | ||
""" | ||
|
||
n: int = 1 | ||
temperature: Optional[float] = None | ||
top_p: Optional[float] = None | ||
frequency_penalty: Optional[float] = None | ||
presence_penalty: Optional[float] = None | ||
repetition_penalty: Optional[float] = None | ||
logprobs: bool = False | ||
top_logprobs: int = 0 | ||
logit_bias: Optional[Dict[int, float]] = None | ||
# internally we use -1 to represent infinite | ||
max_tokens: int = -1 | ||
seed: Optional[int] = None | ||
stop_strs: Optional[List[str]] = None | ||
stop_token_ids: Optional[List[int]] = None | ||
response_format: Optional[RequestResponseFormat] = None | ||
debug_config: Optional[Optional[DebugConfig]] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.