Skip to content

Conversation

@coltea
Copy link
Collaborator

@coltea coltea commented Nov 7, 2025

PR 标题

支持重新学习功能

相关 Issue

变更类型

请勾选适用的变更类型:

  • Bug 修复 (不兼容变更的修复)
  • 新功能 (不兼容变更的新功能)
  • 功能改进 (不兼容现有功能的改进)
  • 文档更新
  • 依赖更新
  • 重构 (不影响功能的代码修改)
  • 测试用例
  • CI/CD 配置变更
  • 其他 (请描述):

变更内容

详细描述本次 PR 的具体变更内容:

  1. 支持重新学习功能

测试情况

描述本次变更的测试情况:

  • 已本地测试
  • 已添加测试用例
  • 不需要测试 (理由: )

其他说明

任何其他需要说明的事项:

@xiaomakuaiz xiaomakuaiz requested a review from Copilot November 7, 2025 04:21
Copy link
Contributor

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

This PR adds a new "restudy" endpoint that allows nodes to be re-studied by updating their vector representations in the RAG system.

  • Adds new NodeRestudy API endpoint at /api/v1/node/restudy
  • Implements business logic to fetch node releases and trigger vector updates
  • Updates Swagger documentation to reflect the new endpoint

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
backend/api/node/v1/node.go Defines request and response structs for the restudy endpoint
backend/handler/v1/node.go Adds HTTP handler for the restudy endpoint with validation
backend/usecase/node.go Implements the NodeRestudy business logic to update node vectors
backend/docs/swagger.yaml Auto-generated Swagger YAML documentation
backend/docs/swagger.json Auto-generated Swagger JSON documentation
backend/docs/docs.go Auto-generated Swagger Go documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xiaomakuaiz
Copy link
Collaborator

  • Bug (blocking) api/node/v1/node.go:60 – NodeRestudyReq never marks either kb_id or node_ids as required. The handler
    calls c.Validate(req), but with no tags the validator is a no-op, so /api/v1/node/restudy happily accepts {}. That bubbles
    down to the use case and produces a broken DB query (see next finding) instead of a clean 400. Please add the appropriate
    validate:"required" (and likely min=1 for the slice) tags so bad inputs are rejected at the edge.
  • Bug (blocking) usecase/node.go:577 – we pass req.NodeIds straight into GetLatestNodeReleaseByNodeIDs. When that slice is empty
    (which is allowed today because validation doesn’t stop it, or if callers accidentally send an empty list), GORM will build a
    WHERE node_id IN (?) with no values and Postgres will throw a syntax error. We should short-circuit (if len(req.NodeIds) == 0
    { return nil }) before calling the repo, so the API doesn’t return 500s for an empty payload even after validation is fixed.

@xiaomakuaiz xiaomakuaiz merged commit 40c3954 into chaitin:main Nov 10, 2025
4 checks passed
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.

2 participants