Commit Graph

2899 Commits

Author SHA1 Message Date
Cohee 27782b2f83 Fix united version comparison 2023-12-11 20:44:29 +02:00
valadaptive ce8cc59e4d Remove fetchJSON 2023-12-11 13:32:38 -05:00
valadaptive 42d4ffe5e8 Remove Kobold "canUse(...)" functions
Replace them all with a versionCompare helper function which we can call
directly with the minimum version constants.
2023-12-10 20:39:21 -05:00
valadaptive d33cb0d8d1 Clarify getstatus API
Instead of "version" and "koboldVersion", have "koboldUnitedVersion" and
"koboldCppVersion", the latter of which is null if we're not connected
to KoboldCpp.
2023-12-10 20:34:11 -05:00
valadaptive 1fbf4394c8 Separate Kobold Horde status function 2023-12-10 20:16:07 -05:00
Cohee 23e6a10cb5 Unsqueeze advanced defs rows 2023-12-11 01:33:56 +02:00
Cohee 7450112e9b Unbust user continue in group chats 2023-12-11 00:02:49 +02:00
Cohee e8742a3e9d Merge branch 'release' into staging 2023-12-10 23:28:10 +02:00
Cohee 2e6ab8be46 Add Object.hasOwn polyfill 2023-12-10 23:28:00 +02:00
Cohee 05b08f1ce2 Don't await delay promise 2023-12-10 21:51:16 +02:00
Cohee 2e50efc35c Limit waiting for TTS to init to 1 second on chat change 2023-12-10 21:50:52 +02:00
Cohee 420d186823 Add reduced motion toggle 2023-12-10 20:02:25 +02:00
Cohee 13e016f3e5
Merge pull request #1508 from LenAnderson/tts-skip-codeblocks-option
add TTS option to skip codeblock narration
2023-12-10 19:28:16 +02:00
Cohee f8a903e1fd #1506 Fix big markdown images 2023-12-10 18:45:55 +02:00
Cohee dbd52a7994
Merge pull request #1482 from valadaptive/sse-stream
Refactor server-sent events parsing
2023-12-10 18:32:19 +02:00
LenAnderson bf88829b03 add option to skip codeblock narration 2023-12-10 16:32:10 +00:00
Cohee b107ace719 Avoid sending 401 in forwarded responses.
Status code 401 resets the client Basic auth, so we replace it with 400. This can produce an interesting artifact as "400 Unauthorized", but it's not out of spec.

"The reason phrases listed here are only recommendations -- they can be replaced by local equivalents or left out altogether without affecting the protocol."

