Enforce API use limits depending on whether the server has billing enabled

and whether the given user is subscribed
This commit is contained in:
sabaimran
2023-11-24 21:55:16 -08:00
parent 9c868ee10b
commit e5b1350523
5 changed files with 45 additions and 11 deletions

View File

@@ -361,9 +361,22 @@
if (newResponseText.getElementsByClassName("spinner").length > 0) {
newResponseText.removeChild(loadingSpinner);
}
newResponseText.innerHTML += chunk;
readStream();
// Try to parse the chunk as a JSON object. It will be a JSON object if there is an error.
if (chunk.startsWith("{") && chunk.endsWith("}")) {
try {
const responseAsJson = JSON.parse(chunk);
if (responseAsJson.detail) {
newResponseText.innerHTML += responseAsJson.detail;
}
} catch (error) {
// If the chunk is not a JSON object, just display it as is
newResponseText.innerHTML += chunk;
}
} else {
// If the chunk is not a JSON object, just display it as is
newResponseText.innerHTML += chunk;
readStream();
}
}
// Scroll to bottom of chat window as chat response is streamed