Skip to content

Commit

Permalink
chore: remove code
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Feb 27, 2024
1 parent a31dc81 commit d5fb68e
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions components/chatAI.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { Transforms } from "slate";
import { Editor } from "slate";
import Quill from "quill";

import { extractText } from "@/utils/others/slateutils";
import {
updateBracketNumbersInDeltaKeepSelection,
convertToSuperscript,
deleteSameBracketNumber,
} from "@/utils/others/quillutils";
import { faSignal } from "@fortawesome/free-solid-svg-icons";
//redux不能在普通函数使用

interface ChatData {
Expand Down Expand Up @@ -128,48 +124,6 @@ const sendMessageToOpenAI = async (
}
};

const getAI = async (
userMessage: string,
systemPrompt: string,
apiKey: string,
upsreamUrl: string,
selectedModel: string
) => {
// 设置API请求参数
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization:
"Bearer " +
(isValidApiKey(apiKey)
? apiKey
: process.env.NEXT_PUBLIC_OPENAI_API_KEY),
},
body: JSON.stringify({
model: selectedModel || "gpt-3.5-turbo",
stream: false,
messages: [
{
role: "system",
content: systemPrompt,
},
{
role: "user",
content: userMessage,
},
],
}),
};
const response = await fetch(
(upsreamUrl || process.env.NEXT_PUBLIC_AI_URL) + "/v1/chat/completions",
requestOptions
);
const data = await response.json();
const topic = data.choices[0].message.content;
return topic; // 获取并返回回复
};

async function processResult(reader, decoder, editor) {
let buffer = "";
while (true) {
Expand Down Expand Up @@ -222,4 +176,4 @@ async function processResult(reader, decoder, editor) {
}
}

export { getAI, sendMessageToOpenAI };
export { sendMessageToOpenAI };

0 comments on commit d5fb68e

Please sign in to comment.