Skip to content

补全 weixin-java-aispeech 知识助理 OpenAPI 能力并完善可扩展请求模型#4042

Merged
binarywang merged 7 commits into
developfrom
copilot/featurenew-weixin-java-aispeech-module
Jun 1, 2026
Merged

补全 weixin-java-aispeech 知识助理 OpenAPI 能力并完善可扩展请求模型#4042
binarywang merged 7 commits into
developfrom
copilot/featurenew-weixin-java-aispeech-module

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2026

当前 weixin-java-aispeech 已具备智能客服主链路,但知识助理侧仅覆盖了部分基础能力,无法完整承接官方文档中的核心知识管理流程。该改动补齐了缺失的知识接口组,并在 SDK 层增加 multipart 文件上传支持,统一扩展入口与数据模型。

  • 知识管理接口补全(按官方路径)

    • 新增文件建知识:POST /api/v1/knowledge-bases/:id/knowledge/file
    • 新增批量查知识:GET /api/v1/knowledge/batch
    • 新增手工知识更新:PUT /api/v1/knowledge/manual/:id
    • 新增知识移动与进度:POST /api/v1/knowledge/moveGET /api/v1/knowledge/move/progress/:task_id
    • 新增标签相关能力:
      • 批量更新知识标签:PUT /api/v1/knowledge/tags
      • 知识库标签创建/更新:POST|PUT /api/v1/knowledge-bases/:id/tags...
  • 服务层能力增强

    • WxAispeechServiceImpl 增加知识侧 multipart POST 执行能力,用于文件上传场景。
    • 优化知识请求头设置逻辑:仅在未显式设置时回填 Content-Type,避免 multipart 场景被 JSON 头覆盖。
  • API 与数据模型扩展

    • 扩展 WxAispeechKnowledgeService 契约,新增文件上传、批量查询、标签、移动任务等方法。
    • 新增知识领域 Bean:
      • KnowledgeMoveRequest
      • KnowledgeMoveProgress
      • KnowledgeTagRequest
    • 增强列表解析兼容性:支持直接数组与 data 包装两种响应结构。
  • 示例(新增能力调用)

    KnowledgeMoveRequest req = new KnowledgeMoveRequest();
    req.setKnowledgeIds(Arrays.asList("k1", "k2"));
    req.setSourceKnowledgeBaseId("kb_source");
    req.setTargetKnowledgeBaseId("kb_target");
    req.setMode("reuse_vectors");
    
    String moveResult = wxAispeechService.getKnowledgeService().moveKnowledge(req);
    KnowledgeMoveProgress progress =
        wxAispeechService.getKnowledgeService().getMoveProgress("task_id_from_moveResult");

Copilot AI changed the title [WIP] Add weixin-java-aispeech module for intelligent dialog API 补全 weixin-java-aispeech 知识助理 OpenAPI 能力并完善可扩展请求模型 Jun 1, 2026
@binarywang binarywang marked this pull request as ready for review June 1, 2026 02:07
Copilot AI review requested due to automatic review settings June 1, 2026 02:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf353516a4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


@Override
public KnowledgeInfo createKnowledgeByFile(String knowledgeBaseId, File file, String title, String description, String metadata)
throws WxErrorException {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Unwrap knowledge response data before deserializing

When these endpoints return the normal WeKnora shape ({"success":true,"data":{...}}, as used by create/get/update/delete handlers), deserializing the whole response directly into KnowledgeInfo leaves fields such as id null instead of returning the created/updated knowledge. The list helpers already unwrap data, but the single-object methods do not, so callers of file/URL/manual create and get/update receive empty objects on successful responses.

Useful? React with 👍 / 👎.

}

Map<String, String> query = new HashMap<>();
query.put("ids", joiner.toString());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Encode batch ids as repeated query parameters

When callers pass multiple IDs, this sends one query value like ids=k1,k2; the WeKnora batch handler binds ids as a query array, so Gin treats that as a single literal ID rather than splitting on commas. As a result /api/v1/knowledge/batch cannot find k1 and k2 separately, and multi-ID lookups return empty/missing results; this needs support for repeated ids=k1&ids=k2 parameters instead of a comma-joined Map value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 在 WxJava 体系中新增 weixin-java-aispeech 模块,并补齐「知识助理」OpenAPI 能力(含 multipart 文件上传),以便 SDK 可以覆盖官方知识管理的核心流程,同时补充了对话侧的基础模型与签名/加解密工具。

