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 } }, {