diff --git a/public/index.html b/public/index.html index fbc5611b4..6a504478a 100644 --- a/public/index.html +++ b/public/index.html @@ -581,7 +581,7 @@ -
+
Frequency Penalty
@@ -596,7 +596,7 @@
-
+
Presence Penalty
@@ -611,7 +611,7 @@
-
+
Top K
@@ -626,7 +626,7 @@
-
+
Top P
diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 5aca5fe49..f72957cdf 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -741,7 +741,6 @@ async function sendOpenAIRequest(type, openai_msgs_tosend, signal) { "frequency_penalty": parseFloat(oai_settings.freq_pen_openai), "presence_penalty": parseFloat(oai_settings.pres_pen_openai), "top_p": parseFloat(oai_settings.top_p_openai), - "top_k": parseFloat(oai_settings.top_k_openai), "max_tokens": oai_settings.openai_max_tokens, "stream": stream, "logit_bias": logit_bias, @@ -755,10 +754,12 @@ async function sendOpenAIRequest(type, openai_msgs_tosend, signal) { if (isClaude) { generate_data['use_claude'] = true; + generate_data['top_k'] = parseFloat(oai_settings.top_k_openai); } if (isOpenRouter) { generate_data['use_openrouter'] = true; + generate_data['top_k'] = parseFloat(oai_settings.top_k_openai); } if (isScale) { @@ -1749,7 +1750,7 @@ async function onModelChange() { } else { const model = model_list.find(m => m.id == oai_settings.openrouter_model); if (model?.context_length) { - $('#openai_max_context').attr('max', model.context_length - 1); // waiting for openrouter to fix this + $('#openai_max_context').attr('max', model.context_length); } else { $('#openai_max_context').attr('max', max_4k); // placeholder } diff --git a/server.js b/server.js index bf3df25de..14b3d27eb 100644 --- a/server.js +++ b/server.js @@ -1031,7 +1031,7 @@ app.post("/editcharacter", urlencodedParser, async function (request, response) * Handle a POST request to edit a character attribute. * * This function reads the character data from a file, updates the specified attribute, - * and writes the updated data back to the file. + * and writes the updated data back to the file. * * @param {Object} request - The HTTP request object. * @param {Object} response - The HTTP response object. @@ -1069,7 +1069,7 @@ app.post("/editcharacterattribute", jsonParser, async function (request, respons charaWrite(avatarPath, char, (request.body.avatar_url).replace('.png', ''), response, 'Character saved'); }).catch((err) => { console.error('An error occured, character edit invalidated.', err); - } ); + } ); } catch { console.error('An error occured, character edit invalidated.'); @@ -3323,6 +3323,7 @@ app.post("/generate_openai", jsonParser, function (request, response_generate_op "presence_penalty": request.body.presence_penalty, "frequency_penalty": request.body.frequency_penalty, "top_p": request.body.top_p, + "top_k": request.body.top_k, "stop": request.body.stop, "logit_bias": request.body.logit_bias }, @@ -3456,7 +3457,7 @@ app.post("/tokenize_via_api", jsonParser, async function(request, response) { return response.sendStatus(400); } const text = request.body.text || ''; - + try { const args = { body: JSON.stringify({"prompt": text}),