summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-06 17:23:33 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-06 17:23:33 +0100
commite889f3cb9b656718127ab23bb0d7203f7eff81d4 (patch)
tree37b00546d5f462bbe6af9eaafed8d7dd69c86edc /g4f
parentUse word word count from alfaaz (diff)
downloadgpt4free-e889f3cb9b656718127ab23bb0d7203f7eff81d4.tar
gpt4free-e889f3cb9b656718127ab23bb0d7203f7eff81d4.tar.gz
gpt4free-e889f3cb9b656718127ab23bb0d7203f7eff81d4.tar.bz2
gpt4free-e889f3cb9b656718127ab23bb0d7203f7eff81d4.tar.lz
gpt4free-e889f3cb9b656718127ab23bb0d7203f7eff81d4.tar.xz
gpt4free-e889f3cb9b656718127ab23bb0d7203f7eff81d4.tar.zst
gpt4free-e889f3cb9b656718127ab23bb0d7203f7eff81d4.zip
Diffstat (limited to '')
-rw-r--r--g4f/gui/client/js/chat.v1.js9
1 files changed, 1 insertions, 8 deletions
diff --git a/g4f/gui/client/js/chat.v1.js b/g4f/gui/client/js/chat.v1.js
index 9772fbf7..7135b8f6 100644
--- a/g4f/gui/client/js/chat.v1.js
+++ b/g4f/gui/client/js/chat.v1.js
@@ -66,7 +66,6 @@ const register_remove_message = async () => {
}
const delete_conversations = async () => {
- localStorage.clear();
for (let i = 0; i < localStorage.length; i++){
let key = localStorage.key(i);
if (key.startsWith("conversation:")) {
@@ -476,12 +475,6 @@ const load_conversation = async (conversation_id) => {
}, 500);
};
-// https://stackoverflow.com/questions/20396456/how-to-do-word-counts-for-a-mixture-of-english-and-chinese-in-javascript
-function count_words(str) {
- var matches = str.match(/[\u00ff-\uffff]|\S+/g);
- return matches ? matches.length : 0;
-}
-
function count_tokens(model, text) {
if (model.startsWith("gpt-3") || model.startsWith("gpt-4")) {
return GPTTokenizer_cl100k_base?.encode(text).length;
@@ -497,7 +490,7 @@ function count_tokens(model, text) {
function count_words_and_tokens(text, model) {
const tokens_count = model ? count_tokens(model, text) : null;
const tokens_append = tokens_count ? `, ${tokens_count} tokens` : "";
- return `(${count_words(text)} words${tokens_append})`
+ return countWords ? `(${countWords(text)} words${tokens_append})` : "";
}
const get_conversation = async (conversation_id) => {