Changes:

  • 新增 weixin-java-aispeech 模块并纳入根工程与 BOM 统一管理。
  • 实现知识助理侧接口(批量查询、手工更新、移动任务、标签、文件上传 multipart POST)及相关请求/响应模型。
  • 增加 TestNG 测试用例与套件配置,覆盖签名、AES 加解密与知识接口调用路径。

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
wx-java-bom/pom.xml 在 BOM 中加入 weixin-java-aispeech 依赖,便于统一版本管理
pom.xml 根工程新增 weixin-java-aispeech module
weixin-java-aispeech/pom.xml 新模块 POM:依赖、TestNG surefire suite 配置
weixin-java-aispeech/src/test/resources/testng.xml 新模块 TestNG 套件配置
weixin-java-aispeech/src/test/java/me/chanjar/weixin/aispeech/util/WxAispeechSignUtilTest.java 签名与 AES 加解密单测
weixin-java-aispeech/src/test/java/me/chanjar/weixin/aispeech/api/impl/WxAispeechKnowledgeServiceImplTest.java 知识接口实现的单测(含 multipart、batch、move、tag)
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/util/WxAispeechSignUtil.java 对话/知识侧签名与 AES/CBC 工具实现
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/config/WxAispeechConfigStorage.java aispeech 模块配置存储接口定义
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/config/impl/WxAispeechDefaultConfigImpl.java 默认配置实现(baseUrl、代理等)
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/knowledge/KnowledgeUrlCreateRequest.java 知识 URL 创建请求模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/knowledge/KnowledgeUpdateRequest.java 知识更新请求模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/knowledge/KnowledgeTagRequest.java 标签请求模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/knowledge/KnowledgeMoveRequest.java 知识移动任务请求模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/knowledge/KnowledgeMoveProgress.java 知识移动任务进度模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/knowledge/KnowledgeManualCreateRequest.java 手工知识创建/更新请求模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/knowledge/KnowledgeListResult.java 知识列表响应包装模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/knowledge/KnowledgeInfo.java 知识实体模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/dialog/PublishProgress.java 发布进度模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/dialog/DialogResult.java 对话结果模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/dialog/DialogQueryRequest.java 对话查询请求模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/dialog/BotIntent.java 机器人意图模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/dialog/AsyncTaskResult.java 异步任务结果模型
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/bean/dialog/AispeechApiResponse.java 对话侧通用响应包装
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/api/WxAispeechService.java 模块顶层 service 接口定义
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/api/WxAispeechKnowledgeService.java 知识助理 service 契约扩展(新增 move/tag/batch/multipart 等)
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/api/WxAispeechDialogService.java 对话侧 service 契约
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/api/impl/WxAispeechServiceImpl.java HttpClient5 执行器实现(含知识侧 multipart 与签名头回填)
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/api/impl/WxAispeechServiceHttpComponentsImpl.java 兼容/扩展用的 HttpComponents 实现壳类
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/api/impl/WxAispeechServiceHttpClientImpl.java 兼容/扩展用的 HttpClient 实现壳类
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/api/impl/WxAispeechKnowledgeServiceImpl.java 知识助理 API 实现(batch/move/tag/上传等)
weixin-java-aispeech/src/main/java/me/chanjar/weixin/aispeech/api/impl/WxAispeechDialogServiceImpl.java 对话侧 API 实现(token/import/publish/query 等)

Comment thread weixin-java-aispeech/src/test/resources/testng.xml Outdated
Comment thread weixin-java-aispeech/pom.xml Outdated
binarywang and others added 4 commits June 1, 2026 21:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@binarywang binarywang merged commit d1f920c into develop Jun 1, 2026
1 check failed
@binarywang binarywang deleted the copilot/featurenew-weixin-java-aispeech-module branch June 1, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] 新建 weixin-java-aispeech 模块,承接智能对话(客服+知识助理)API

3 participants