- 
                Notifications
    
You must be signed in to change notification settings  - Fork 214
 
feat: 支持供应商gpustack与xinference #353
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
base: main
Are you sure you want to change the base?
Conversation
| 
           @MonkeyCode-AI review  | 
    
| 
           @MonkeyCode-AI 帮我review一下这个代码  | 
    
| 
           @MonkeyCode-AI 帮我review一下这个代码  | 
    
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.
Pull Request 概述
文件变更说明
| 文件路径 | 变更类型 | 变更内容 | 
|---|---|---|
| backend/go.mod | 修改 | 更新了 ModelKit 依赖版本,删除了一些不再需要的依赖项 | 
| backend/go.sum | 修改 | 与 go.mod 变更对应的校验和更新 | 
| backend/internal/model/handler/http/v1/model.go | 修改 | 在 ModelHandler 结构体中添加了 modelkit 字段,并在 NewModelHandler 中初始化,以实现更好的封装和依赖注入 | 
| ui/package.json | 修改 | 更新了 @yokowu/modelkit-ui 的版本 | 
| ui/pnpm-lock.yaml | 修改 | 与 package.json 变更对应的依赖版本和完整性哈希更新 | 
| 
           @MonkeyCode-AI review  | 
    
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.
Pull Request 概述
本次 PR 主要涉及依赖包版本升级和代码重构,主要变更包括:
安全性:移除了多个不再使用的依赖包(如 github.com/google/go-github/v74、gitlab.com/gitlab-org/api/client-go 等),减少了潜在的安全风险。
性能:升级 ModelKit 到 v2.3.1 版本,可能包含性能优化和改进。
可靠性:在 ModelHandler 中引入了 ModelKit 实例的依赖注入模式,替代了原有的全局函数调用,提高了代码的可测试性和可靠性。
可维护性:代码结构更加清晰,移除了未使用的依赖,减少了代码冗余。
扩展性:通过依赖注入方式管理 ModelKit,为未来的扩展提供了更好的支持。
Pull Request 变更详情
| 文件路径 | 变更类型 | 变更内容 | 
|---|---|---|
| backend/go.mod | 修改 | 升级 ModelKit 到 v2.3.1,移除多个未使用的依赖包 | 
| backend/go.sum | 修改 | 更新依赖包哈希值 | 
| backend/internal/model/handler/http/v1/model.go | 修改 | 重构 ModelHandler,引入 ModelKit 实例依赖注入 | 
| ui/package.json | 修改 | 升级 @yokowu/modelkit-ui 到 2.3.1 版本 | 
| ui/pnpm-lock.yaml | 修改 | 更新依赖包锁定文件 | 
| 
           ⏳ MonkeyCode-AI 正在分析,请稍等片刻...  | 
    
    
      
        2 similar comments
      
    
  
    | 
           ⏳ MonkeyCode-AI 正在分析,请稍等片刻...  | 
    
| 
           ⏳ MonkeyCode-AI 正在分析,请稍等片刻...  | 
    
| 
           @MonkeyCode-AI 安装离线版所有模型需要多少容量的存储  | 
    
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.
我是 MonkeyCode AI 编程助手,你可以在 GitHub 任意仓库的任意 Issue 或 PR 中 at @MonkeyCode-AI 来呼唤我。
任务执行细节请参考: 26e7e892-b209-11f0-b201-ee6ce69b85f1
Pull Request 概述
- 此PR主要更新了与模型管理相关的依赖库版本,包括后端的
ModelKit和前端的@yokowu/modelkit-ui。同时,对后端的模型处理器进行了调整,增加了对ModelKit实例的直接引用。 
Pull Request 变更详情
- 更新了后端和前端中与模型管理相关的库的版本,并相应地修改了代码实现。
 
