Explicitly import Buffer. Specify jsdoc local extensions

1616e7e06760cdb593d269b56e37c7f6184099b8

Cohee <18619528+Cohee1207@users.noreply.github.com>

33 files changed, +93 -77Showing whitespace changes
src/additional-headers.js+14 -14
@@ -4,7 +4,7 @@ import { getConfigValue } from './util.js';
44
5/**5/**
6 * Gets the headers for the Mancer API.6 * Gets the headers for the Mancer API.
7 * @param {import('./users').UserDirectoryList} directories User directories7 * @param {import('./users.js').UserDirectoryList} directories User directories
8 * @returns {object} Headers for the request8 * @returns {object} Headers for the request
9 */9 */
10function getMancerHeaders(directories) {10function getMancerHeaders(directories) {
@@ -18,7 +18,7 @@ function getMancerHeaders(directories) {
1818
19/**19/**
20 * Gets the headers for the TogetherAI API.20 * Gets the headers for the TogetherAI API.
21 * @param {import('./users').UserDirectoryList} directories User directories21 * @param {import('./users.js').UserDirectoryList} directories User directories
22 * @returns {object} Headers for the request22 * @returns {object} Headers for the request
23 */23 */
24function getTogetherAIHeaders(directories) {24function getTogetherAIHeaders(directories) {
@@ -31,7 +31,7 @@ function getTogetherAIHeaders(directories) {
3131
32/**32/**
33 * Gets the headers for the InfermaticAI API.33 * Gets the headers for the InfermaticAI API.
34 * @param {import('./users').UserDirectoryList} directories User directories34 * @param {import('./users.js').UserDirectoryList} directories User directories
35 * @returns {object} Headers for the request35 * @returns {object} Headers for the request
36 */36 */
37function getInfermaticAIHeaders(directories) {37function getInfermaticAIHeaders(directories) {
@@ -44,7 +44,7 @@ function getInfermaticAIHeaders(directories) {
4444
45/**45/**
46 * Gets the headers for the DreamGen API.46 * Gets the headers for the DreamGen API.
47 * @param {import('./users').UserDirectoryList} directories User directories47 * @param {import('./users.js').UserDirectoryList} directories User directories
48 * @returns {object} Headers for the request48 * @returns {object} Headers for the request
49 */49 */
50function getDreamGenHeaders(directories) {50function getDreamGenHeaders(directories) {
@@ -57,7 +57,7 @@ function getDreamGenHeaders(directories) {
5757
58/**58/**
59 * Gets the headers for the OpenRouter API.59 * Gets the headers for the OpenRouter API.
60 * @param {import('./users').UserDirectoryList} directories User directories60 * @param {import('./users.js').UserDirectoryList} directories User directories
61 * @returns {object} Headers for the request61 * @returns {object} Headers for the request
62 */62 */
63function getOpenRouterHeaders(directories) {63function getOpenRouterHeaders(directories) {
@@ -69,7 +69,7 @@ function getOpenRouterHeaders(directories) {
6969
70/**70/**
71 * Gets the headers for the vLLM API.71 * Gets the headers for the vLLM API.
72 * @param {import('./users').UserDirectoryList} directories User directories72 * @param {import('./users.js').UserDirectoryList} directories User directories
73 * @returns {object} Headers for the request73 * @returns {object} Headers for the request
74 */74 */
75function getVllmHeaders(directories) {75function getVllmHeaders(directories) {
@@ -82,7 +82,7 @@ function getVllmHeaders(directories) {
8282
83/**83/**
84 * Gets the headers for the Aphrodite API.84 * Gets the headers for the Aphrodite API.
85 * @param {import('./users').UserDirectoryList} directories User directories85 * @param {import('./users.js').UserDirectoryList} directories User directories
86 * @returns {object} Headers for the request86 * @returns {object} Headers for the request
87 */87 */
88function getAphroditeHeaders(directories) {88function getAphroditeHeaders(directories) {
@@ -96,7 +96,7 @@ function getAphroditeHeaders(directories) {
9696
97/**97/**
98 * Gets the headers for the Tabby API.98 * Gets the headers for the Tabby API.
99 * @param {import('./users').UserDirectoryList} directories User directories99 * @param {import('./users.js').UserDirectoryList} directories User directories
100 * @returns {object} Headers for the request100 * @returns {object} Headers for the request
101 */101 */
102function getTabbyHeaders(directories) {102function getTabbyHeaders(directories) {
@@ -110,7 +110,7 @@ function getTabbyHeaders(directories) {
110110
111/**111/**
112 * Gets the headers for the LlamaCPP API.112 * Gets the headers for the LlamaCPP API.
113 * @param {import('./users').UserDirectoryList} directories User directories113 * @param {import('./users.js').UserDirectoryList} directories User directories
114 * @returns {object} Headers for the request114 * @returns {object} Headers for the request
115 */115 */
116function getLlamaCppHeaders(directories) {116function getLlamaCppHeaders(directories) {
@@ -123,7 +123,7 @@ function getLlamaCppHeaders(directories) {
123123
124/**124/**
125 * Gets the headers for the Ooba API.125 * Gets the headers for the Ooba API.
126 * @param {import('./users').UserDirectoryList} directories126 * @param {import('./users.js').UserDirectoryList} directories
127 * @returns {object} Headers for the request127 * @returns {object} Headers for the request
128 */128 */
129function getOobaHeaders(directories) {129function getOobaHeaders(directories) {
@@ -136,7 +136,7 @@ function getOobaHeaders(directories) {
136136
137/**137/**
138 * Gets the headers for the KoboldCpp API.138 * Gets the headers for the KoboldCpp API.
139 * @param {import('./users').UserDirectoryList} directories139 * @param {import('./users.js').UserDirectoryList} directories
140 * @returns {object} Headers for the request140 * @returns {object} Headers for the request
141 */141 */
142function getKoboldCppHeaders(directories) {142function getKoboldCppHeaders(directories) {
@@ -149,7 +149,7 @@ function getKoboldCppHeaders(directories) {
149149
150/**150/**
151 * Gets the headers for the Featherless API.151 * Gets the headers for the Featherless API.
152 * @param {import('./users').UserDirectoryList} directories152 * @param {import('./users.js').UserDirectoryList} directories
153 * @returns {object} Headers for the request153 * @returns {object} Headers for the request
154 */154 */
155function getFeatherlessHeaders(directories) {155function getFeatherlessHeaders(directories) {
@@ -161,7 +161,7 @@ function getFeatherlessHeaders(directories) {
161161
162/**162/**
163 * Gets the headers for the HuggingFace API.163 * Gets the headers for the HuggingFace API.
164 * @param {import('./users').UserDirectoryList} directories164 * @param {import('./users.js').UserDirectoryList} directories
165 * @returns {object} Headers for the request165 * @returns {object} Headers for the request
166 */166 */
167function getHuggingFaceHeaders(directories) {167function getHuggingFaceHeaders(directories) {
@@ -197,7 +197,7 @@ export function setAdditionalHeaders(request, args, server) {
197 * @param {object} requestHeaders Request headers197 * @param {object} requestHeaders Request headers
198 * @param {string} type API type198 * @param {string} type API type
199 * @param {string|null} server API server for new request199 * @param {string|null} server API server for new request
200 * @param {import('./users').UserDirectoryList} directories User directories200 * @param {import('./users.js').UserDirectoryList} directories User directories
201 */201 */
202export function setAdditionalHeadersByType(requestHeaders, type, server, directories) {202export function setAdditionalHeadersByType(requestHeaders, type, server, directories) {
203 const headerGetters = {203 const headerGetters = {
src/character-card-parser.js+1 -0
@@ -1,4 +1,5 @@
1import fs from 'node:fs';1import fs from 'node:fs';
2import { Buffer } from 'node:buffer';
23
3import encode from 'png-chunks-encode';4import encode from 'png-chunks-encode';
4import extract from 'png-chunks-extract';5import extract from 'png-chunks-extract';
src/constants.js+2 -2
@@ -8,7 +8,7 @@ export const PUBLIC_DIRECTORIES = {
8export const SETTINGS_FILE = 'settings.json';8export const SETTINGS_FILE = 'settings.json';
99
10/**10/**
11 * @type {import('./users').UserDirectoryList}11 * @type {import('./users.js').UserDirectoryList}
12 * @readonly12 * @readonly
13 * @enum {string}13 * @enum {string}
14 */14 */
@@ -45,7 +45,7 @@ export const USER_DIRECTORY_TEMPLATE = Object.freeze({
45});45});
4646
47/**47/**
48 * @type {import('./users').User}48 * @type {import('./users.js').User}
49 * @readonly49 * @readonly
50 */50 */
51export const DEFAULT_USER = Object.freeze({51export const DEFAULT_USER = Object.freeze({
src/endpoints/assets.js+1 -1
@@ -79,7 +79,7 @@ function getFiles(dir, files = []) {
7979
80/**80/**
81 * Ensure that the asset folders exist.81 * Ensure that the asset folders exist.
82 * @param {import('../users').UserDirectoryList} directories - The user's directories82 * @param {import('../users.js').UserDirectoryList} directories - The user's directories
83 */83 */
84function ensureFoldersExist(directories) {84function ensureFoldersExist(directories) {
85 const folderPath = path.join(directories.assets);85 const folderPath = path.join(directories.assets);
src/endpoints/characters.js+6 -5
@@ -2,6 +2,7 @@ import * as path from 'node:path';
2import * as fs from 'node:fs';2import * as fs from 'node:fs';
3import { promises as fsPromises } from 'node:fs';3import { promises as fsPromises } from 'node:fs';
4import * as readline from 'node:readline';4import * as readline from 'node:readline';
5import { Buffer } from 'node:buffer';
56
6import express from 'express';7import express from 'express';
7import sanitize from 'sanitize-filename';8import sanitize from 'sanitize-filename';
@@ -188,7 +189,7 @@ const calculateDataSize = (data) => {
188 * processCharacter - Process a given character, read its data and calculate its statistics.189 * processCharacter - Process a given character, read its data and calculate its statistics.
189 *190 *
190 * @param {string} item The name of the character.191 * @param {string} item The name of the character.
191 * @param {import('../users').UserDirectoryList} directories User directories192 * @param {import('../users.js').UserDirectoryList} directories User directories
192 * @return {Promise<object>} A Promise that resolves when the character processing is done.193 * @return {Promise<object>} A Promise that resolves when the character processing is done.
193 */194 */
194const processCharacter = async (item, directories) => {195const processCharacter = async (item, directories) => {
@@ -232,7 +233,7 @@ const processCharacter = async (item, directories) => {
232/**233/**
233 * Convert a character object to Spec V2 format.234 * Convert a character object to Spec V2 format.
234 * @param {object} jsonObject Character object235 * @param {object} jsonObject Character object
235 * @param {import('../users').UserDirectoryList} directories User directories236 * @param {import('../users.js').UserDirectoryList} directories User directories
236 * @param {boolean} hoistDate Will set the chat and create_date fields to the current date if they are missing237 * @param {boolean} hoistDate Will set the chat and create_date fields to the current date if they are missing
237 * @returns {object} Character object in Spec V2 format238 * @returns {object} Character object in Spec V2 format
238 */239 */
@@ -252,7 +253,7 @@ function getCharaCardV2(jsonObject, directories, hoistDate = true) {
252/**253/**
253 * Convert a character object to Spec V2 format.254 * Convert a character object to Spec V2 format.
254 * @param {object} char Character object255 * @param {object} char Character object
255 * @param {import('../users').UserDirectoryList} directories User directories256 * @param {import('../users.js').UserDirectoryList} directories User directories
256 * @returns {object} Character object in Spec V2 format257 * @returns {object} Character object in Spec V2 format
257 */258 */
258function convertToV2(char, directories) {259function convertToV2(char, directories) {
@@ -342,7 +343,7 @@ function readFromV2(char) {
342/**343/**
343 * Format character data to Spec V2 format.344 * Format character data to Spec V2 format.
344 * @param {object} data Character data345 * @param {object} data Character data
345 * @param {import('../users').UserDirectoryList} directories User directories346 * @param {import('../users.js').UserDirectoryList} directories User directories
346 * @returns347 * @returns
347 */348 */
348function charaFormatData(data, directories) {349function charaFormatData(data, directories) {
@@ -1081,7 +1082,7 @@ router.post('/chats', jsonParser, async function (request, response) {
1081/**1082/**
1082 * Gets the name for the uploaded PNG file.1083 * Gets the name for the uploaded PNG file.
1083 * @param {string} file File name1084 * @param {string} file File name
1084 * @param {import('../users').UserDirectoryList} directories User directories1085 * @param {import('../users.js').UserDirectoryList} directories User directories
1085 * @returns {string} - The name for the uploaded PNG file1086 * @returns {string} - The name for the uploaded PNG file
1086 */1087 */
1087function getPngName(file, directories) {1088function getPngName(file, directories) {
src/endpoints/content-manager.js+5 -4
@@ -1,5 +1,6 @@
1import * as fs from 'node:fs';1import * as fs from 'node:fs';
2import * as path from 'node:path';2import * as path from 'node:path';
3import { Buffer } from 'node:buffer';
34
4import express from 'express';5import express from 'express';
5import fetch from 'node-fetch';6import fetch from 'node-fetch';
@@ -50,7 +51,7 @@ export const CONTENT_TYPES = {
5051
51/**52/**
52 * Gets the default presets from the content directory.53 * Gets the default presets from the content directory.
53 * @param {import('../users').UserDirectoryList} directories User directories54 * @param {import('../users.js').UserDirectoryList} directories User directories
54 * @returns {object[]} Array of default presets55 * @returns {object[]} Array of default presets
55 */56 */
56export function getDefaultPresets(directories) {57export function getDefaultPresets(directories) {
@@ -97,7 +98,7 @@ export function getDefaultPresetFile(filename) {
97/**98/**
98 * Seeds content for a user.99 * Seeds content for a user.
99 * @param {ContentItem[]} contentIndex Content index100 * @param {ContentItem[]} contentIndex Content index
100 * @param {import('../users').UserDirectoryList} directories User directories101 * @param {import('../users.js').UserDirectoryList} directories User directories
101 * @param {string[]} forceCategories List of categories to force check (even if content check is skipped)102 * @param {string[]} forceCategories List of categories to force check (even if content check is skipped)
102 * @returns {Promise<boolean>} Whether any content was added103 * @returns {Promise<boolean>} Whether any content was added
103 */104 */
@@ -156,7 +157,7 @@ async function seedContentForUser(contentIndex, directories, forceCategories) {
156157
157/**158/**
158 * Checks for new content and seeds it for all users.159 * Checks for new content and seeds it for all users.
159 * @param {import('../users').UserDirectoryList[]} directoriesList List of user directories160 * @param {import('../users.js').UserDirectoryList[]} directoriesList List of user directories
160 * @param {string[]} forceCategories List of categories to force check (even if content check is skipped)161 * @param {string[]} forceCategories List of categories to force check (even if content check is skipped)
161 * @returns {Promise<void>}162 * @returns {Promise<void>}
162 */163 */
@@ -258,7 +259,7 @@ export function getContentOfType(type, format) {
258/**259/**
259 * Gets the target directory for the specified asset type.260 * Gets the target directory for the specified asset type.
260 * @param {ContentType} type Asset type261 * @param {ContentType} type Asset type
261 * @param {import('../users').UserDirectoryList} directories User directories262 * @param {import('../users.js').UserDirectoryList} directories User directories
262 * @returns {string | null} Target directory263 * @returns {string | null} Target directory
263 */264 */
264function getTargetByType(type, directories) {265function getTargetByType(type, directories) {
src/endpoints/images.js+1 -0
@@ -1,5 +1,6 @@
1import * as fs from 'node:fs';1import * as fs from 'node:fs';
2import * as path from 'node:path';2import * as path from 'node:path';
3import { Buffer } from 'node:buffer';
34
4import express from 'express';5import express from 'express';
5import sanitize from 'sanitize-filename';6import sanitize from 'sanitize-filename';
src/endpoints/novelai.js+1 -0
@@ -1,4 +1,5 @@
1import * as util from 'node:util';1import * as util from 'node:util';
2import { Buffer } from 'node:buffer';
23
3import fetch from 'node-fetch';4import fetch from 'node-fetch';
4import express from 'express';5import express from 'express';
src/endpoints/openai.js+1 -0
@@ -1,4 +1,5 @@
1import * as fs from 'node:fs';1import * as fs from 'node:fs';
2import { Buffer } from 'node:buffer';
23
3import fetch from 'node-fetch';4import fetch from 'node-fetch';
4import FormData from 'form-data';5import FormData from 'form-data';
src/endpoints/presets.js+1 -1
@@ -11,7 +11,7 @@ import { jsonParser } from '../express-common.js';
11/**11/**
12 * Gets the folder and extension for the preset settings based on the API source ID.12 * Gets the folder and extension for the preset settings based on the API source ID.
13 * @param {string} apiId API source ID13 * @param {string} apiId API source ID
14 * @param {import('../users').UserDirectoryList} directories User directories14 * @param {import('../users.js').UserDirectoryList} directories User directories
15 * @returns {object} Object containing the folder and extension for the preset settings15 * @returns {object} Object containing the folder and extension for the preset settings
16 */16 */
17function getPresetSettingsByAPI(apiId, directories) {17function getPresetSettingsByAPI(apiId, directories) {
src/endpoints/secrets.js+5 -5
@@ -59,7 +59,7 @@ const EXPORTABLE_KEYS = [
5959
60/**60/**
61 * Writes a secret to the secrets file61 * Writes a secret to the secrets file
62 * @param {import('../users').UserDirectoryList} directories User directories62 * @param {import('../users.js').UserDirectoryList} directories User directories
63 * @param {string} key Secret key63 * @param {string} key Secret key
64 * @param {string} value Secret value64 * @param {string} value Secret value
65 */65 */
@@ -79,7 +79,7 @@ export function writeSecret(directories, key, value) {
7979
80/**80/**
81 * Deletes a secret from the secrets file81 * Deletes a secret from the secrets file
82 * @param {import('../users').UserDirectoryList} directories User directories82 * @param {import('../users.js').UserDirectoryList} directories User directories
83 * @param {string} key Secret key83 * @param {string} key Secret key
84 * @returns84 * @returns
85 */85 */
@@ -98,7 +98,7 @@ export function deleteSecret(directories, key) {
9898
99/**99/**
100 * Reads a secret from the secrets file100 * Reads a secret from the secrets file
101 * @param {import('../users').UserDirectoryList} directories User directories101 * @param {import('../users.js').UserDirectoryList} directories User directories
102 * @param {string} key Secret key102 * @param {string} key Secret key
103 * @returns {string} Secret value103 * @returns {string} Secret value
104 */104 */
@@ -116,7 +116,7 @@ export function readSecret(directories, key) {
116116
117/**117/**
118 * Reads the secret state from the secrets file118 * Reads the secret state from the secrets file
119 * @param {import('../users').UserDirectoryList} directories User directories119 * @param {import('../users.js').UserDirectoryList} directories User directories
120 * @returns {object} Secret state120 * @returns {object} Secret state
121 */121 */
122export function readSecretState(directories) {122export function readSecretState(directories) {
@@ -139,7 +139,7 @@ export function readSecretState(directories) {
139139
140/**140/**
141 * Reads all secrets from the secrets file141 * Reads all secrets from the secrets file
142 * @param {import('../users').UserDirectoryList} directories User directories142 * @param {import('../users.js').UserDirectoryList} directories User directories
143 * @returns {Record<string, string> | undefined} Secrets143 * @returns {Record<string, string> | undefined} Secrets
144 */144 */
145export function getAllSecrets(directories) {145export function getAllSecrets(directories) {
src/endpoints/speech.js+1 -0
@@ -1,3 +1,4 @@
1import { Buffer } from 'node:buffer';
1import express from 'express';2import express from 'express';
2import wavefile from 'wavefile';3import wavefile from 'wavefile';
3import { jsonParser } from '../express-common.js';4import { jsonParser } from '../express-common.js';
src/endpoints/sprites.js+2 -2
@@ -11,7 +11,7 @@ import { jsonParser, urlencodedParser } from '../express-common.js';
1111
12/**12/**
13 * Gets the path to the sprites folder for the provided character name13 * Gets the path to the sprites folder for the provided character name
14 * @param {import('../users').UserDirectoryList} directories - User directories14 * @param {import('../users.js').UserDirectoryList} directories - User directories
15 * @param {string} name - The name of the character15 * @param {string} name - The name of the character
16 * @param {boolean} isSubfolder - Whether the name contains a subfolder16 * @param {boolean} isSubfolder - Whether the name contains a subfolder
17 * @returns {string | null} The path to the sprites folder. Null if the name is invalid.17 * @returns {string | null} The path to the sprites folder. Null if the name is invalid.
@@ -42,7 +42,7 @@ function getSpritesPath(directories, name, isSubfolder) {
42 * Imports base64 encoded sprites from RisuAI character data.42 * Imports base64 encoded sprites from RisuAI character data.
43 * The sprites are saved in the character's sprites folder.43 * The sprites are saved in the character's sprites folder.
44 * The additionalAssets and emotions are removed from the data.44 * The additionalAssets and emotions are removed from the data.
45 * @param {import('../users').UserDirectoryList} directories User directories45 * @param {import('../users.js').UserDirectoryList} directories User directories
46 * @param {object} data RisuAI character data46 * @param {object} data RisuAI character data
47 * @returns {void}47 * @returns {void}
48 */48 */
src/endpoints/thumbnails.js+4 -4
@@ -18,7 +18,7 @@ const pngFormat = getConfigValue('avatarThumbnailsPng', false);
1818
19/**19/**
20 * Gets a path to thumbnail folder based on the type.20 * Gets a path to thumbnail folder based on the type.
21 * @param {import('../users').UserDirectoryList} directories User directories21 * @param {import('../users.js').UserDirectoryList} directories User directories
22 * @param {'bg' | 'avatar'} type Thumbnail type22 * @param {'bg' | 'avatar'} type Thumbnail type
23 * @returns {string} Path to the thumbnails folder23 * @returns {string} Path to the thumbnails folder
24 */24 */
@@ -39,7 +39,7 @@ function getThumbnailFolder(directories, type) {
3939
40/**40/**
41 * Gets a path to the original images folder based on the type.41 * Gets a path to the original images folder based on the type.
42 * @param {import('../users').UserDirectoryList} directories User directories42 * @param {import('../users.js').UserDirectoryList} directories User directories
43 * @param {'bg' | 'avatar'} type Thumbnail type43 * @param {'bg' | 'avatar'} type Thumbnail type
44 * @returns {string} Path to the original images folder44 * @returns {string} Path to the original images folder
45 */45 */
@@ -60,7 +60,7 @@ function getOriginalFolder(directories, type) {
6060
61/**61/**
62 * Removes the generated thumbnail from the disk.62 * Removes the generated thumbnail from the disk.
63 * @param {import('../users').UserDirectoryList} directories User directories63 * @param {import('../users.js').UserDirectoryList} directories User directories
64 * @param {'bg' | 'avatar'} type Type of the thumbnail64 * @param {'bg' | 'avatar'} type Type of the thumbnail
65 * @param {string} file Name of the file65 * @param {string} file Name of the file
66 */66 */
@@ -77,7 +77,7 @@ export function invalidateThumbnail(directories, type, file) {
7777
78/**78/**
79 * Generates a thumbnail for the given file.79 * Generates a thumbnail for the given file.
80 * @param {import('../users').UserDirectoryList} directories User directories80 * @param {import('../users.js').UserDirectoryList} directories User directories
81 * @param {'bg' | 'avatar'} type Type of the thumbnail81 * @param {'bg' | 'avatar'} type Type of the thumbnail
82 * @param {string} file Name of the file82 * @param {string} file Name of the file
83 * @returns83 * @returns
src/endpoints/tokenizers.js+1 -0
@@ -1,5 +1,6 @@
1import * as fs from 'node:fs';1import * as fs from 'node:fs';
2import * as path from 'node:path';2import * as path from 'node:path';
3import { Buffer } from 'node:buffer';
34
4import express from 'express';5import express from 'express';
5import { sync as writeFileAtomicSync } from 'write-file-atomic';6import { sync as writeFileAtomicSync } from 'write-file-atomic';
src/endpoints/translate.js+2 -0
@@ -1,5 +1,7 @@
1import * as https from 'node:https';1import * as https from 'node:https';
2import { createRequire } from 'node:module';2import { createRequire } from 'node:module';
3import { Buffer } from 'node:buffer';
4
3import fetch from 'node-fetch';5import fetch from 'node-fetch';
4import express from 'express';6import express from 'express';
5import iconv from 'iconv-lite';7import iconv from 'iconv-lite';
src/endpoints/users-admin.js+6 -6
@@ -22,10 +22,10 @@ export const router = express.Router();
2222
23router.post('/get', requireAdminMiddleware, jsonParser, async (_request, response) => {23router.post('/get', requireAdminMiddleware, jsonParser, async (_request, response) => {
24 try {24 try {
25 /** @type {import('../users').User[]} */25 /** @type {import('../users.js').User[]} */
26 const users = await storage.values(x => x.key.startsWith(KEY_PREFIX));26 const users = await storage.values(x => x.key.startsWith(KEY_PREFIX));
2727
28 /** @type {Promise<import('../users').UserViewModel>[]} */28 /** @type {Promise<import('../users.js').UserViewModel>[]} */
29 const viewModelPromises = users29 const viewModelPromises = users
30 .map(user => new Promise(resolve => {30 .map(user => new Promise(resolve => {
31 getUserAvatar(user.handle).then(avatar =>31 getUserAvatar(user.handle).then(avatar =>
@@ -62,7 +62,7 @@ router.post('/disable', requireAdminMiddleware, jsonParser, async (request, resp
62 return response.status(400).json({ error: 'Cannot disable yourself' });62 return response.status(400).json({ error: 'Cannot disable yourself' });
63 }63 }
6464
65 /** @type {import('../users').User} */65 /** @type {import('../users.js').User} */
66 const user = await storage.getItem(toKey(request.body.handle));66 const user = await storage.getItem(toKey(request.body.handle));
6767
68 if (!user) {68 if (!user) {
@@ -86,7 +86,7 @@ router.post('/enable', requireAdminMiddleware, jsonParser, async (request, respo
86 return response.status(400).json({ error: 'Missing required fields' });86 return response.status(400).json({ error: 'Missing required fields' });
87 }87 }
8888
89 /** @type {import('../users').User} */89 /** @type {import('../users.js').User} */
90 const user = await storage.getItem(toKey(request.body.handle));90 const user = await storage.getItem(toKey(request.body.handle));
9191
92 if (!user) {92 if (!user) {
@@ -110,7 +110,7 @@ router.post('/promote', requireAdminMiddleware, jsonParser, async (request, resp
110 return response.status(400).json({ error: 'Missing required fields' });110 return response.status(400).json({ error: 'Missing required fields' });
111 }111 }
112112
113 /** @type {import('../users').User} */113 /** @type {import('../users.js').User} */
114 const user = await storage.getItem(toKey(request.body.handle));114 const user = await storage.getItem(toKey(request.body.handle));
115115
116 if (!user) {116 if (!user) {
@@ -139,7 +139,7 @@ router.post('/demote', requireAdminMiddleware, jsonParser, async (request, respo
139 return response.status(400).json({ error: 'Cannot demote yourself' });139 return response.status(400).json({ error: 'Cannot demote yourself' });
140 }140 }
141141
142 /** @type {import('../users').User} */142 /** @type {import('../users.js').User} */
143 const user = await storage.getItem(toKey(request.body.handle));143 const user = await storage.getItem(toKey(request.body.handle));
144144
145 if (!user) {145 if (!user) {
src/endpoints/users-private.js+3 -3
@@ -72,7 +72,7 @@ router.post('/change-avatar', jsonParser, async (request, response) => {
72 return response.status(400).json({ error: 'Invalid data URL' });72 return response.status(400).json({ error: 'Invalid data URL' });
73 }73 }
7474
75 /** @type {import('../users').User} */75 /** @type {import('../users.js').User} */
76 const user = await storage.getItem(toKey(request.body.handle));76 const user = await storage.getItem(toKey(request.body.handle));
7777
78 if (!user) {78 if (!user) {
@@ -101,7 +101,7 @@ router.post('/change-password', jsonParser, async (request, response) => {
101 return response.status(403).json({ error: 'Unauthorized' });101 return response.status(403).json({ error: 'Unauthorized' });
102 }102 }
103103
104 /** @type {import('../users').User} */104 /** @type {import('../users.js').User} */
105 const user = await storage.getItem(toKey(request.body.handle));105 const user = await storage.getItem(toKey(request.body.handle));
106106
107 if (!user) {107 if (!user) {
@@ -189,7 +189,7 @@ router.post('/change-name', jsonParser, async (request, response) => {
189 return response.status(403).json({ error: 'Unauthorized' });189 return response.status(403).json({ error: 'Unauthorized' });
190 }190 }
191191
192 /** @type {import('../users').User} */192 /** @type {import('../users.js').User} */
193 const user = await storage.getItem(toKey(request.body.handle));193 const user = await storage.getItem(toKey(request.body.handle));
194194
195 if (!user) {195 if (!user) {
src/endpoints/users-public.js+5 -5
@@ -26,10 +26,10 @@ router.post('/list', async (_request, response) => {
26 return response.sendStatus(204);26 return response.sendStatus(204);
27 }27 }
2828
29 /** @type {import('../users').User[]} */29 /** @type {import('../users.js').User[]} */
30 const users = await storage.values(x => x.key.startsWith(KEY_PREFIX));30 const users = await storage.values(x => x.key.startsWith(KEY_PREFIX));
3131
32 /** @type {Promise<import('../users').UserViewModel>[]} */32 /** @type {Promise<import('../users.js').UserViewModel>[]} */
33 const viewModelPromises = users33 const viewModelPromises = users
34 .filter(x => x.enabled)34 .filter(x => x.enabled)
35 .map(user => new Promise(async (resolve) => {35 .map(user => new Promise(async (resolve) => {
@@ -63,7 +63,7 @@ router.post('/login', jsonParser, async (request, response) => {
63 const ip = getIpFromRequest(request);63 const ip = getIpFromRequest(request);
64 await loginLimiter.consume(ip);64 await loginLimiter.consume(ip);
6565
66 /** @type {import('../users').User} */66 /** @type {import('../users.js').User} */
67 const user = await storage.getItem(toKey(request.body.handle));67 const user = await storage.getItem(toKey(request.body.handle));
6868
69 if (!user) {69 if (!user) {
@@ -111,7 +111,7 @@ router.post('/recover-step1', jsonParser, async (request, response) => {
111 const ip = getIpFromRequest(request);111 const ip = getIpFromRequest(request);
112 await recoverLimiter.consume(ip);112 await recoverLimiter.consume(ip);
113113
114 /** @type {import('../users').User} */114 /** @type {import('../users.js').User} */
115 const user = await storage.getItem(toKey(request.body.handle));115 const user = await storage.getItem(toKey(request.body.handle));
116116
117 if (!user) {117 if (!user) {
@@ -148,7 +148,7 @@ router.post('/recover-step2', jsonParser, async (request, response) => {
148 return response.status(400).json({ error: 'Missing required fields' });148 return response.status(400).json({ error: 'Missing required fields' });
149 }149 }
150150
151 /** @type {import('../users').User} */151 /** @type {import('../users.js').User} */
152 const user = await storage.getItem(toKey(request.body.handle));152 const user = await storage.getItem(toKey(request.body.handle));
153 const ip = getIpFromRequest(request);153 const ip = getIpFromRequest(request);
154154
src/endpoints/vectors.js+8 -8
@@ -39,7 +39,7 @@ const SOURCES = [
39 * @param {Object} sourceSettings - Settings for the source, if it needs any39 * @param {Object} sourceSettings - Settings for the source, if it needs any
40 * @param {string} text - The text to get the vector for40 * @param {string} text - The text to get the vector for
41 * @param {boolean} isQuery - If the text is a query for embedding search41 * @param {boolean} isQuery - If the text is a query for embedding search
42 * @param {import('../users').UserDirectoryList} directories - The directories object for the user42 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
43 * @returns {Promise<number[]>} - The vector for the text43 * @returns {Promise<number[]>} - The vector for the text
44 */44 */
45async function getVector(source, sourceSettings, text, isQuery, directories) {45async function getVector(source, sourceSettings, text, isQuery, directories) {
@@ -75,7 +75,7 @@ async function getVector(source, sourceSettings, text, isQuery, directories) {
75 * @param {Object} sourceSettings - Settings for the source, if it needs any75 * @param {Object} sourceSettings - Settings for the source, if it needs any
76 * @param {string[]} texts - The array of texts to get the vector for76 * @param {string[]} texts - The array of texts to get the vector for
77 * @param {boolean} isQuery - If the text is a query for embedding search77 * @param {boolean} isQuery - If the text is a query for embedding search
78 * @param {import('../users').UserDirectoryList} directories - The directories object for the user78 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
79 * @returns {Promise<number[][]>} - The array of vectors for the texts79 * @returns {Promise<number[][]>} - The array of vectors for the texts
80 */80 */
81async function getBatchVector(source, sourceSettings, texts, isQuery, directories) {81async function getBatchVector(source, sourceSettings, texts, isQuery, directories) {
@@ -195,7 +195,7 @@ function getModelScope(sourceSettings) {
195195
196/**196/**
197 * Gets the index for the vector collection197 * Gets the index for the vector collection
198 * @param {import('../users').UserDirectoryList} directories - User directories198 * @param {import('../users.js').UserDirectoryList} directories - User directories
199 * @param {string} collectionId - The collection ID199 * @param {string} collectionId - The collection ID
200 * @param {string} source - The source of the vector200 * @param {string} source - The source of the vector
201 * @param {object} sourceSettings - The model for the source201 * @param {object} sourceSettings - The model for the source
@@ -215,7 +215,7 @@ async function getIndex(directories, collectionId, source, sourceSettings) {
215215
216/**216/**
217 * Inserts items into the vector collection217 * Inserts items into the vector collection
218 * @param {import('../users').UserDirectoryList} directories - User directories218 * @param {import('../users.js').UserDirectoryList} directories - User directories
219 * @param {string} collectionId - The collection ID219 * @param {string} collectionId - The collection ID
220 * @param {string} source - The source of the vector220 * @param {string} source - The source of the vector
221 * @param {Object} sourceSettings - Settings for the source, if it needs any221 * @param {Object} sourceSettings - Settings for the source, if it needs any
@@ -239,7 +239,7 @@ async function insertVectorItems(directories, collectionId, source, sourceSettin
239239
240/**240/**
241 * Gets the hashes of the items in the vector collection241 * Gets the hashes of the items in the vector collection
242 * @param {import('../users').UserDirectoryList} directories - User directories242 * @param {import('../users.js').UserDirectoryList} directories - User directories
243 * @param {string} collectionId - The collection ID243 * @param {string} collectionId - The collection ID
244 * @param {string} source - The source of the vector244 * @param {string} source - The source of the vector
245 * @param {Object} sourceSettings - Settings for the source, if it needs any245 * @param {Object} sourceSettings - Settings for the source, if it needs any
@@ -256,7 +256,7 @@ async function getSavedHashes(directories, collectionId, source, sourceSettings)
256256
257/**257/**
258 * Deletes items from the vector collection by hash258 * Deletes items from the vector collection by hash
259 * @param {import('../users').UserDirectoryList} directories - User directories259 * @param {import('../users.js').UserDirectoryList} directories - User directories
260 * @param {string} collectionId - The collection ID260 * @param {string} collectionId - The collection ID
261 * @param {string} source - The source of the vector261 * @param {string} source - The source of the vector
262 * @param {Object} sourceSettings - Settings for the source, if it needs any262 * @param {Object} sourceSettings - Settings for the source, if it needs any
@@ -277,7 +277,7 @@ async function deleteVectorItems(directories, collectionId, source, sourceSettin
277277
278/**278/**
279 * Gets the hashes of the items in the vector collection that match the search text279 * Gets the hashes of the items in the vector collection that match the search text
280 * @param {import('../users').UserDirectoryList} directories - User directories280 * @param {import('../users.js').UserDirectoryList} directories - User directories
281 * @param {string} collectionId - The collection ID281 * @param {string} collectionId - The collection ID
282 * @param {string} source - The source of the vector282 * @param {string} source - The source of the vector
283 * @param {Object} sourceSettings - Settings for the source, if it needs any283 * @param {Object} sourceSettings - Settings for the source, if it needs any
@@ -298,7 +298,7 @@ async function queryCollection(directories, collectionId, source, sourceSettings
298298
299/**299/**
300 * Queries multiple collections for the given search queries. Returns the overall top K results.300 * Queries multiple collections for the given search queries. Returns the overall top K results.
301 * @param {import('../users').UserDirectoryList} directories - User directories301 * @param {import('../users.js').UserDirectoryList} directories - User directories
302 * @param {string[]} collectionIds - The collection IDs to query302 * @param {string[]} collectionIds - The collection IDs to query
303 * @param {string} source - The source of the vector303 * @param {string} source - The source of the vector
304 * @param {Object} sourceSettings - Settings for the source, if it needs any304 * @param {Object} sourceSettings - Settings for the source, if it needs any
src/endpoints/worldinfo.js+1 -1
@@ -9,7 +9,7 @@ import { jsonParser, urlencodedParser } from '../express-common.js';
99
10/**10/**
11 * Reads a World Info file and returns its contents11 * Reads a World Info file and returns its contents
12 * @param {import('../users').UserDirectoryList} directories User directories12 * @param {import('../users.js').UserDirectoryList} directories User directories
13 * @param {string} worldInfoName Name of the World Info file13 * @param {string} worldInfoName Name of the World Info file
14 * @param {boolean} allowDummy If true, returns an empty object if the file doesn't exist14 * @param {boolean} allowDummy If true, returns an empty object if the file doesn't exist
15 * @returns {object} World Info file contents15 * @returns {object} World Info file contents
src/middleware/basicAuth.js+1 -0
@@ -2,6 +2,7 @@
2 * When applied, this middleware will ensure the request contains the required header for basic authentication and only2 * When applied, this middleware will ensure the request contains the required header for basic authentication and only
3 * allow access to the endpoint after successful authentication.3 * allow access to the endpoint after successful authentication.
4 */4 */
5import { Buffer } from 'node:buffer';
5import storage from 'node-persist';6import storage from 'node-persist';
6import { getAllUserHandles, toKey, getPasswordHash } from '../users.js';7import { getAllUserHandles, toKey, getPasswordHash } from '../users.js';
7import { getConfig, getConfigValue } from '../util.js';8import { getConfig, getConfigValue } from '../util.js';
src/middleware/multerMonkeyPatch.js+2 -0
@@ -1,3 +1,5 @@
1import { Buffer } from 'node:buffer';
2
1/**3/**
2 * Decodes a file name from Latin1 to UTF-8.4 * Decodes a file name from Latin1 to UTF-8.
3 * @param {string} str Input string5 * @param {string} str Input string
src/transformers.mjs+1 -0
@@ -1,5 +1,6 @@
1import path from 'node:path';1import path from 'node:path';
2import fs from 'node:fs';2import fs from 'node:fs';
3import { Buffer } from 'node:buffer';
34
4import { pipeline, env, RawImage, Pipeline } from 'sillytavern-transformers';5import { pipeline, env, RawImage, Pipeline } from 'sillytavern-transformers';
5import { getConfigValue } from './util.js';6import { getConfigValue } from './util.js';
src/users.js+3 -2
@@ -3,6 +3,7 @@ import * as path from 'node:path';
3import * as fs from 'node:fs';3import * as fs from 'node:fs';
4import * as crypto from 'node:crypto';4import * as crypto from 'node:crypto';
5import * as os from 'node:os';5import * as os from 'node:os';
6import { Buffer } from 'node:buffer';
67
7// Express and other dependencies8// Express and other dependencies
8import storage from 'node-persist';9import storage from 'node-persist';
@@ -93,7 +94,7 @@ const STORAGE_KEYS = {
9394
94/**95/**
95 * Ensures that the content directories exist.96 * Ensures that the content directories exist.
96 * @returns {Promise<import('./users').UserDirectoryList[]>} - The list of user directories97 * @returns {Promise<import('./users.js').UserDirectoryList[]>} - The list of user directories
97 */98 */
98export async function ensurePublicDirectoriesExist() {99export async function ensurePublicDirectoriesExist() {
99 for (const dir of Object.values(PUBLIC_DIRECTORIES)) {100 for (const dir of Object.values(PUBLIC_DIRECTORIES)) {
@@ -116,7 +117,7 @@ export async function ensurePublicDirectoriesExist() {
116117
117/**118/**
118 * Gets a list of all user directories.119 * Gets a list of all user directories.
119 * @returns {Promise<import('./users').UserDirectoryList[]>} - The list of user directories120 * @returns {Promise<import('./users.js').UserDirectoryList[]>} - The list of user directories
120 */121 */
121export async function getUserDirectoriesList() {122export async function getUserDirectoriesList() {
122 const userHandles = await getAllUserHandles();123 const userHandles = await getAllUserHandles();
src/util.js+1 -0
@@ -3,6 +3,7 @@ import * as fs from 'node:fs';
3import * as http2 from 'node:http2';3import * as http2 from 'node:http2';
4import { Readable } from 'node:stream';4import { Readable } from 'node:stream';
5import { createRequire } from 'node:module';5import { createRequire } from 'node:module';
6import { Buffer } from 'node:buffer';
67
7import yaml from 'yaml';8import yaml from 'yaml';
8import { sync as commandExistsSync } from 'command-exists';9import { sync as commandExistsSync } from 'command-exists';
src/vectors/cohere-vectors.js+2 -2
@@ -5,7 +5,7 @@ import { SECRET_KEYS, readSecret } from '../endpoints/secrets.js';
5 * Gets the vector for the given text batch from an OpenAI compatible endpoint.5 * Gets the vector for the given text batch from an OpenAI compatible endpoint.
6 * @param {string[]} texts - The array of texts to get the vector for6 * @param {string[]} texts - The array of texts to get the vector for
7 * @param {boolean} isQuery - If the text is a query for embedding search7 * @param {boolean} isQuery - If the text is a query for embedding search
8 * @param {import('../users').UserDirectoryList} directories - The directories object for the user8 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
9 * @param {string} model - The model to use for the embedding9 * @param {string} model - The model to use for the embedding
10 * @returns {Promise<number[][]>} - The array of vectors for the texts10 * @returns {Promise<number[][]>} - The array of vectors for the texts
11 */11 */
@@ -51,7 +51,7 @@ export async function getCohereBatchVector(texts, isQuery, directories, model) {
51 * Gets the vector for the given text from an OpenAI compatible endpoint.51 * Gets the vector for the given text from an OpenAI compatible endpoint.
52 * @param {string} text - The text to get the vector for52 * @param {string} text - The text to get the vector for
53 * @param {boolean} isQuery - If the text is a query for embedding search53 * @param {boolean} isQuery - If the text is a query for embedding search
54 * @param {import('../users').UserDirectoryList} directories - The directories object for the user54 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
55 * @param {string} model - The model to use for the embedding55 * @param {string} model - The model to use for the embedding
56 * @returns {Promise<number[]>} - The vector for the text56 * @returns {Promise<number[]>} - The vector for the text
57 */57 */
src/vectors/llamacpp-vectors.js+2 -2
@@ -6,7 +6,7 @@ import { TEXTGEN_TYPES } from '../constants.js';
6 * Gets the vector for the given text from LlamaCpp6 * Gets the vector for the given text from LlamaCpp
7 * @param {string[]} texts - The array of texts to get the vectors for7 * @param {string[]} texts - The array of texts to get the vectors for
8 * @param {string} apiUrl - The API URL8 * @param {string} apiUrl - The API URL
9 * @param {import('../users').UserDirectoryList} directories - The directories object for the user9 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
10 * @returns {Promise<number[][]>} - The array of vectors for the texts10 * @returns {Promise<number[][]>} - The array of vectors for the texts
11 */11 */
12export async function getLlamaCppBatchVector(texts, apiUrl, directories) {12export async function getLlamaCppBatchVector(texts, apiUrl, directories) {
@@ -47,7 +47,7 @@ export async function getLlamaCppBatchVector(texts, apiUrl, directories) {
47 * Gets the vector for the given text from LlamaCpp47 * Gets the vector for the given text from LlamaCpp
48 * @param {string} text - The text to get the vector for48 * @param {string} text - The text to get the vector for
49 * @param {string} apiUrl - The API URL49 * @param {string} apiUrl - The API URL
50 * @param {import('../users').UserDirectoryList} directories - The directories object for the user50 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
51 * @returns {Promise<number[]>} - The vector for the text51 * @returns {Promise<number[]>} - The vector for the text
52 */52 */
53export async function getLlamaCppVector(text, apiUrl, directories) {53export async function getLlamaCppVector(text, apiUrl, directories) {
src/vectors/makersuite-vectors.js+2 -2
@@ -5,7 +5,7 @@ const API_MAKERSUITE = 'https://generativelanguage.googleapis.com';
5/**5/**
6 * Gets the vector for the given text from gecko model6 * Gets the vector for the given text from gecko model
7 * @param {string[]} texts - The array of texts to get the vector for7 * @param {string[]} texts - The array of texts to get the vector for
8 * @param {import('../users').UserDirectoryList} directories - The directories object for the user8 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
9 * @returns {Promise<number[][]>} - The array of vectors for the texts9 * @returns {Promise<number[][]>} - The array of vectors for the texts
10 */10 */
11export async function getMakerSuiteBatchVector(texts, directories) {11export async function getMakerSuiteBatchVector(texts, directories) {
@@ -16,7 +16,7 @@ export async function getMakerSuiteBatchVector(texts, directories) {
16/**16/**
17 * Gets the vector for the given text from Gemini API text-embedding-004 model17 * Gets the vector for the given text from Gemini API text-embedding-004 model
18 * @param {string} text - The text to get the vector for18 * @param {string} text - The text to get the vector for
19 * @param {import('../users').UserDirectoryList} directories - The directories object for the user19 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
20 * @returns {Promise<number[]>} - The vector for the text20 * @returns {Promise<number[]>} - The vector for the text
21 */21 */
22export async function getMakerSuiteVector(text, directories) {22export async function getMakerSuiteVector(text, directories) {
src/vectors/nomicai-vectors.js+2 -2
@@ -13,7 +13,7 @@ const SOURCES = {
13 * Gets the vector for the given text batch from an OpenAI compatible endpoint.13 * Gets the vector for the given text batch from an OpenAI compatible endpoint.
14 * @param {string[]} texts - The array of texts to get the vector for14 * @param {string[]} texts - The array of texts to get the vector for
15 * @param {string} source - The source of the vector15 * @param {string} source - The source of the vector
16 * @param {import('../users').UserDirectoryList} directories - The directories object for the user16 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
17 * @returns {Promise<number[][]>} - The array of vectors for the texts17 * @returns {Promise<number[][]>} - The array of vectors for the texts
18 */18 */
19export async function getNomicAIBatchVector(texts, source, directories) {19export async function getNomicAIBatchVector(texts, source, directories) {
@@ -64,7 +64,7 @@ export async function getNomicAIBatchVector(texts, source, directories) {
64 * Gets the vector for the given text from an OpenAI compatible endpoint.64 * Gets the vector for the given text from an OpenAI compatible endpoint.
65 * @param {string} text - The text to get the vector for65 * @param {string} text - The text to get the vector for
66 * @param {string} source - The source of the vector66 * @param {string} source - The source of the vector
67 * @param {import('../users').UserDirectoryList} directories - The directories object for the user67 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
68 * @returns {Promise<number[]>} - The vector for the text68 * @returns {Promise<number[]>} - The vector for the text
69 */69 */
70export async function getNomicAIVector(text, source, directories) {70export async function getNomicAIVector(text, source, directories) {
src/vectors/ollama-vectors.js+2 -2
@@ -8,7 +8,7 @@ import { TEXTGEN_TYPES } from '../constants.js';
8 * @param {string} apiUrl - The API URL8 * @param {string} apiUrl - The API URL
9 * @param {string} model - The model to use9 * @param {string} model - The model to use
10 * @param {boolean} keep - Keep the model loaded in memory10 * @param {boolean} keep - Keep the model loaded in memory
11 * @param {import('../users').UserDirectoryList} directories - The directories object for the user11 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
12 * @returns {Promise<number[][]>} - The array of vectors for the texts12 * @returns {Promise<number[][]>} - The array of vectors for the texts
13 */13 */
14export async function getOllamaBatchVector(texts, apiUrl, model, keep, directories) {14export async function getOllamaBatchVector(texts, apiUrl, model, keep, directories) {
@@ -26,7 +26,7 @@ export async function getOllamaBatchVector(texts, apiUrl, model, keep, directori
26 * @param {string} apiUrl - The API URL26 * @param {string} apiUrl - The API URL
27 * @param {string} model - The model to use27 * @param {string} model - The model to use
28 * @param {boolean} keep - Keep the model loaded in memory28 * @param {boolean} keep - Keep the model loaded in memory
29 * @param {import('../users').UserDirectoryList} directories - The directories object for the user29 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
30 * @returns {Promise<number[]>} - The vector for the text30 * @returns {Promise<number[]>} - The vector for the text
31 */31 */
32export async function getOllamaVector(text, apiUrl, model, keep, directories) {32export async function getOllamaVector(text, apiUrl, model, keep, directories) {
src/vectors/openai-vectors.js+2 -2
@@ -23,7 +23,7 @@ const SOURCES = {
23 * Gets the vector for the given text batch from an OpenAI compatible endpoint.23 * Gets the vector for the given text batch from an OpenAI compatible endpoint.
24 * @param {string[]} texts - The array of texts to get the vector for24 * @param {string[]} texts - The array of texts to get the vector for
25 * @param {string} source - The source of the vector25 * @param {string} source - The source of the vector
26 * @param {import('../users').UserDirectoryList} directories - The directories object for the user26 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
27 * @param {string} model - The model to use for the embedding27 * @param {string} model - The model to use for the embedding
28 * @returns {Promise<number[][]>} - The array of vectors for the texts28 * @returns {Promise<number[][]>} - The array of vectors for the texts
29 */29 */
@@ -79,7 +79,7 @@ export async function getOpenAIBatchVector(texts, source, directories, model = '
79 * Gets the vector for the given text from an OpenAI compatible endpoint.79 * Gets the vector for the given text from an OpenAI compatible endpoint.
80 * @param {string} text - The text to get the vector for80 * @param {string} text - The text to get the vector for
81 * @param {string} source - The source of the vector81 * @param {string} source - The source of the vector
82 * @param {import('../users').UserDirectoryList} directories - The directories object for the user82 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
83 * @param {string} model - The model to use for the embedding83 * @param {string} model - The model to use for the embedding
84 * @returns {Promise<number[]>} - The vector for the text84 * @returns {Promise<number[]>} - The vector for the text
85 */85 */
src/vectors/vllm-vectors.js+2 -2
@@ -7,7 +7,7 @@ import { TEXTGEN_TYPES } from '../constants.js';
7 * @param {string[]} texts - The array of texts to get the vectors for7 * @param {string[]} texts - The array of texts to get the vectors for
8 * @param {string} apiUrl - The API URL8 * @param {string} apiUrl - The API URL
9 * @param {string} model - The model to use9 * @param {string} model - The model to use
10 * @param {import('../users').UserDirectoryList} directories - The directories object for the user10 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
11 * @returns {Promise<number[][]>} - The array of vectors for the texts11 * @returns {Promise<number[][]>} - The array of vectors for the texts
12 */12 */
13export async function getVllmBatchVector(texts, apiUrl, model, directories) {13export async function getVllmBatchVector(texts, apiUrl, model, directories) {
@@ -49,7 +49,7 @@ export async function getVllmBatchVector(texts, apiUrl, model, directories) {
49 * @param {string} text - The text to get the vector for49 * @param {string} text - The text to get the vector for
50 * @param {string} apiUrl - The API URL50 * @param {string} apiUrl - The API URL
51 * @param {string} model - The model to use51 * @param {string} model - The model to use
52 * @param {import('../users').UserDirectoryList} directories - The directories object for the user52 * @param {import('../users.js').UserDirectoryList} directories - The directories object for the user
53 * @returns {Promise<number[]>} - The vector for the text53 * @returns {Promise<number[]>} - The vector for the text
54 */54 */
55export async function getVllmVector(text, apiUrl, model, directories) {55export async function getVllmVector(text, apiUrl, model, directories) {