1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
const fetch = require('node-fetch'); const config = { "prompt": "马化腾是谁", "options": { "parentMessageId": "chatcmpl-756yYyWTlMacS71BLTcBtxCQZw3rj" }, "systemMessage": "You are ChatGPT, a large language model trained by OpenAI. Answer as concisely as possible.\nKnowledge cutoff: 2021-09-01\nCurrent date: 2023-04-14" }; fetch("http://43.143.166.59:3000/api/chat-process", { "headers": { "accept": "application/json, text/plain, */*", "accept-language": "zh-CN,zh;q=0.9,en;q=0.8", "content-type": "application/json", "Referer": "http://43.143.166.59:3000/", "Referrer-Policy": "strict-origin-when-cross-origin" }, "body": JSON.stringify(config), "method": "POST" }).then(response => { return response.text() }).then(res=>{ const answer = []; res.split(`\n`).forEach((value)=> answer.push(JSON.parse(value))) return answer; }).then(list=> { return list[list.length-1]; }).then(out=> { // 下一次回复, 需要携带上一次的 parentMessageId console.log(out) }) |