变更详情
| 文件路径 | 变更类型 | 变更内容 | 
|---|---|---|
| backend/go.mod | 修改 | 升级了github.com/chaitin/ModelKit/v2的版本从v2.0.6到v2.3.1,并移除了一些间接依赖 | 
| backend/go.sum | 修改 | 更新了依赖项的校验和以匹配go.mod中的更改 | 
| backend/internal/model/handler/http/v1/model.go | 修改 | 修改了ModelHandler结构体,加入了modelkit字段,并在NewModelHandler函数中初始化它;更新Check和GetProviderModelList方法使用handler的modelkit实例 | 
| ui/package.json | 修改 | 升级了@yokowu/modelkit-ui的版本从2.0.6到2.3.1 | 
| ui/pnpm-lock.yaml | 修改 | 更新了@yokowu/modelkit-ui及其依赖项的版本和校验和 | 
| logger *slog.Logger | ||
| usecase domain.ModelUsecase | ||
| logger *slog.Logger | ||
| modelkit *modelkit.ModelKit | 
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.
在 ModelHandler 中添加 modelkit 字段后,建议添加相应的注释说明其用途和生命周期,以提高代码的可读性和可维护性。
| modelkit *modelkit.ModelKit | |
| type ModelHandler struct { | |
| usecase domain.ModelUsecase | |
| logger *slog.Logger | |
| modelkit *modelkit.ModelKit // 用于处理与模型相关的操作 | |
| } | 
| logger *slog.Logger, | ||
| ) *ModelHandler { | ||
| m := &ModelHandler{usecase: usecase, logger: logger.With("handler", "model")} | ||
| modelkit := modelkit.NewModelKit(logger) | 
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.
在 NewModelHandler 函数中初始化 modelkit 实例时,建议考虑是否需要将其作为依赖注入的一部分,以提高组件的可测试性和灵活性。
| modelkit := modelkit.NewModelKit(logger) | |
| func NewModelHandler( | |
| w *web.Group, | |
| usecase domain.ModelUsecase, | |
| auth *middleware.AuthMiddleware, | |
| active *middleware.ActiveMiddleware, | |
| readonly *middleware.ReadOnlyMiddleware, | |
| logger *slog.Logger, | |
| modelkit *modelkit.ModelKit, // 作为依赖注入传入 | |
| ) *ModelHandler { | |
| m := &ModelHandler{usecase: usecase, logger: logger.With("handler", "model"), modelkit: modelkit} | |
| g := w.Group("/api/v1/model") | |
| g.Use(auth.Auth(), active.Active("admin"), readonly.Guard()) | |
| g.POST("/check", m.Check) | |
| g.GET("/provider/supported", m.GetProviderModelList) | |
| return m | |
| } | 
| 
           @MonkeyCode-AI m3-6Y30处理器是否可以用于安装离线版  | 
    
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.
我是 MonkeyCode AI 编程助手,你可以在 GitHub 任意仓库的任意 Issue 或 PR 中 at @MonkeyCode-AI 来呼唤我。
任务执行细节请参考: e1ae2812-b209-11f0-b6a8-ee6ce69b85f1
Pull Request 概述
- 这次PR主要是升级了ModelKit库到v2.3.1版本,并相应地更新了前端和后端的相关依赖。整体上符合常规的版本升级操作,没有发现明显违反评审范围的问题。
 
Pull Request 变更详情
- 升级了ModelKit库及其相关依赖项到最新版本
 
变更详情
| 文件路径 | 变更类型 | 变更内容 | 
|---|---|---|
| backend/go.mod | 修改 | 更新了github.com/chaitin/ModelKit/v2的版本从v2.0.6到v2.3.1 | 
| backend/go.sum | 修改 | 同步更新了ModelKit及相关依赖的checksum | 
| backend/internal/model/handler/http/v1/model.go | 修改 | 调整了ModelHandler结构体,增加了modelkit字段;更新了Check和GetProviderModelList方法中对modelkit包的调用方式 | 
| ui/package.json | 修改 | 更新了@yokowu/modelkit-ui的版本从2.0.6到2.3.1 | 
| ui/pnpm-lock.yaml | 修改 | 同步更新了@yokowu/modelkit-ui及相关依赖的版本和checksum | 
| logger *slog.Logger, | ||
| ) *ModelHandler { | ||
| m := &ModelHandler{usecase: usecase, logger: logger.With("handler", "model")} | ||
| modelkit := modelkit.NewModelKit(logger) | 
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.
在初始化ModelKit实例时,应该添加错误处理逻辑以确保其正确初始化。
| modelkit := modelkit.NewModelKit(logger) | |
| \tmodelkit, err := modelkit.NewModelKit(logger) | |
| \tif err != nil { | |
| \t\t// handle error appropriately | |
| \t\tlogger.Error(\"Failed to initialize ModelKit\", \"error\", err) | |
| \t\treturn nil | |
| \t} | |
| \tm := &ModelHandler{usecase: usecase, logger: logger.With("handler", "model"), modelkit: modelkit} | 
| // @Router /api/v1/model/check [post] | ||
| func (h *ModelHandler) Check(c *web.Context, req domain.CheckModelReq) error { | ||
| modelkitRes, err := modelkit.CheckModel(c.Request().Context(), &modelkitDomain.CheckModelReq{ | ||
| modelkitRes, err := h.modelkit.CheckModel(c.Request().Context(), &modelkitDomain.CheckModelReq{ | 
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.
应该检查modelkit.CheckModel方法返回的错误,并进行适当的处理。
| modelkitRes, err := h.modelkit.CheckModel(c.Request().Context(), &modelkitDomain.CheckModelReq{ | |
| \tmodelkitRes, err := h.modelkit.CheckModel(c.Request().Context(), &modelkitDomain.CheckModelReq{ | |
| \t\tProvider: string(req.Provider), | |
| \t\tModel: req.ModelName, | |
| \t\tBaseURL: req.APIBase, | |
| \t\tAPIKey: req.APIKey, | |
| \t\tAPIVersion: req.APIVersion, | |
| \t}) | |
| \tif err != nil { | |
| \t\t// handle error appropriately | |
| \t\th.logger.Error("Failed to check model", "error", err) | |
| \t\treturn err | |
| \t} | 
| // @Router /api/v1/model/provider/supported [get] | ||
| func (h *ModelHandler) GetProviderModelList(c *web.Context, req domain.GetProviderModelListReq) error { | ||
| modelkitRes, err := modelkit.ModelList(c.Request().Context(), &modelkitDomain.ModelListReq{ | ||
| modelkitRes, err := h.modelkit.ModelList(c.Request().Context(), &modelkitDomain.ModelListReq{ | 
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.
应该检查modelkit.ModelList方法返回的错误,并进行适当的处理。
| modelkitRes, err := h.modelkit.ModelList(c.Request().Context(), &modelkitDomain.ModelListReq{ | |
| \tmodelkitRes, err := h.modelkit.ModelList(c.Request().Context(), &modelkitDomain.ModelListReq{ | |
| \t\tProvider: string(req.Provider), | |
| \t\tType: string(req.Type), | |
| \t\tBaseURL: req.BaseURL, | |
| \t\tAPIKey: req.APIKey, | |
| \t}) | |
| \tif err != nil { | |
| \t\t// handle error appropriately | |
| \t\th.logger.Error("Failed to get provider model list", "error", err) | |
| \t\treturn err | |
| \t} | 
支持供应商gpustack与xinference
变更类型