Fix koboldcpp abort generation error (#4693) * Enhance contribution guidelines for pull requests Added guidelines for maintaining workflow during PRs. * fix abort generation error when koboldcpp is set with a password * add parameter type, and remove unecessary line * oops, missing comma * eslint * remove header content type --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com> Co-authored-by: Your Name <you@example.com>

db315ecf0f75006c60c6f18c885b8800de4f243f

EugeoSynthesisThirtyTwo <gabriel.dhimoila@gmail.com>

Signed
1 files changed, +9 -4Showing whitespace changes
src/endpoints/backends/text-completions.js+9 -4
@@ -72,15 +72,20 @@ async function parseOllamaStream(jsonStream, request, response) {
7272
7373/**
7474 * Abort KoboldCpp generation request.
75+ * @param {import('express').Request} request the generation request
7576 * @param {string} url Server base URL
7677 * @returns {Promise<void>} Promise resolving when we are done
7778 */
7879async function abortKoboldCppRequest(request, url) {
7980 try {
8081 console.info('Aborting Kobold generation...');
81- const abortResponse = await fetch(`${url}/api/extra/abort`, {
82+ let args = {
8283 method: 'POST',
83- });
84+ headers: {},
85+ };
86+
87+ setAdditionalHeaders(request, args, url);
88+ const abortResponse = await fetch(`${url}/api/extra/abort`, args);
8489
8590 if (!abortResponse.ok) {
8691 console.error('Error sending abort request to Kobold:', abortResponse.status, abortResponse.statusText);
@@ -275,7 +280,7 @@ router.post('/generate', async function (request, response) {
275280 request.socket.removeAllListeners('close');
276281 request.socket.on('close', async function () {
277282 if (request.body.api_type === TEXTGEN_TYPES.KOBOLDCPP && !response.writableEnded) {
278283 await abortKoboldCppRequest(request, trimV1(baseUrl));
279284 }
280285
281286 controller.abort();