Skip to content

[app-platform] Add open source knowledge repo impl.#564

Merged
loveTsong merged 5 commits intoModelEngine-Group:1.3.xfrom
RonnyChan96:1.3.x_add_open_source_knowledge_repo
Feb 6, 2026
Merged

[app-platform] Add open source knowledge repo impl.#564
loveTsong merged 5 commits intoModelEngine-Group:1.3.xfrom
RonnyChan96:1.3.x_add_open_source_knowledge_repo

Conversation

@RonnyChan96
Copy link
Contributor

🔗 相关问题 / Related Issue

Issue 链接 / Issue Link: #563

  • 我已经创建了相关 Issue 并进行了讨论 / I have created and discussed the related issue
  • 这是一个微小的修改(如错别字),不需要 Issue / This is a trivial change (like typo fix) that doesn't need an issue

📋 变更类型 / Type of Change

  • 🐛 Bug 修复 / Bug fix (non-breaking change which fixes an issue)
  • ✨ 新功能 / New feature (non-breaking change which adds functionality)
  • 💥 破坏性变更 / Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 文档更新 / Documentation update
  • 🔧 重构 / Refactoring (no functional changes)
  • ⚡ 性能优化 / Performance improvement
  • 📦 依赖升级 / Dependency upgrade (update dependencies to newer versions)
  • 🚀 功能增强 / Feature enhancement (improve existing functionality without breaking changes)
  • 🧹 代码清理 / Code cleanup

📝 变更目的 / Purpose of the Change

适配DataMate的知识库接口,提供新的知识库实现

📋 主要变更 / Brief Changelog

  • 增加新的KnowledgeServiceImpl
  • 对接DataMate的接口

🧪 验证变更 / Verifying this Change

测试步骤 / Test Steps

  1. 本地启动连接云端DataMate接口调试。

测试覆盖 / Test Coverage

  • 我已经添加了单元测试 / I have added unit tests
  • 所有现有测试都通过 / All existing tests pass
  • 我已经进行了手动测试 / I have performed manual testing

📸 截图 / Screenshots

✅ 贡献者检查清单 / Contributor Checklist

请确保你的 Pull Request 符合以下要求 / Please ensure your Pull Request meets the following requirements:

基本要求 / Basic Requirements:

  • 确保有 GitHub Issue 对应这个变更(微小变更如错别字除外)/ Make sure there is a Github issue filed for the change (trivial changes like typos excluded)
  • 你的 Pull Request 只解决一个 Issue,没有包含其他不相关的变更 / Your PR addresses just this issue, without pulling in other changes - one PR resolves one issue
  • PR 中的每个 commit 都有有意义的主题行和描述 / Each commit in the PR has a meaningful subject line and body

代码质量 / Code Quality:

  • 我的代码遵循项目的代码规范 / My code follows the project's coding standards
  • 我已经进行了自我代码审查 / I have performed a self-review of my code
  • 我已经为复杂的代码添加了必要的注释 / I have commented my code, particularly in hard-to-understand areas

测试要求 / Testing Requirements:

  • 我已经编写了必要的单元测试来验证逻辑正确性 / I have written necessary unit-tests to verify the logic correction
  • 当存在跨模块依赖时,我尽量使用了 mock / I have used mocks when cross-module dependencies exist
  • 基础检查通过:mvn -B clean package -Dmaven.test.skip=truenpm install --force && npm run build:pro / Basic checks pass
  • 单元测试通过:mvn clean install / Unit tests pass

文档和兼容性 / Documentation and Compatibility:

  • 我已经更新了相应的文档 / I have made corresponding changes to the documentation
  • 如果有破坏性变更,我已经在 PR 描述中详细说明 / If there are breaking changes, I have documented them in detail
  • 我已经考虑了向后兼容性 / I have considered backward compatibility

📋 附加信息 / Additional Notes


审查者注意事项 / Reviewer Notes:

@RonnyChan96 RonnyChan96 added this to the 1.3.2 milestone Dec 15, 2025
@RonnyChan96 RonnyChan96 self-assigned this Dec 15, 2025
@RonnyChan96 RonnyChan96 added in: builder Issues in app-builder modules type: feature A general feature labels Dec 15, 2025
@CodeCasterX
Copy link
Member

里程碑和目标分支不匹配

@RonnyChan96 RonnyChan96 changed the base branch from main to 1.3.x December 16, 2025 01:10
@RonnyChan96
Copy link
Contributor Author

里程碑和目标分支不匹配

fix

/**
* 返回前多少的条目。
*/
@Property(description = "topK", name = "topK")
Copy link
Contributor

Choose a reason for hiding this comment

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

image 字段间需要换行

@Property(description = "topK", name = "topK")
private Integer topK;
/**
* 相关性阈值。
Copy link
Contributor

Choose a reason for hiding this comment

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

Uploading image.png…
字段间需要换行

* 知识库描述。
*/
private String description;
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

