-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Add 01ai and doubao ai summary feature && remove claude ai summary…
… feature. 2. Remove Inoreader and Raindrop Integration. 3. Add streaming output functionality for LLM topic summary
- Loading branch information
1 parent
f1604cc
commit 27d4b07
Showing
24 changed files
with
335 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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' }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import OpenAI from 'openai' | ||
|
||
const openai = new OpenAI({ | ||
baseURL: process.env.LINGYIWANGWU_BASE_URL, | ||
apiKey: process.env.LINGYIWANGWU_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: 'yi-lightning', | ||
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' }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.