Spaces:
Running
Running
handle sambanova
Browse files
server.js
CHANGED
@@ -343,14 +343,24 @@ app.post("/api/ask-ai", async (req, res) => {
|
|
343 |
if (chunk) {
|
344 |
let newChunk = chunk;
|
345 |
if (!selectedModel?.isThinker) {
|
346 |
-
if (
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
}
|
355 |
} else {
|
356 |
// check if in the completeResponse there is already a </html> tag but after the last </think> tag, if yes break the loop
|
|
|
343 |
if (chunk) {
|
344 |
let newChunk = chunk;
|
345 |
if (!selectedModel?.isThinker) {
|
346 |
+
if (provider !== "sambanova") {
|
347 |
+
res.write(chunk);
|
348 |
+
completeResponse += chunk;
|
349 |
+
|
350 |
+
if (completeResponse.includes("</html>")) {
|
351 |
+
break;
|
352 |
+
}
|
353 |
+
} else {
|
354 |
+
let newChunk = chunk;
|
355 |
+
if (chunk.includes("</html>")) {
|
356 |
+
// Replace everything after the last </html> tag with an empty string
|
357 |
+
newChunk = newChunk.replace(/<\/html>[\s\S]*/, "</html>");
|
358 |
+
}
|
359 |
+
completeResponse += newChunk;
|
360 |
+
res.write(newChunk);
|
361 |
+
if (newChunk.includes("</html>")) {
|
362 |
+
break;
|
363 |
+
}
|
364 |
}
|
365 |
} else {
|
366 |
// check if in the completeResponse there is already a </html> tag but after the last </think> tag, if yes break the loop
|