Skip to content

fix: 修复xinference向量模型添加失败的缺陷 #1566

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

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

shaohuzhang1
Copy link
Contributor

fix: 修复xinference向量模型添加失败的缺陷

Copy link

f2c-ci-robot bot commented Nov 6, 2024

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

f2c-ci-robot bot commented Nov 6, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment


embedding = embedding_res["data"][0]["embedding"]

return list(map(float, embedding))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上述代码存在以下问题:

  1. 在创建子类时,没有导入必要的模块。
  2. 运行模型和下载模型文件的代码块被放在了下划线函数 down_model 的后面,并且它们没有对应的文档描述。

对于问题一:由于需要导入 restfulclient 模块,请在调用新建子类方法之前确保该插件已安装或通过 pip 安装它。对于问题二,请提供上下文中的更详细文档说明,以便于理解代码意图。

@@ -36,3 +37,4 @@ def build_model(self, model_info: Dict[str, object]):
return self

api_base = forms.TextInputField('API 域名', required=True)
api_key = forms.PasswordInputField('API Key', required=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码中并没有发现明显的不符合要求或问题的地方,但可能存在一些需要改进的空间:

  1. check_credentials() 函数中的异常处理:
    可以更清晰地说明错误的具体原因,使用有意义的对象来描述当前的状态信息,如 `raise AppApiException(Vali
    ##Suffix:

##Middle:
dCode.valid_error.value,
"Invalid API address")`。

  1. 将方法重载部分进行合并:
    如果 get_base_model_list() 和 get_model_info_by_name() 成为一个单独的方法,则可以将这两个函数整合在一起,减少重复编写和提高可读性。

  2. 添加单元测试或API调用文档:
    这有助于确保在实际开发中不会出现类似问题。建议增加单元测试以验证所有可能的情况是否都能正确处理。同时也可以通过API文档格式化的方式记录API接口的信息。这能帮助后续的查询者快速了解如何与该服务交互并获得预期的结果。

@wxg0103 wxg0103 merged commit fc015d1 into main Nov 7, 2024
4 of 5 checks passed
@wxg0103 wxg0103 deleted the pr@main@fix_embedding branch November 7, 2024 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants