use new provider
Browse files187 unmodified lines1881891901911921931941951961971981992002012022 unmodified lines2052062072082092102114 unmodified lines2162172182192202212222232242252267 unmodified lines234235236237238239240187 unmodified linesprovider: "sambanova",messages: [{role: "system",content:"ONLY USE HTML, CSS AND JAVASCRIPT. If you want to use ICON make sure to import the library first. Try to create the best UI possible by using only HTML, CSS and JAVASCRIPT. Also, try to ellaborate as much as you can, to create something unique. ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE",},...(html? [{role: "user",content: `My current code is: ${html}.`,},]: []),2 unmodified linescontent: prompt,},],max_tokens: 12_000,});while (true) {4 unmodified linesconst chunk = value.choices[0]?.delta?.content;if (chunk) {// Stream chunk to clientres.write(chunk);completeResponse += chunk;// Break when HTML is completeif (completeResponse.includes("</html>")) {break;}}7 unmodified linesif (!res.headersSent) {res.status(500).send({ok: false,message: "Error generating response",});} else {// Otherwise end the stream187 unmodified lines1881891901911921931941951961971981992002012022 unmodified lines2052062072082092102114 unmodified lines2162172182192202212222232242252262272282292302317 unmodified lines239240241242243244245187 unmodified linesprovider: "sambanova",messages: [{role: "user",content:"ONLY USE HTML, CSS AND JAVASCRIPT. If you want to use ICON make sure to import the library first. Try to create the best UI possible by using only HTML, CSS and JAVASCRIPT. Also, try to ellaborate as much as you can, to create something unique. ALWAYS GIVE THE RESPONSE INTO A SINGLE HTML FILE",},...(html? [{role: "system",content: `The current code is: ${html}.`,},]: []),2 unmodified linescontent: prompt,},],max_tokens: 6_000,});while (true) {4 unmodified linesconst chunk = value.choices[0]?.delta?.content;if (chunk) {// Stream chunk to clientlet newChunk = chunk;if (chunk.includes("</html>")) {console.log("Chunk before replacement:", newChunk);// Replace everything after the last </html> tag with an empty stringnewChunk = newChunk.replace(/<\/html>[\s\S]*/, "</html>");console.log("Chunk after replacement:", newChunk);}completeResponse += newChunk;res.write(newChunk);if (newChunk.includes("</html>")) {break;}}7 unmodified linesif (!res.headersSent) {res.status(500).send({ok: false,message: error.message,});} else {// Otherwise end the stream
server.js+15-10