-
Notifications
You must be signed in to change notification settings - Fork 118
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
增加模型列表获取的SDK #29
增加模型列表获取的SDK #29
Conversation
|
||
""" | ||
response = appbuilder.get_model_list(apiTypefilter=["chat"]) | ||
self.assertIsNotNone(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只验证 返回是否为空, 需要进一步校验返回值的正确性
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apiTypefilter=["chat"], filter的chat是什么含义
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
就是只返回千帆的对话Chat模型
appbuilder/core/utils.py
Outdated
|
||
|
||
def utils_get_user_agent(): | ||
return 'appbuilder-sdk-python/{}'.format("__version__") | ||
|
||
|
||
def get_model_list(secret_key: str = "", apiTypefilter: List[str] = [], is_available: bool = False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_model_list函数的返回类型是不是也可以说明下
appbuilder/core/utils.py
Outdated
|
||
|
||
def utils_get_user_agent(): | ||
return 'appbuilder-sdk-python/{}'.format("__version__") | ||
|
||
|
||
def get_model_list(secret_key: str = "", apiTypefilter: List[str] = [], is_available: bool = False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数入参apiTypefilter,可以统一写成下划线
appbuilder/core/utils.py
Outdated
models = [] | ||
if is_available: | ||
for common_model in response.result.common: | ||
if common_model.chargeStatus in ["OPENED", "FREE"]: | ||
mapped_name = map_model_name(common_model.name) | ||
models.append(mapped_name) | ||
|
||
for custom_model in response.result.custom: | ||
if custom_model.chargeStatus in ["OPENED", "FREE"]: | ||
mapped_name = map_model_name(custom_model.name) | ||
models.append(mapped_name) | ||
return models | ||
else: | ||
for common_model in response.result.common: | ||
mapped_name = map_model_name(common_model.name) | ||
models.append(mapped_name) | ||
|
||
for custom_model in response.result.custom: | ||
mapped_name = map_model_name(custom_model.name) | ||
models.append(mapped_name) | ||
return models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以使用一个迭代器,将通用模型与定制化模型连接起来,再进行遍历
import itertools
for model in itertools.chain(response.result.common, response.result.custom):
if is_available and common_model.chargeStatus not in ["OPENED", "FREE"]:
continue
mapped_name = map_model_name(common_model.name)
models.append(mapped_name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
None | ||
|
||
""" | ||
response = appbuilder.get_model_list(apiTypefilter=["chat"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 函数命名是 小写, 参数是 驼峰, 需要统一
- apiTypefilter 缩短一下变量定义?
1、utils目录下新建model_util.py文件,包含Models工具类,提供list()方法
2、utils.py里面新建get_model_list()工具方法,供用户调用