From 209d3bcb5a978fc3f529adc2c2a11ab12a7f8f0c Mon Sep 17 00:00:00 2001 From: jiakai from macos Date: Wed, 16 Oct 2024 15:21:08 +0800 Subject: [PATCH] feat: remove doubao ai summary feature. --- components/AISummary/index.jsx | 5 ++--- pages/api/doubao.js | 40 ---------------------------------- public/index.xml | 2 +- 3 files changed, 3 insertions(+), 44 deletions(-) delete mode 100644 pages/api/doubao.js diff --git a/components/AISummary/index.jsx b/components/AISummary/index.jsx index 7119118..32a0205 100644 --- a/components/AISummary/index.jsx +++ b/components/AISummary/index.jsx @@ -35,7 +35,7 @@ export default function AISummary({ contentMarkdown, params, tags }) { setError('') setSummary('') const themeContent = extractThemeContent(contentMarkdown) - const message = `请用中文总结以下主题内容,并在总结末尾提及作者还分享了一些有趣的网站、实用的链接和金句。总结控制在50个中文字以内:\n\n${themeContent}` + const message = `请用中文总结以下话题内容。总结控制在50个中文汉字以内:\n\n${themeContent}` fetch(`/api/${selectedAI}`, { method: 'POST', @@ -95,9 +95,8 @@ export default function AISummary({ contentMarkdown, params, tags }) { onChange={(e) => setSelectedAI(e.target.value)} aria-label="选择 AI 模型" > - + - diff --git a/pages/api/doubao.js b/pages/api/doubao.js deleted file mode 100644 index 7bfde7e..0000000 --- a/pages/api/doubao.js +++ /dev/null @@ -1,40 +0,0 @@ -import OpenAI from 'openai' - -const openai = new OpenAI({ - baseURL: process.env.DOUBAO_BASE_URL, - apiKey: process.env.DOUBAO_API_KEY -}) - -export default async function handler(req, res) { - if (req.method === 'POST') { - const { message } = req.body - - res.writeHead(200, { - 'Content-Type': 'text/event-stream', - 'Cache-Control': 'no-cache, no-transform', - 'Connection': 'keep-alive', - }) - - try { - const stream = await openai.chat.completions.create({ - model: 'Doubao-lite-4k', - messages: [{ role: 'user', content: message }], - stream: true, - }) - - for await (const chunk of stream) { - const content = chunk.choices[0]?.delta?.content || '' - if (content) { - res.write(`data: ${JSON.stringify({ content })}\n\n`) - } - } - } catch (error) { - console.error('Error in OpenAI stream:', error) - res.write(`data: ${JSON.stringify({ error: '获取摘要时出错,请稍后重试。' })}\n\n`) - } finally { - res.end() - } - } else { - res.status(405).json({ error: 'Method not allowed' }) - } -} \ No newline at end of file diff --git a/public/index.xml b/public/index.xml index 5d3ebf4..69057d4 100644 --- a/public/index.xml +++ b/public/index.xml @@ -2,7 +2,7 @@ 周见 - 2024-10-16T06:50:22.674Z + 2024-10-16T07:16:45.450Z https://github.com/jpmonette/feed 周见