同上,字段间需要换行

private String createdAt;
/**
* 知识库更新时间。
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

同上,字段间需要换行

package modelengine.fit.jade.datamate.knowledge.knowledge.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

Copy link
Contributor

Choose a reason for hiding this comment

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

去除无用空格


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Data;
Copy link
Contributor

Choose a reason for hiding this comment

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

去除无用空格


import lombok.Builder;
import lombok.Data;

Copy link
Contributor

Choose a reason for hiding this comment

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

去除无用空格

private final HttpClassicClientFactory httpClientFactory;
private final LazyLoader<HttpClassicClient> httpClient;
private final Map<Integer, KnowledgeManagerRetCode> exceptionMap = new HashMap<>();

Copy link
Contributor

Choose a reason for hiding this comment

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

public属性的方法需要添加注释


private final DataMateKnowledgeBaseManager knowledgeBaseManager;
private final KnowledgeI18nService knowledgeI18nService;

Copy link
Contributor

Choose a reason for hiding this comment

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

public属性的方法需要添加注释

DataMateResponse.from(response, DataMateKnowledgeListEntity.class);
return Validation.notNull(resp.getData(), "The response body is abnormal.");
} catch (ClientException ex) {
log.error(QUERY_KNOWLEDGE_LIST_ERROR.getMsg(), ex.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

image log.error中建议传Throwable

return Validation.notNull(resp.getData(), "The response body is abnormal.");
} catch (ClientException ex) {
log.error(QUERY_KNOWLEDGE_LIST_ERROR.getMsg(), ex.getMessage());
throw new KnowledgeException(QUERY_KNOWLEDGE_LIST_ERROR, ex.getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

建议在抛出 KnowledgeException时也尽量保留原始异常信息,保留cause

@loveTsong loveTsong modified the milestones: 1.3.2, 1.3.3 Jan 29, 2026
- 'modelengine.fit.jade.datamate.knowledge'
datamate:
url:
list: 'https://datamate.dallas98.top:30000/api/knowledge-base/list'
Copy link
Contributor

Choose a reason for hiding this comment

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

Image 这里默认建议使用datamate在ME集群中的服务名地址替换,不要防止测试用地址

Copy link
Contributor

Choose a reason for hiding this comment

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

需要继续修改为合适的默认值:https://datamate-gateway:8080

* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

package modelengine.fit.jade.datamate.knowledge.knowledge.service;
Copy link
Contributor

Choose a reason for hiding this comment

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

Image 包路径中出现了重复的 `knowledge`,删除多余的一层`knowledge`目录

* @since 2025-12-15
*/
@Component
public class DataMateKnowledgeRepoServiceImpl implements KnowledgeRepoService {
Copy link
Contributor

Choose a reason for hiding this comment

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

Image 关键实现缺少单元测试覆盖

HttpClassicClientRequest request =
this.httpClient.get().createRequest(HttpRequestMethod.POST, this.dataMateUrls.get("list"));
request.entity(Entity.createObject(request, param));
request.headers().set(AUTHORIZATION, BEARER + apiKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

Image 上层允许apiKey为空,这里建议为空或null时不传入 该鉴权header,这样更加符合使用规范。

HttpClassicClientRequest request =
this.httpClient.get().createRequest(HttpRequestMethod.POST, this.dataMateUrls.get("retrieve"));
request.entity(Entity.createObject(request, param));
request.headers().set(AUTHORIZATION, BEARER + apiKey);
Copy link
Contributor

Choose a reason for hiding this comment

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

上层允许apiKey为空,这里建议为空或null时不传入 该鉴权header,这样更加符合使用规范。

return new KnowledgeException(this.exceptionMap.get(statusCode), ex, ex.getSimpleMessage());
}

private HttpClassicClient getHttpClient() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Image 建议增加访问的超时时间配置,增强对异常场景的处理,以及可针对用户场景实现自定义配置。比如:默认超时时间设置为30s,同时支持配置文件可配置。

Copy link
Contributor

@loveTsong loveTsong left a comment

Choose a reason for hiding this comment

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

pl fix it

loveTsong
loveTsong previously approved these changes Feb 6, 2026
@loveTsong loveTsong merged commit 0696f02 into ModelEngine-Group:1.3.x Feb 6, 2026
2 checks passed
@loveTsong loveTsong linked an issue Feb 6, 2026 that may be closed by this pull request
4 tasks
private KnowledgeException handleException(HttpClientResponseException ex) {
int statusCode = ex.statusCode();
log.error(this.exceptionMap.get(statusCode).getMsg(), ex);
return new KnowledgeException(this.exceptionMap.get(statusCode), ex, ex.getSimpleMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

如果错误码在exceptionMap中不存在,则会出现空指针异常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: builder Issues in app-builder modules type: feature A general feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

适配DataMate的知识库接口

5 participants