明树Git Lab

Commit 48dbf20c authored by zfp1's avatar zfp1

update

parent dd51d9d2
...@@ -25,7 +25,7 @@ app.get('/wechat', (req, res) => { ...@@ -25,7 +25,7 @@ app.get('/wechat', (req, res) => {
// 消息处理流程 // 消息处理流程
app.post('/wechat', async (req, res) => { app.post('/wechat', async (req, res) => {
try { // try {
// XML解析 // XML解析
const result = await xml2js.parseStringPromise(req.body); const result = await xml2js.parseStringPromise(req.body);
const message = result.xml.Content[0]; const message = result.xml.Content[0];
...@@ -35,7 +35,7 @@ app.post('/wechat', async (req, res) => { ...@@ -35,7 +35,7 @@ app.post('/wechat', async (req, res) => {
const completion = await openai.chat.completions.create({ const completion = await openai.chat.completions.create({
model: "deepseek-chat", model: "deepseek-chat",
messages: [ messages: [
{ role: "system", content: "你是一个微信服务号智能助手,限制你的字符输出要低于2048个字节。" },{ { role: "system", content: "你是一个微信服务号智能助手,你输出的字符要低于2048个字节" },{
role: "user", role: "user",
content: message content: message
}], }],
...@@ -75,10 +75,10 @@ app.post('/wechat', async (req, res) => { ...@@ -75,10 +75,10 @@ app.post('/wechat', async (req, res) => {
res.set('Content-Type', 'text/xml'); res.set('Content-Type', 'text/xml');
console.log(responseXML) console.log(responseXML)
res.send(responseXML); res.send(responseXML);
} catch (error) { // } catch (error) {
console.error(error); // console.error(error);
res.status(500).send(' 服务异常'); // res.status(500).send(' 服务异常');
} // }
}); });
app.listen(3001, () => console.log(' 服务运行在3001端口')); app.listen(3001, () => console.log(' 服务运行在3001端口'));
\ No newline at end of file
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