feat: KOC 资源导入后自动爬取主页资料并调用 LLM 打标签
- 新增 structured_text_process 打标客户端(文本构造、标签解析清洗、MCP 调用) - 写库后后台打标(tagUntaggedAccounts),单条新增 / 批量导入 / 每日补全三个入口统一 - 标签只补空,UPDATE 带 tags 为空守卫,不覆盖已有标签 - 新增 AI_TAGGING_TOOL 配置项(留空关闭),更新配置示例与文档 - 新增 16 个打标测试用例,全量 131 个测试通过
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
parseResourceImportFile,
|
||||
RESOURCE_IMPORT_MAX_BYTES,
|
||||
RESOURCE_IMPORT_MAX_ROWS,
|
||||
resourceImportMissingFields,
|
||||
needsResourceEnrichment,
|
||||
type ResourceImportRow,
|
||||
} from "../../../lib/resource-import";
|
||||
import {
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
enrichRows,
|
||||
loadAccounts,
|
||||
mergeExistingFields,
|
||||
tagUntaggedAccounts,
|
||||
writeAnalyzedRows,
|
||||
RESOURCE_IMPORT_SYNC_ENRICH_ROWS,
|
||||
type AnalyzedRow,
|
||||
@@ -49,7 +50,7 @@ function deferredEnrichmentCount(rows: ResourceImportRow[]) {
|
||||
(row) =>
|
||||
row.errors.length === 0 &&
|
||||
row.profileUrl &&
|
||||
resourceImportMissingFields(row).length > 0,
|
||||
needsResourceEnrichment(row),
|
||||
).length;
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ async function enrichImportedRowsInBackground(rows: ResourceImportRow[]) {
|
||||
(row) =>
|
||||
row.errors.length === 0 &&
|
||||
row.profileUrl &&
|
||||
resourceImportMissingFields(row).length > 0,
|
||||
needsResourceEnrichment(row),
|
||||
);
|
||||
if (missingRows.length === 0) return;
|
||||
const enriched = await enrichRows(missingRows, accounts.results);
|
||||
@@ -132,6 +133,10 @@ export async function POST(request: Request) {
|
||||
);
|
||||
}
|
||||
await writeAnalyzedRows(importableRows);
|
||||
runInBackground(
|
||||
tagUntaggedAccounts(importableRows),
|
||||
"resource account tagging",
|
||||
);
|
||||
if (deferredEnrichment > 0) {
|
||||
const importableSourceRows = rows.filter((row) =>
|
||||
importableRowNumbers.has(row.rowNumber),
|
||||
|
||||
Reference in New Issue
Block a user