Skip to content

Commit

Permalink
fix: 插入前先换行
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Jan 31, 2024
1 parent 27c0ffe commit d56f427
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions components/chatAI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ const sendMessageToOpenAI = async (
upsreamUrl: string,
prompt?: string
) => {
// console.log("apiKey", apiKey);
// console.log("isValidApiKey(apiKey)", isValidApiKey(apiKey).toString());
// console.log(
// " token的值",
// "Bearer " +
// (isValidApiKey(apiKey) ? apiKey : process.env.NEXT_PUBLIC_OPENAI_API_KEY)
// );
//识别应该使用的模型
let model = selectedModel === "gpt3.5" ? "gpt-3.5-turbo" : "gpt-4";
console.log("upstreamUrl", upsreamUrl);
Expand Down Expand Up @@ -88,10 +81,9 @@ const sendMessageToOpenAI = async (
}
const reader = response.body.getReader();
const decoder = new TextDecoder();

await processResult(reader, decoder, editor);
console.log("流式输出完成接下来要插入一个换行符");
//开始结束前先进行换行
editor.insertText(editor.getSelection().index, "\n");
await processResult(reader, decoder, editor);

convertToSuperscript(editor);
updateBracketNumbersInDeltaKeepSelection(editor);
Expand Down

0 comments on commit d56f427

Please sign in to comment.