You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
675 B
JavaScript

let params = {
title: '灵能世界',
question: '写一段关于方清辉的介绍',
token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6ImlzZWthaXdpa2kifQ.eyJpc3MiOiJtd2NoYXRjb21wbGV0ZSIsInN1YiI6MSwibmFtZSI6Ikh5cGVyemxpYiIsImlhdCI6MTY4MTQ1Mjk2NiwiZXhwIjoxNjgxNTM5MzY2fQ.U0yBb8Qw9WXAe2PzfRbgWdQPH62xLqbwet7Jev0VcZ4'
}
let ws = new WebSocket('ws://localhost:8144/chatcomplete/message?' + new URLSearchParams(params));
ws.addEventListener('message', (event) => {
const data = JSON.parse(event.data);
if (data?.event === 'output') {
console.log(data.text);
} else {
console.log(data)
}
});
ws.addEventListener('error', console.log);