From 9ef7cd04bdd78cfaab930b1b3c123c19e550aa72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=8B=E4=B9=8B?= Date: Fri, 6 Mar 2026 10:52:34 +0800 Subject: [PATCH] =?UTF-8?q?DEV-004:=20=E7=8E=AF=E8=8A=824=E5=AE=8C?= =?UTF-8?q?=E6=88=90=20-=20=E6=8E=A5=E5=85=A5=20Kimi=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + webhook.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 12923765..a10a2d64 100644 --- a/.env +++ b/.env @@ -3,3 +3,4 @@ DINGTALK_APP_SECRET=vJnmeF0B1yaYRv7u4IzdKsC6wPfStyUWEQnBdjas-NH5JUAKUwj7Dc659Bau DINGTALK_ROBOT_CODE=dingzerc04si7jmyvasq PORT=3000 +KIMI_API_KEY=sk-A1STcZTjWTYOiG864MCt31VHHq8fD1r9E7LBDxoaMDDoGGbx \ No newline at end of file diff --git a/webhook.js b/webhook.js index 3910b7e5..0d51c4cc 100644 --- a/webhook.js +++ b/webhook.js @@ -7,11 +7,31 @@ const app = express(); app.use(express.json()); app.use(express.urlencoded({ extended: true })); +// 调用 Kimi API +async function callKimiAPI(content) { + const response = await fetch('https://api.moonshot.cn/v1/chat/completions', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${process.env.KIMI_API_KEY}` + }, + body: JSON.stringify({ + model: 'moonshot-v1-8k', + messages: [ + { role: 'system', content: '你是之之秋秋,光湖纪元的钉钉机器人助手。' }, + { role: 'user', content: content } + ] + }) + }); + + const data = await response.json(); + return data.choices[0].message.content; +} // AI 处理函数 async function processWithAI(content) { // 这里接入 Kimi API // 暂时返回测试回复 - return `🤖 收到:"${content}"\n\n我是之之秋秋,正在开发中...`; + return await callKimiAPI(content); } // 验证签名