Skip to content

Commit b78704b

Browse files
committed
Cherry-pick 4aca819: Add ernie-speed (#315)
1 parent 7a51518 commit b78704b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

erniebot/src/erniebot/constants.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from typing import Final
16+
1517
LOGGER_NAME: str = "erniebot"
1618

1719
STREAM_RESPONSE_PREFIX: bytes = b"data: "
1820

19-
DEFAULT_REQUEST_TIMEOUT_SECS: float = 600
21+
DEFAULT_REQUEST_TIMEOUT_SECS: Final[float] = 600
2022

21-
POLLING_INTERVAL_SECS: float = 5
22-
POLLING_TIMEOUT_SECS: float = 20
23+
POLLING_INTERVAL_SECS: Final[float] = 5
24+
POLLING_TIMEOUT_SECS: Final[float] = 600

erniebot/src/erniebot/resources/chat_completion.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class ChatCompletion(EBResource, CreatableWithStreaming):
6464
"ernie-longtext": {
6565
"model_id": "ernie_bot_8k",
6666
},
67+
"ernie-speed": {
68+
"model_id": "ernie_speed",
69+
},
6770
},
6871
},
6972
APIType.AISTUDIO: {
@@ -478,8 +481,14 @@ def _set_val_if_key_exists(src: dict, dst: dict, key: str) -> None:
478481

479482
# params
480483
params = {}
481-
if model == "ernie-turbo":
482-
for arg in ("functions", "stop", "disable_search", "enable_citation"):
484+
if model in ("ernie-turbo", "ernie-speed"):
485+
for arg in (
486+
"functions",
487+
"stop",
488+
"disable_search",
489+
"enable_citation",
490+
"tool_choice",
491+
):
483492
if arg in kwargs:
484493
raise errors.InvalidArgumentError(f"`{arg}` is not supported by the {model} model.")
485494
params["messages"] = messages

0 commit comments

Comments
 (0)