diff --git a/services/attach/index.ts b/services/attach/index.ts index 978edd3..74864d8 100644 --- a/services/attach/index.ts +++ b/services/attach/index.ts @@ -106,6 +106,11 @@ class AttachService extends NetToolBase { */ async mifyCrawler(link: string, userDescription: string) { const URL = "https://mify-be.pt.xiaomi.com/api/v1/workflows/run" + const errMap: Record = { + crawlerErr: "网页抓取失败", + larkErr: "文档获取失败或者文档为空", + authErr: "请确保小煎蛋有对文档的读取权限,可以私发小煎蛋设置权限", + } return this.post( URL, { @@ -124,11 +129,14 @@ class AttachService extends NetToolBase { .then((res) => { const llmRes = res.data.outputs.content if (!llmRes) throw new Error("模型总结失败") - if (llmRes === "crawlerErr") throw new Error("网页抓取失败") + if (errMap[llmRes]) throw new Error(errMap[llmRes]) return llmRes as string }) .catch((error) => { - if (["网页抓取失败", "模型总结失败"].includes(error.message)) { + if ( + Object.values(errMap).includes(error.message) || + error.message === "模型总结失败" + ) { throw error } throw new Error("MIFY爬虫请求失败")