-
Notifications
You must be signed in to change notification settings - Fork 6
Feat reranker embeddinig #88
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a48ac79
feat: reranker
jiangwel 4aad0dc
feat: bailian embedding
jiangwel 9aae602
feat(embedder): 添加扩展的嵌入字符串接口及实现
jiangwel 1af266b
refactor(embedding): 简化嵌入响应结构并更新相关文档和测试
jiangwel 799c8cc
feat: 重构embedder模块并添加测试用例
jiangwel 26e40df
docs: 更新README并添加Chat模型使用文档
jiangwel cbe3264
fix: 修复HTTP响应体关闭错误处理问题
jiangwel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ ui/ModelModal/dist | |
| .DS_Store | ||
| test/ui_example/dist | ||
| books | ||
| test/.env | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,222 +1,15 @@ | ||
| # ModelKit | ||
| # ModelKit: 大模型API SDK | ||
| ModelKit是一个大模型API SDK, 支持Chat、Embedding、Rerank模型, 支持OpenAI Api, DashScope Api, Ollama Api. | ||
|
|
||
| [](https://golang.org) | ||
| [](https://reactjs.org) | ||
| [](LICENSE) | ||
| ## 教程 | ||
| [使用Chat模型](docs/Chat.md) | ||
|
|
||
| ModelKit 是一个强大的AI模型管理平台,支持多种AI服务提供商,提供统一的模型管理、配置验证服务。 | ||
| [使用Embedding模型](docs/Embedding.md) | ||
|
|
||
| ## 🚀 功能特性 | ||
| [使用Rerank模型](docs/Rerank.md) | ||
|
|
||
| - **多模型提供商支持**: 支持 OpenAI、Ollama、DeepSeek、SiliconFlow、Moonshot、Azure OpenAI、百智云、腾讯混元、百炼、火山引擎、Gemini、智谱等主流AI服务商 | ||
| - **模型类型管理**: 支持聊天模型、嵌入模型、重排序模型、视觉模型、代码模型、函数调用等多种模型类型 | ||
| - **配置验证**: 提供模型配置的实时验证功能,确保API配置正确性 | ||
| - **现代化Web界面**: 基于React 19和Material-UI构建的响应式用户界面 | ||
| - **国际化支持**: 内置中英文多语言支持 | ||
| - **可复用组件**: 提供开箱即用的ModelModal组件,支持在其他项目中快速集成 | ||
|
|
||
| ## ⚡️ 界面展示 | ||
|
|
||
| | 添加模型 | 模型列表 | | ||
| | ------------------------------------------------ | ------------------------------------------------ | | ||
| | <img src="./images/image_add_model.jpg" width=370 /> | <img src="./images/image_list_model.jpg" width=370 /> | | ||
|
|
||
| ## 快速开始 | ||
| 1. 加载modelkit前后端依赖 | ||
| 2. 后端实现ListModel,CreateModel,UpdateModel,CheckModel 4个接口, 其中ListModel, CheckModel已提供业务逻辑,在handler中调用即可 | ||
| 3. 用这4个接口实现前端前端ModelService接口,传入modelkit-ui组件即可使用 | ||
|
|
||
| ## Usage | ||
|
|
||
| ### 1. 安装依赖 | ||
|
|
||
| #### 后端依赖 | ||
| ```bash | ||
| go get github.com/chaitin/ModelKit/v2 | ||
| go get github.com/labstack/echo/v4 | ||
| go get github.com/go-playground/validator/v10 | ||
| ``` | ||
|
|
||
| #### 前端依赖 | ||
| ```bash | ||
| npm install @ctzhian/modelkit | ||
| # 或 | ||
| yarn add @ctzhian/modelkit | ||
| ``` | ||
|
|
||
| ### 2. 实现接口 | ||
|
|
||
| 需要实现以下4个接口,其中 `listModel` 和 `checkModel` 已提供业务逻辑,在handler中调用即可: | ||
| + `listModel`:获取模型列表 | ||
| + `checkModel`:检查模型配置 | ||
| + `createModel`:创建模型 | ||
| + `updateModel`:更新模型 | ||
|
|
||
| ### 3. 后端使用方式 | ||
|
|
||
| 在handler中调用 `listModel` 与 `checkModel` 业务逻辑: | ||
|
|
||
| ```go | ||
| package v1 | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "github.com/chaitin/ModelKit/v2/domain" | ||
| modelkit "github.com/chaitin/ModelKit/v2/usecase" | ||
| "github.com/labstack/echo/v4" | ||
| ) | ||
|
|
||
| modelkit := modelkit.NewModelKit(logger.Logger) | ||
|
|
||
| // GetModelList 获取模型列表 | ||
| func (m *ModelKit) GetModelList(c echo.Context) error { | ||
| var req domain.ModelListReq | ||
| if err := c.Bind(&req); err != nil { | ||
| return c.JSON(http.StatusBadRequest, domain.Response{ | ||
| Success: false, | ||
| Message: "参数绑定失败: " + err.Error(), | ||
| }) | ||
| } | ||
|
|
||
| // 调用ModelKit提供的业务逻辑 | ||
| resp, err := modelkit.ModelList(c.Request().Context(), &req) | ||
| if err != nil { | ||
| return c.JSON(http.StatusInternalServerError, domain.Response{ | ||
| Success: false, | ||
| Message: err.Error(), | ||
| }) | ||
| } | ||
|
|
||
| return c.JSON(http.StatusOK, domain.Response{ | ||
| Success: true, | ||
| Message: "获取模型列表成功", | ||
| Data: resp, | ||
| }) | ||
| } | ||
|
|
||
| // CheckModel 检查模型 | ||
| func (m *ModelKit) CheckModel(c echo.Context) error { | ||
| var req domain.CheckModelReq | ||
| if err := c.Bind(&req); err != nil { | ||
| return c.JSON(http.StatusBadRequest, domain.Response{ | ||
| Success: false, | ||
| Message: "参数绑定失败: " + err.Error(), | ||
| }) | ||
| } | ||
|
|
||
| // 调用ModelKit提供的业务逻辑 | ||
| resp, err := modelkit.CheckModel(c.Request().Context(), &req) | ||
| if err != nil { | ||
| return c.JSON(http.StatusInternalServerError, domain.Response{ | ||
| Success: false, | ||
| Message: err.Error(), | ||
| }) | ||
| } | ||
|
|
||
| if resp.Error != "" { | ||
| return c.JSON(http.StatusBadRequest, domain.Response{ | ||
| Success: false, | ||
| Message: "模型检查失败", | ||
| Data: resp, | ||
| }) | ||
| } | ||
|
|
||
| return c.JSON(http.StatusOK, domain.Response{ | ||
| Success: true, | ||
| Message: "模型检查成功", | ||
| Data: resp, | ||
| }) | ||
| } | ||
|
|
||
| // CreateModel 创建模型 (需要自行实现业务逻辑) | ||
| func (m *ModelKit) CreateModel(c echo.Context) error { | ||
| // 实现创建模型的业务逻辑 | ||
| // ... | ||
| } | ||
|
|
||
| // UpdateModel 更新模型 (需要自行实现业务逻辑) | ||
| func (m *ModelKit) UpdateModel(c echo.Context) error { | ||
| // 实现更新模型的业务逻辑 | ||
| // ... | ||
| } | ||
| ``` | ||
|
|
||
| ### 4. 前端使用方式 | ||
|
|
||
| ```typescript | ||
| // 1. 引入ModelKit组件和类型 | ||
| import { | ||
| ModelModal, | ||
| Model, | ||
| ModelService, | ||
| ConstsModelType as ModelKitType, | ||
| ModelListItem | ||
| } from '@yokowu/modelkit-ui'; | ||
|
|
||
| // 2. 创建符合ModelService接口的服务实现 | ||
| const modelService: ModelService = { | ||
| createModel: async (params) => { | ||
| const response = await postCreateModel(params as unknown as DomainCreateModelReq); | ||
| return { model: response as unknown as Model }; | ||
| }, | ||
| listModel: async (params) => { | ||
| const response = await getGetProviderModelList(params as unknown as GetGetProviderModelListParams); | ||
| return { models: response?.models || [] }; | ||
| }, | ||
| checkModel: async (params) => { | ||
| const response = await postCheckModel(params as unknown as DomainCheckModelReq); | ||
| return { model: response as unknown as Model }; | ||
| }, | ||
| updateModel: async (params) => { | ||
| const response = await putUpdateModel(params as unknown as DomainUpdateModelReq); | ||
| return { model: response as unknown as Model }; | ||
| } | ||
| }; | ||
|
|
||
| // 3. 使用ModelModal组件 | ||
| function App() { | ||
| const [open, setOpen] = useState(false); | ||
| const [editData, setEditData] = useState<Model | null>(null); | ||
| const [modelType, setModelType] = useState<ModelKitType>(ModelKitType.CHAT); | ||
|
|
||
| const refreshModel = () => { | ||
| // 刷新模型列表的逻辑 | ||
| }; | ||
|
|
||
| return ( | ||
| <ModelModal | ||
| open={open} | ||
| onClose={() => { | ||
| setOpen(false); | ||
| setEditData(null); | ||
| }} | ||
| refresh={refreshModel} | ||
| data={editData} | ||
| type={modelType} | ||
| modelService={modelService} | ||
| language="zh-CN" | ||
| /> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ### 开发环境设置 | ||
|
|
||
| 1. **后端开发** | ||
| ```bash | ||
| go mod tidy | ||
| ``` | ||
|
|
||
| 2. **前端开发** | ||
| ```bash | ||
| cd ui/ModelModal | ||
| pnpm install | ||
| ``` | ||
| [使用模型管理组件](docs/ModelModal.md) | ||
|
|
||
| ## 🙏 致谢 | ||
|
|
||
| 感谢所有为ModelKit项目做出贡献的开发者和用户! | ||
|
|
||
| --- | ||
|
|
||
| **ModelKit** - 让AI模型管理更简单 🚀 | ||
| eino项目 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.