flat: ai对话提交

This commit is contained in:
Apcallover
2025-11-20 09:17:29 +08:00
parent e67c53404b
commit 5497398498
14 changed files with 410 additions and 355 deletions

View File

@@ -17,7 +17,7 @@ export default function StreamRequest(url, data = {}, onDataReceived, onError, o
};
return new Promise(async (resolve, reject) => {
try {
const response = await fetch(config.StreamBaseURl + url, {
const response = await fetch(config.baseUrl + url, {
method: "POST",
headers,
body: JSON.stringify(data)
@@ -46,6 +46,7 @@ export default function StreamRequest(url, data = {}, onDataReceived, onError, o
let lines = buffer.split("\n");
buffer = lines.pop(); // 可能是不完整的 JSON 片段,留待下次解析
for (let line of lines) {
line = line.slice(5).trim()
if (line.startsWith("data: ")) {
const jsonData = line.slice(6).trim();
if (jsonData === "[DONE]") {