-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support eval actions * fix: refactor model to fix circular import & fix evals * fix: nbs import * fix: move runnable -> common/ * fix: lint * chore: update version
- Loading branch information
Showing
17 changed files
with
461 additions
and
125 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
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
Empty file.
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,74 @@ | ||
# Copyright (c) 2023 Baidu, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from abc import ABC, abstractmethod | ||
from typing import ( | ||
Any, | ||
Dict, | ||
Generic, | ||
Optional, | ||
TypeVar, | ||
) | ||
|
||
Input = TypeVar("Input") | ||
Output = TypeVar("Output") | ||
|
||
|
||
class Executable(Generic[Input, Output], ABC): | ||
""" | ||
generic abstraction class of executable | ||
""" | ||
|
||
@abstractmethod | ||
def exec(self, input: Optional[Input] = None, **kwargs: Dict) -> Output: | ||
... | ||
|
||
|
||
class Serializable(ABC): | ||
""" | ||
generic abstraction class of serializable. | ||
especially for the model, service, and trainer. | ||
""" | ||
|
||
@abstractmethod | ||
def dumps(self) -> Optional[bytes]: | ||
""" | ||
dumps | ||
Returns: | ||
serialized bytes data | ||
""" | ||
... | ||
|
||
@abstractmethod | ||
def loads(self, data: bytes) -> Any: | ||
""" | ||
loads | ||
Parameters: | ||
data (bytes): load | ||
Returns: | ||
Any: _description_ | ||
""" | ||
... | ||
|
||
|
||
class ExecuteSerializable(Executable[Input, Output], Serializable): | ||
""" | ||
set of executable and serializable. subclass implement it to support | ||
exec and dumps/loads. | ||
""" | ||
|
||
... |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright (c) 2023 Baidu, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from qianfan.model.configs import DeployConfig | ||
from qianfan.model.model import Model, Service | ||
|
||
__all__ = ["Model", "Service", "DeployConfig"] |
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,37 @@ | ||
from typing import Any | ||
|
||
from pydantic import BaseModel | ||
|
||
from qianfan.model.consts import ServiceType | ||
from qianfan.resources.console import consts as console_consts | ||
|
||
|
||
class DeployConfig(BaseModel): | ||
name: str = "" | ||
""" | ||
Service name | ||
""" | ||
endpoint_prefix: str = "" | ||
""" | ||
Endpoint custom prefix, will be used to call resource api | ||
""" | ||
description: str = "" | ||
""" | ||
description of service | ||
""" | ||
replicas: int = 1 | ||
""" | ||
replicas for model services, related to the capacity in QPS of model service. | ||
default set to 1 | ||
""" | ||
pool_type: console_consts.DeployPoolType = ( | ||
console_consts.DeployPoolType.PrivateResource | ||
) | ||
""" | ||
resource pool type, public resource will be shared with others. | ||
""" | ||
service_type: ServiceType | ||
""" | ||
service type, after deploy, Service could behave like the specific type. | ||
""" | ||
extras: Any = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2023 Baidu, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from enum import Enum | ||
|
||
|
||
class ServiceType(str, Enum): | ||
Chat = "Chat" | ||
"""Corresponding to the `ChatCompletion`""" | ||
Completion = "Completion" | ||
"""Corresponding to the `Completion`""" | ||
Embedding = "Embedding" | ||
"""Corresponding to the `Embedding`""" | ||
Text2Image = "Text2Image" | ||
"""Corresponding to the `Text2Image""" |
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.