冯杨

同步github官方更新截止Commits on Apr 18, 2025

a9c36c76e569107b5a39b3de8afd6e016b24d662
@@ -581,19 +581,46 @@ @@ -581,19 +581,46 @@
581 581
582 console.log('Sending chat message:', message); 582 console.log('Sending chat message:', message);
583 583
584 - fetch('/human', {  
585 - body: JSON.stringify({  
586 - text: message,  
587 - type: 'chat',  
588 - interrupt: true,  
589 - sessionid: parseInt(document.getElementById('sessionid').value),  
590 - }), 584 + // fetch('/human', {
  585 + // body: JSON.stringify({
  586 + // text: message,
  587 + // type: 'chat',
  588 + // interrupt: true,
  589 + // sessionid: parseInt(document.getElementById('sessionid').value),
  590 + // }),
  591 + // headers: {
  592 + // 'Content-Type': 'application/json'
  593 + // },
  594 + // method: 'POST'
  595 + // });
  596 +
  597 + var payload = {
  598 + "model": "fay-streaming",
  599 + "messages": [
  600 + {
  601 + "role": $('#username').val(),
  602 + "content": message
  603 + }
  604 + ],
  605 + "observation": ""
  606 + };
  607 +
  608 + fetch('http://127.0.0.1:5000/v1/chat/completions', {
  609 + body: JSON.stringify(payload),
591 headers: { 610 headers: {
592 - 'Content-Type': 'application/json' 611 + 'Content-Type': 'application/json'
593 }, 612 },
594 method: 'POST' 613 method: 'POST'
  614 + }).then(function(response) {
  615 + if (response.ok) {
  616 + console.log('Message sent to API.');
  617 + } else {
  618 + console.error('Failed to send message to API.');
  619 + }
  620 + }).catch(function(error) {
  621 + console.error('Error:', error);
595 }); 622 });
596 - 623 +
597 addChatMessage(message, 'user'); 624 addChatMessage(message, 'user');
598 $('#chat-message').val(''); 625 $('#chat-message').val('');
599 }); 626 });