明树Git Lab

Commit cd3a7b22 authored by zfp1's avatar zfp1

3

parent a57dfd19
......@@ -35,22 +35,26 @@ app.post('/wechat', async (req, res) => {
const completion = await openai.chat.completions.create({
model: "deepseek-chat",
messages: [
{ role: "system", content: "你是一个微信服务号智能助手,限制你的字符输出要低于2048个字节。" },{
{ role: "system", content: "你是一个微信服务号智能助手, 限制你的字符输出要低于2048个字节。" }, {
role: "user",
content: message
}],
stream: false
stream: true
});
let fullContent = '';
for await (const chunk of completion) {
fullContent += chunk.choices[0].message.content || '';
}
console.log("completion:::", completion);
console.log("completion:::", fullContent);
// 响应构造
const responseXML = `
<xml>
<ToUserName><![CDATA[${fromUser}]]></ToUserName>
<FromUserName><![CDATA[${result.xml.ToUserName[0]}]]></FromUserName>
<CreateTime>${Math.floor(Date.now()/1000)}</CreateTime>
<CreateTime>${Math.floor(Date.now() / 1000)}</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[${completion.choices[0].message.content}]]></Content>
<Content><![CDATA[${fullContent}]]></Content>
</xml>
`;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment