Skip to content

Commit

Permalink
fix: 读取ai响应
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Feb 26, 2024
1 parent 43f222a commit 2015962
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/chatAI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async function processResult(reader, decoder, editor) {
// 找到一个完整的 JSON 对象的边界
let jsonStr = buffer.substring(0, boundary + 1);
buffer = buffer.substring(boundary + 2);
// console.log("jsonStr", jsonStr);
console.log("jsonStr", jsonStr);

// 尝试解析 JSON 对象
try {
Expand All @@ -201,8 +201,8 @@ async function processResult(reader, decoder, editor) {
// 处理 dataObject 中的 content
if (dataObject.choices && dataObject.choices.length > 0) {
let content =
dataObject.choices[0].message?.content ||
dataObject.choices[0].delta?.content;
dataObject.choices[0].delta?.content ??
dataObject.choices[0].message?.content;
if (content) {
// 在当前光标位置插入文本
// editor.focus();
Expand Down

0 comments on commit 2015962

Please sign in to comment.