From d9037460cf2fe2f4fcc42ad7415f0471810cdfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E6=B5=B7=E6=B4=8B?= Date: Sun, 24 May 2026 19:39:06 +0800 Subject: [PATCH] ai --- routes/ai.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/ai.js b/routes/ai.js index d7f5263..3bb5d27 100644 --- a/routes/ai.js +++ b/routes/ai.js @@ -1,10 +1,12 @@ const Router = require('koa-router'); const fetch = require('node-fetch'); +const path = require('path'); +const fs = require('fs'); const router = new Router(); const DEEPSEEK_API_KEY = 'sk-21cc85a144874d9b902edffe6af8a971'; -const DEEPSEEK_API_URL = 'https://api.deepseek.com'; +const DEEPSEEK_API_URL = 'https://api.deepseek.com/chat/completions'; router.post('/generate-product', async (ctx) => { try { @@ -146,6 +148,8 @@ router.post('/recognize-product', async (ctx) => { "confidence": 0到1之间的数字(识别置信度) }`; + const imageUrl = `data:image/jpeg;base64,${imageBase64}`; + const response = await fetch(DEEPSEEK_API_URL, { method: 'POST', headers: { @@ -161,7 +165,7 @@ router.post('/recognize-product', async (ctx) => { { type: 'image_url', image_url: { - url: `data:image/jpeg;base64,${imageBase64}` + url: imageUrl } }, {