enzostvs HF Staff commited on
Commit
05b2241
·
1 Parent(s): 4c01d00

handle sambanova

Browse files
Files changed (1) hide show
  1. server.js +18 -8
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 (chunk.includes("</html>")) {
347
- // Replace everything after the last </html> tag with an empty string
348
- newChunk = newChunk.replace(/<\/html>[\s\S]*/, "</html>");
349
- }
350
- completeResponse += newChunk;
351
- res.write(newChunk);
352
- if (newChunk.includes("</html>")) {
353
- break;
 
 
 
 
 
 
 
 
 
 
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