https://www.rfc-editor.org/rfc/rfc9110.html#name-overview-of-status-codes
2023-12-10 18:00:04 +02:00
Cohee 3653c8636e
Merge pull request #1501 from LenAnderson/qr-editor-tab-support
Add support for tab and shift-tab in QR editor
2023-12-10 16:50:30 +02:00
Cohee af89cfa870 Code clean-up 2023-12-10 16:48:25 +02:00
Cohee 5054de247b Merge branch 'staging' into qr-editor-tab-support 2023-12-10 16:36:28 +02:00
Cohee ae01e7419f
Merge pull request #1503 from valadaptive/tokenizers-cleanup
Tokenizers cleanup
2023-12-10 16:35:52 +02:00
Cohee 9acef0fae6 Horde doesn't support API tokenizers 2023-12-10 16:21:06 +02:00
Cohee f54bf99006 Fix token ids not displaying in "API_CURRENT" mode for TextGen 2023-12-10 16:09:00 +02:00
Cohee 6957d9e7cf Fix display names of Best match tokenizers 2023-12-10 16:03:25 +02:00
Cohee 6e5eea5dba Unbreak previously selected API tokenizer in dropdown 2023-12-10 15:56:38 +02:00
Cohee d5140142fb Merge branch 'staging' into tokenizers-cleanup 2023-12-10 15:51:15 +02:00
Cohee e0d0e1dd66
Merge pull request #1502 from valadaptive/status-cleanup
Clean up getStatus code
2023-12-10 15:49:37 +02:00
Cohee 6be1c6ff10
Merge pull request #1504 from valadaptive/store-compiled-templates
Cache compiled Handlebars templates
2023-12-10 15:32:52 +02:00
Cohee 5f1683f43a More input padding and stricter sanitation 2023-12-10 15:07:39 +02:00
Cohee 36438394a2
Merge pull request #1505 from valadaptive/no-random-comparator
Implement random sort with a shuffle
2023-12-10 15:06:27 +02:00
valadaptive 0201a0260c Default event type to 'message' if it's empty
Added to the upstream test suite. Matches the spec.
2023-12-10 04:45:10 -05:00
valadaptive 55976e61a3 Fix tokenizer override
I searched for all users of tokenizers.API, but missed that the menu
converts the numerical select values directly to enum values. I've used
the special tokenizer value 98 to represent "the tokenizer API for
whichever backend we're currently using".
2023-12-09 23:57:21 -05:00
valadaptive 0fce475a95 Implement random sort with a shuffle
Sorting with a random comparator doesn't actually shuffle an array.
Depending on the sorting algorithm used, there will be a bias to the
shuffle (see https://bost.ocks.org/mike/shuffle/compare.html).
If you open that link in Firefox, the bias will be especially bad.
Instead of implementing "random" character sort using a random sort
comparator, use the shuffle function instead.
2023-12-09 22:52:38 -05:00
valadaptive c48bc8a76e Cache compiled Handlebars templates
Since we already have a template cache, it makes sense to store the
templates in it *after* compiling them, to avoid the overhead of
re-compiling them every time we call renderTemplate.

I've also changed the cache from an object to a Map--it's more
semantically correct, and avoids weird edge cases like a template named
"hasOwnProperty" or some other function that exists as an object
property.
2023-12-09 21:29:36 -05:00
valadaptive 499d158c11 Remove last usage of getAPIServerUrl
Now that we're not using this in the tokenizers code, we can remove it.
2023-12-09 20:55:34 -05:00
valadaptive 014416546c Add padding once in getTokenCount
This means we don't have to pass the "padding" parameter into every
function so they can add the padding themselves--we can do it in just
one place instead.
2023-12-09 20:53:16 -05:00
valadaptive 2f2cd197cc Clean up tokenizer API code
Store the URLs for each tokenizer's action in one place at the top of
the file, instead of in a bunch of switch-cases. The URLs for the
textgen and Kobold APIs don't change and hence don't need to be
function arguments.
2023-12-09 20:48:41 -05:00
valadaptive 09465fbb97 Inline most get(...)TokenizerParams calls
For everything except textgenerationwebui, these params are now simple
enough that it doesn't make sense for them to be in a separate function.
2023-12-09 20:35:11 -05:00
valadaptive 30502ac949 Split up Kobold and textgenerationwebui endpoints
The endpoint was one big if/else statement that did two entirely
different things depending on the value of main_api. It makes more sense
for those to be two separate endpoints.
2023-12-09 20:26:24 -05:00
valadaptive 7486ab3886 Separate textgen and Kobold tokenization APIs
They function differently and have different logic and API parameters,
so it makes sense to count them as two different APIs. Kobold's API
doesn't return tokens, so it can only be used to count them.

There's still a lot of duplicate code which I will clean up in the
following commits.
2023-12-09 20:24:56 -05:00
valadaptive 18177c147d Separate remote and server tokenization code paths
This lets us remove extraneous API params from paths where they aren't
needed.
2023-12-09 20:08:48 -05:00
valadaptive ddd73a204a Remove "remote" language from tokenizer functions
We'll be making a distinction between tokenizing *on* the server itself,
and tokenizing via the server having the AI service do it. It makes more
sense to use the term "remote" for the latter.
2023-12-09 19:49:22 -05:00
valadaptive 04e92efe29 Move API tokenization endpoint into /tokenizers
Requires extracting some more functions out of server.js.
2023-12-09 19:35:49 -05:00
valadaptive 8bad059a62 Rename /tokenize_via_api endpoint
No redirect for this since I don't expect any extensions to be calling this directly.
2023-12-09 19:29:24 -05:00
valadaptive a23be7d785 Clean up CSS for API "connect" buttons
Instead of identifying each connect button by ID, we can just use the
.api_button class. The .menu_button class *would* override it due to CSS
cascade rules (specifically, declarations later in the stylesheet apply
over ones that appear earlier), but the `.menu_button.api_button`
selector has a higher *specificity* and hence works.
2023-12-09 18:52:14 -05:00
valadaptive babb127aee Move NovelAI status functions over to the rest
Have all the get(...)Status and event handler registrations in the same
areas, rather than having the NovelAI ones far away. I want to
eventually move all the API-specific stuff into separate modules, but
this will make things cleaner for the time being.
2023-12-09 18:41:51 -05:00
valadaptive 0ea0399ed1 Separate getStatus into Kobold/textgen versions
This adds a bit of duplicate code for the time being, but ultimately
makes the code less confusing because we only need to include the bits
that are relevant to the specific API in each function. We can also
remove API parameters that are useless depending on the endpoint.
2023-12-09 18:39:19 -05:00
Cohee f43d738dfd
Merge pull request #1500 from SillyTavern/staging
Staging
2023-12-09 19:59:49 +02:00
LenAnderson a3ec8d709d add support for tab and shift-tab in QR editor 2023-12-09 17:56:36 +00:00
Cohee a8224c16de Fix order of middleware application
Previously: CSRF => auth => whitelist
Now: auth => whitelist => CSRF
2023-12-09 19:56:26 +02:00