package cmd import ( "fmt" "github.com/aisim/kb-cli/internal/classify" "github.com/spf13/cobra" ) var classifyCmd = &cobra.Command{ Use: "classify", Short: "使用 LLM 对知识库文档进行分类", Long: `使用本地 LLM 分析知识库文档,提取平台、设备、内容类型等信息。 输出: - entities.json: 实体定义(从 实体/ 目录提取) - relations.json: 实体关系 - classification.json: 文档分类结果`, RunE: runClassify, } var ( classifyBatchSize int classifyDryRun bool ) func init() { rootCmd.AddCommand(classifyCmd) classifyCmd.Flags().IntVar(&classifyBatchSize, "batch-size", 10, "每批处理的文档数量") classifyCmd.Flags().BoolVar(&classifyDryRun, "dry-run", false, "仅显示将要执行的操作") } func runClassify(cmd *cobra.Command, args []string) error { vaultPath := cmd.Flag("vault").Value.String() fmt.Println("步骤 1/3: 提取实体信息...") entities, relations, err := classify.ExtractEntities(vaultPath) if err != nil { return fmt.Errorf("提取实体失败: %w", err) } if !classifyDryRun { if err := classify.SaveEntities(vaultPath, entities, relations); err != nil { return fmt.Errorf("保存实体失败: %w", err) } fmt.Printf("✓ 已生成 entities.json 和 relations.json\n") } else { fmt.Printf("[DRY-RUN] 将生成 entities.json 和 relations.json\n") } fmt.Println("\n步骤 2/3: 文档分类(待实现)...") fmt.Println("步骤 3/3: 生成 classification.json(待实现)...") return nil }