From f854948de5cc9f85774bf0e270cb9ff9a779ec1c Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 15:10:47 +0300 Subject: [PATCH 01/19] NVM colab --- colab/GPU.ipynb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/colab/GPU.ipynb b/colab/GPU.ipynb index 868062f80..25f5b8b01 100644 --- a/colab/GPU.ipynb +++ b/colab/GPU.ipynb @@ -235,6 +235,8 @@ "%cd /\n", "def setupNVM():\n", " !curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash\n", + " !export NVM_DIR=\"$HOME/.nvm\"\n", + " ![ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\"\n", "ii.addTask(\"Setup NVM\", setupNVM)\n", "\n", "def installNode():\n", From c9b64082d059e2b391360ee38ba6667ecb229d0e Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 15:42:35 +0300 Subject: [PATCH 02/19] Replace nvm with n on colab --- colab/GPU.ipynb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/colab/GPU.ipynb b/colab/GPU.ipynb index 25f5b8b01..e82f9891b 100644 --- a/colab/GPU.ipynb +++ b/colab/GPU.ipynb @@ -233,15 +233,10 @@ "# ---\n", "# nodejs\n", "%cd /\n", - "def setupNVM():\n", - " !curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash\n", - " !export NVM_DIR=\"$HOME/.nvm\"\n", - " ![ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\"\n", - "ii.addTask(\"Setup NVM\", setupNVM)\n", - "\n", "def installNode():\n", - " !nvm install 19.1.0\n", - " !nvm use 19.1.0\n", + " !npm install -g n\n", + " !n 19\n", + " !node --version\n", "ii.addTask(\"Install node\", installNode)\n", "\n", "\n", From 794bc310d4d97dfb910287e7d066fee85cebfd70 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 15:56:12 +0300 Subject: [PATCH 03/19] Activate world info only after swipe chat shift --- public/script.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/script.js b/public/script.js index 789a3deb3..1b16ac562 100644 --- a/public/script.js +++ b/public/script.js @@ -1566,8 +1566,6 @@ async function Generate(type, automatic_trigger, force_name2) { hordeAmountGen = adjustedParams.maxLength; } - let { worldInfoString, worldInfoBefore, worldInfoAfter } = getWorldInfoPrompt(chat2); - // Extension added strings const allAnchors = getAllExtensionPrompts(); const afterScenarioAnchor = getExtensionPrompt(extension_prompt_types.AFTER_SCENARIO); @@ -1575,12 +1573,13 @@ async function Generate(type, automatic_trigger, force_name2) { /////////////////////// swipecode if (type == 'swipe') { - console.log('pre swipe shift: ' + chat2.length); console.log('shifting swipe chat2'); chat2.shift(); - } + + let { worldInfoString, worldInfoBefore, worldInfoAfter } = getWorldInfoPrompt(chat2); + console.log('post swipe shift:' + chat2.length); var i = 0; From f6ed23d29d93a5207494643c449ad32a36e695ed Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 16:45:09 +0300 Subject: [PATCH 04/19] Fix swipe on first message when streaming is on --- public/script.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 1b16ac562..511af7cfe 100644 --- a/public/script.js +++ b/public/script.js @@ -1231,6 +1231,7 @@ class StreamingProcessor { let formattedText = messageFormating(processedText, chat[messageId].name, chat[messageId].is_system, chat[messageId].force_avatar); const mesText = $(`#chat .mes[mesid="${messageId}"] .mes_text`); mesText.html(formattedText); + this.setFirstSwipe(messageId); } scrollChatToBottom(); @@ -1257,6 +1258,14 @@ class StreamingProcessor { showSwipeButtons(); } + setFirstSwipe(messageId) { + if (this.type !== 'swipe' && this.type !== 'impersonate') { + if (chat[messageId]['swipes'].length === 1 && chat[messageId]['swipe_id'] === 0) { + chat[messageId]['swipes'][0] = chat[messageId]['mes']; + } + } + } + onStopStreaming() { this.onErrorStreaming(); } @@ -1274,11 +1283,12 @@ class StreamingProcessor { this.isFinished = false; this.generator = this.nullStreamingGeneration; this.abortController = new AbortController(); + this.firstMessageText = '...'; } async generate() { if (this.messageId == -1) { - this.messageId = this.onStartStreaming('...'); + this.messageId = this.onStartStreaming(this.firstMessageText); await delay(1); // delay for message to be rendered } @@ -1327,6 +1337,7 @@ async function Generate(type, automatic_trigger, force_name2) { if (isStreamingEnabled()) { streamingProcessor = new StreamingProcessor(type, force_name2); + hideSwipeButtons(); } else { streamingProcessor = false; From e4f8aa310d376aa4715f9f26148fd0b74b69fd19 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 17:37:32 +0300 Subject: [PATCH 05/19] Check for swipes before trying to record --- public/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/script.js b/public/script.js index 511af7cfe..2bef5c553 100644 --- a/public/script.js +++ b/public/script.js @@ -1260,7 +1260,7 @@ class StreamingProcessor { setFirstSwipe(messageId) { if (this.type !== 'swipe' && this.type !== 'impersonate') { - if (chat[messageId]['swipes'].length === 1 && chat[messageId]['swipe_id'] === 0) { + if (Array.isArray(chat[messageId]['swipes']) && chat[messageId]['swipes'].length === 1 && chat[messageId]['swipe_id'] === 0) { chat[messageId]['swipes'][0] = chat[messageId]['mes']; } } From 075f387506a86136cea5a09946183a58d5f6a28e Mon Sep 17 00:00:00 2001 From: Cohee Date: Sat, 22 Apr 2023 19:09:09 +0300 Subject: [PATCH 06/19] Create npm-publish.yml --- .github/workflows/npm-publish.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 000000000..6cdebafb6 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} From 683cc5aaf78039a82c8635441d91980d7b87601c Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 19:13:11 +0300 Subject: [PATCH 07/19] Rebranding --- package-lock.json | 10 ++--- package.json | 6 +-- public/notes/1.html | 2 +- public/notes/10.html | 4 +- public/notes/11.html | 2 +- public/notes/12.html | 2 +- public/notes/13.html | 2 +- public/notes/13_1.html | 2 +- public/notes/2.html | 2 +- public/notes/3.html | 2 +- public/notes/4.html | 6 +-- public/notes/6.html | 2 +- public/notes/7.html | 4 +- public/notes/8.html | 2 +- public/notes/9.html | 2 +- public/notes/message_sound.html | 4 +- public/notes/multigen.html | 2 +- public/script.js | 10 ++--- server.js | 78 +++++++++++++++++++++++---------- 19 files changed, 87 insertions(+), 57 deletions(-) diff --git a/package-lock.json b/package-lock.json index bb3a10080..5bae7726a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "TavernAI", - "version": "1.3.0", + "name": "sillytavern", + "version": "1.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "TavernAI", - "version": "1.3.0", + "name": "sillytavern", + "version": "1.4.1", "dependencies": { "@dqbd/tiktoken": "^1.0.2", "axios": "^1.3.4", @@ -34,7 +34,7 @@ "ws": "^8.13.0" }, "bin": { - "TavernAI": "server.js" + "sillytavern": "server.js" } }, "node_modules/@dqbd/tiktoken": { diff --git a/package.json b/package.json index 4f83820ae..df64ec6ef 100644 --- a/package.json +++ b/package.json @@ -30,10 +30,10 @@ "xml2js": "^0.5.0" } }, - "name": "TavernAI", - "version": "1.3.0", + "name": "sillytavern", + "version": "1.4.1", "bin": { - "TavernAI": "server.js" + "sillytavern": "server.js" }, "rules": { "no-path-concat": "off", diff --git a/public/notes/1.html b/public/notes/1.html index c9a85446f..3a9e84c70 100644 --- a/public/notes/1.html +++ b/public/notes/1.html @@ -1,6 +1,6 @@ - TavernAI - Note - Character Descriptions + Character Descriptions diff --git a/public/notes/10.html b/public/notes/10.html index 1f2415cdf..153041240 100644 --- a/public/notes/10.html +++ b/public/notes/10.html @@ -1,6 +1,6 @@ - TavernAI - Note - Import Chat + Import Chat @@ -12,7 +12,7 @@

Chat import

-

Import chats into TavernAI

+

Import chats into SillyTavern

To import Character.AI chats, use this tool: https://github.com/0x000011b/characterai-dumper.

diff --git a/public/notes/11.html b/public/notes/11.html index 9afb1abd0..9d8521cb9 100644 --- a/public/notes/11.html +++ b/public/notes/11.html @@ -1,6 +1,6 @@ - TavernAI - Note - Example Dialogues + Example Dialogues diff --git a/public/notes/12.html b/public/notes/12.html index 4669c6507..629abf287 100644 --- a/public/notes/12.html +++ b/public/notes/12.html @@ -1,6 +1,6 @@ - TavernAI - Note - Scenario + Scenario diff --git a/public/notes/13.html b/public/notes/13.html index e01ec2b19..b581f15e1 100644 --- a/public/notes/13.html +++ b/public/notes/13.html @@ -14,7 +14,7 @@

World Info

World Info enhances AI's understanding of the details in your world.

It functions like a dynamic dictionary that only inserts relevant information from World Info entries when keywords associated with the entries are present in the message text.

-

The TavernAI engine activates and seamlessly integrates the appropriate lore into the prompt, providing background information to the AI.

+

SillyTavern activates and seamlessly integrates the appropriate lore into the prompt, providing background information to the AI.

It is important to note that while World Info helps guide the AI towards your desired lore, it does not guarantee its appearance in the generated output messages.

Pro Tips

diff --git a/public/notes/13_1.html b/public/notes/13_1.html index 8285a8c23..2b522e9e6 100644 --- a/public/notes/13_1.html +++ b/public/notes/13_1.html @@ -15,7 +15,7 @@

Scan Depth

Defines how many messages in the chat history should be scanned for World Info keys.

-

If set to 1, then TavernAI only scans the message you send and the most recent reply.

+

If set to 1, then SillyTavern only scans the message you send and the most recent reply.

This stacks up to 10 message pairs it total.

diff --git a/public/notes/2.html b/public/notes/2.html index 726fa852c..96e9c14b0 100644 --- a/public/notes/2.html +++ b/public/notes/2.html @@ -1,6 +1,6 @@ - TavernAI - Note - Personality Summary + Personality Summary diff --git a/public/notes/3.html b/public/notes/3.html index f44eff9a4..7866b02ce 100644 --- a/public/notes/3.html +++ b/public/notes/3.html @@ -1,6 +1,6 @@ - TavernAI - Note - First Message + First Message diff --git a/public/notes/4.html b/public/notes/4.html index 8ee6352bb..95afd1097 100644 --- a/public/notes/4.html +++ b/public/notes/4.html @@ -1,7 +1,7 @@ - TavernAI - Note - KobolAI Settings + KoboldAI Settings @@ -17,7 +17,7 @@

KoboldAI Settings

Standard KoboldAI settings files are used here. To add your own settings, simply add the file .settings - in TavernAI\public\KoboldAI Settings + in SillyTavern\public\KoboldAI Settings

Temperature

Value from 0.1 to 2.0. Lower value - the answers are more logical, but less creative. Higher value - the @@ -34,7 +34,7 @@ The larger the parameter value, the longer the generation time takes.

Context size

How much will the AI remember. Context size also affects the speed of generation.

- Important: The setting of Context Size in TavernAI GUI overrides the setting for KoboldAI GUI + Important: The setting of Context Size in SillyTavern GUI overrides the setting for KoboldAI GUI

Advanced Settings

diff --git a/public/notes/6.html b/public/notes/6.html index 99f6443f3..2985e29b4 100644 --- a/public/notes/6.html +++ b/public/notes/6.html @@ -1,6 +1,6 @@ - TavernAI - Note - Novel AI API Key + NovelAI API Key diff --git a/public/notes/7.html b/public/notes/7.html index e5bab4e95..9f3bd288f 100644 --- a/public/notes/7.html +++ b/public/notes/7.html @@ -1,6 +1,6 @@ - TavernAI - Note - NovelAI Settings + NovelAI Settings @@ -13,7 +13,7 @@

NovelAI settings

- The files with the settings are here (TavernAI\public\NovelAI Settings).
+ The files with the settings are here (SillyTavern\public\NovelAI Settings).
You can also manually add your own settings files.

Temperature

diff --git a/public/notes/8.html b/public/notes/8.html index a97213a02..bc2af9c82 100644 --- a/public/notes/8.html +++ b/public/notes/8.html @@ -1,6 +1,6 @@ - TavernAI - Note - NovelAI Models + NovelAI Models diff --git a/public/notes/9.html b/public/notes/9.html index d1e855643..d3cfd9abc 100644 --- a/public/notes/9.html +++ b/public/notes/9.html @@ -1,6 +1,6 @@ - TavernAI - Note - Anchors + Anchors diff --git a/public/notes/message_sound.html b/public/notes/message_sound.html index a9d051585..e375db331 100644 --- a/public/notes/message_sound.html +++ b/public/notes/message_sound.html @@ -16,7 +16,7 @@

Message Sound

-

To play your own custom sound on receiving a new message from bot, replace the following MP3 file in your TavernAI folder:

+

To play your own custom sound on receiving a new message from bot, replace the following MP3 file in your SillyTavern folder:

public/sounds/message.mp3 @@ -24,7 +24,7 @@ Plays at 80% volume.

- If "Background Sound Only" option is enabled, the sound plays only if TavernAI window is unfocused. + If "Background Sound Only" option is enabled, the sound plays only if SillyTavern window is unfocused.

diff --git a/public/notes/multigen.html b/public/notes/multigen.html index b95502813..b5306b8af 100644 --- a/public/notes/multigen.html +++ b/public/notes/multigen.html @@ -16,7 +16,7 @@

Multigen

-

TavernAI tries to create faster and longer responses by chaining the generation using smaller batches.

+

SillyTavern tries to create faster and longer responses by chaining the generation using smaller batches.

Default settings:

First batch = 50 tokens

Next batches = 30 tokens

diff --git a/public/script.js b/public/script.js index 2bef5c553..73ad32b3d 100644 --- a/public/script.js +++ b/public/script.js @@ -158,15 +158,15 @@ export { } // API OBJECT FOR EXTERNAL WIRING -window["TavernAI"] = {}; +window["SillyTavern"] = {}; let converter = new showdown.Converter({ emoji: "true" }); const gpt3 = new GPT3BrowserTokenizer({ type: 'gpt3' }); /* let bg_menu_toggle = false; */ -const systemUserName = "TavernAI"; +const systemUserName = "SillyTavern"; let default_user_name = "You"; let name1 = default_user_name; -let name2 = "TavernAI"; +let name2 = "SillyTavern"; let chat = []; let safetychat = [ { @@ -248,7 +248,7 @@ const system_messages = { is_user: false, is_name: true, mes: [ - 'Welcome to TavernAI! In order to begin chatting:', + 'Welcome to SillyTavern! In order to begin chatting:', '
    ', '
  • Connect to one of the supported generation APIs
  • ', '
  • Create or pick a character from the list
  • ', @@ -3454,7 +3454,7 @@ function isHordeGenerationNotAllowed() { return false; } -window["TavernAI"].getContext = function () { +window["SillyTavern"].getContext = function () { return { chat: chat, characters: characters, diff --git a/server.js b/server.js index 7c56516ec..1adbf6286 100644 --- a/server.js +++ b/server.js @@ -183,8 +183,8 @@ app.use(function (req, res, next) { //Security //clientIp = req.connection.remoteAddress.split(':').pop(); if (whitelistMode === true && !whitelist.includes(clientIp)) { - console.log('Forbidden: Connection attempt from ' + clientIp + '. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.conf in root of TavernAI folder.\n'); - return res.status(403).send('Forbidden: Connection attempt from ' + clientIp + '. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.conf in root of TavernAI folder.'); + console.log('Forbidden: Connection attempt from ' + clientIp + '. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.conf in root of SillyTavern folder.\n'); + return res.status(403).send('Forbidden: Connection attempt from ' + clientIp + '. If you are attempting to connect, please add your IP address in whitelist or disable whitelist mode in config.conf in root of SillyTavern folder.'); } next(); }); @@ -368,7 +368,7 @@ app.post("/generate_textgenerationwebui", jsonParser, async function (request, r if (!!request.header('X-Response-Streaming')) { const fn_index = Number(request.header('X-Gradio-Streaming-Function')); let isStreamingStopped = false; - request.socket.on('close', function() { + request.socket.on('close', function () { isStreamingStopped = true; }); @@ -1598,18 +1598,18 @@ app.post("/importchat", urlencodedParser, function (request, response) { const errors = []; newChats.forEach(chat => fs.writeFile( - chatsPath + avatar_url + '/' + ch_name + ' - ' + humanizedISO8601DateTime() + ' imported.jsonl', - chat.map(JSON.stringify).join('\n'), - 'utf8', - (err) => err ?? errors.push(err) - ) + chatsPath + avatar_url + '/' + ch_name + ' - ' + humanizedISO8601DateTime() + ' imported.jsonl', + chat.map(JSON.stringify).join('\n'), + 'utf8', + (err) => err ?? errors.push(err) + ) ); if (0 < errors.length) { response.send('Errors occurred while writing character files. Errors: ' + JSON.stringify(errors)); } - response.send({res: true}); + response.send({ res: true }); } else { response.send({ error: true }); } @@ -1840,7 +1840,7 @@ app.post('/deletegroup', jsonParser, async (request, response) => { const POE_DEFAULT_BOT = 'a2'; -async function getPoeClient(token, useCache=false) { +async function getPoeClient(token, useCache = false) { let client = new poe.Client(false, useCache); await client.init(token); return client; @@ -1906,7 +1906,7 @@ app.post('/generate_poe', jsonParser, async (request, response) => { if (streaming) { let isStreamingStopped = false; - request.socket.on('close', function() { + request.socket.on('close', function () { isStreamingStopped = true; client.abortController.abort(); }); @@ -1972,17 +1972,17 @@ app.get('/get_sprites', jsonParser, function (request, response) { try { if (fs.existsSync(spritesPath) && fs.statSync(spritesPath).isDirectory()) { sprites = fs.readdirSync(spritesPath) - .filter(file => { - const mimeType = mime.lookup(file); - return mimeType && mimeType.startsWith('image/'); - }) - .map((file) => { - const pathToSprite = path.join(spritesPath, file); - return { - label: path.parse(pathToSprite).name.toLowerCase(), - path: `/characters/${name}/${file}`, - }; - }); + .filter(file => { + const mimeType = mime.lookup(file); + return mimeType && mimeType.startsWith('image/'); + }) + .map((file) => { + const pathToSprite = path.join(spritesPath, file); + return { + label: path.parse(pathToSprite).name.toLowerCase(), + path: `/characters/${name}/${file}`, + }; + }); } } catch (err) { @@ -2152,12 +2152,42 @@ app.post("/getstatus_openai", jsonParser, function (request, response_getstatus_ }); }); +// Shamelessly stolen from Agnai +app.post("/openai_usage", jsonParser, async function (_, response) { + if (!request.body) return response.sendStatus(400); + const key = request.body.key; + const api_url = new URL(request.body.reverse_proxy || api_openai).toString(); + + const headers = { + 'Content-Type': 'application/json', + Authorization: `Bearer ${key}`, + }; + + const date = new Date(); + date.setDate(1); + const start_date = date.toISOString().slice(0, 10); + + date.setMonth(date.getMonth() + 1); + const end_date = date.toISOString().slice(0, 10); + + try { + const res = await getAsync( + `${api_url}/dashboard/billing/usage?start_date=${start_date}&end_date=${end_date}`, + { headers }, + ); + return response.send(res); + } + catch { + return response.sendStatus(400); + } +}); + app.post("/generate_openai", jsonParser, function (request, response_generate_openai) { if (!request.body) return response_generate_openai.sendStatus(400); const api_url = new URL(request.body.reverse_proxy || api_openai).toString(); const controller = new AbortController(); - request.socket.on('close', function() { + request.socket.on('close', function () { controller.abort(); }); @@ -2330,7 +2360,7 @@ app.listen(server_port, (listen ? '0.0.0.0' : '127.0.0.1'), async function () { console.log('Launching...'); if (autorun) open('http://127.0.0.1:' + server_port); - console.log('TavernAI started: http://127.0.0.1:' + server_port); + console.log('SillyTavern started: http://127.0.0.1:' + server_port); if (fs.existsSync('public/characters/update.txt') && !is_colab) { convertStage1(); } From 371e1c6f2df332489ee47fc72a83faefc223bfa1 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 19:13:44 +0300 Subject: [PATCH 08/19] Fix --- public/scripts/extensions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/extensions.js b/public/scripts/extensions.js index 181ec9b1c..c097a33c7 100644 --- a/public/scripts/extensions.js +++ b/public/scripts/extensions.js @@ -29,7 +29,7 @@ const extension_settings = { let modules = []; let activeExtensions = new Set(); -const getContext = () => window['TavernAI'].getContext(); +const getContext = () => window['SillyTavern'].getContext(); const getApiUrl = () => extension_settings.apiUrl; const defaultRequestArgs = { method: 'GET', headers: { 'Bypass-Tunnel-Reminder': 'bypass' } }; let connectedToApi = false; From 2d67210da4fe56cdf385517ef0c7e918a5cc6713 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 19:21:07 +0300 Subject: [PATCH 09/19] Remove test job --- .github/workflows/npm-publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 6cdebafb6..be97e87e7 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -16,7 +16,6 @@ jobs: with: node-version: 16 - run: npm ci - - run: npm test publish-npm: needs: build From 36a1120251e5cc863baf13c0c36830f61a92474b Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 19:33:39 +0300 Subject: [PATCH 10/19] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index df64ec6ef..fa67a8ca4 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ }, "name": "sillytavern", "version": "1.4.1", - "bin": { - "sillytavern": "server.js" + "scripts": { + "sillytavern": "node server.js" }, "rules": { "no-path-concat": "off", From d41e639639d6edbc562a2c0f4c56fcbbe4949171 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 19:33:57 +0300 Subject: [PATCH 11/19] Update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa67a8ca4..1c7327825 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ } }, "name": "sillytavern", - "version": "1.4.1", + "version": "1.4.2", "scripts": { "sillytavern": "node server.js" }, From c72d61abfa035f3af02533be7afdd57d634e941b Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 19:43:25 +0300 Subject: [PATCH 12/19] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1c7327825..4320b46a9 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "name": "sillytavern", "version": "1.4.2", "scripts": { - "sillytavern": "node server.js" + "start": "node server.js" }, "rules": { "no-path-concat": "off", From 25456f58d2af745ee5688a86d10c8b0750af41dc Mon Sep 17 00:00:00 2001 From: Cohee Date: Sat, 22 Apr 2023 19:47:24 +0300 Subject: [PATCH 13/19] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4320b46a9..076468d41 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ } }, "name": "sillytavern", - "version": "1.4.2", + "version": "1.4.3", "scripts": { "start": "node server.js" }, From c6214086defbc9021f0e18e35b917af5c82c3b79 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 19:59:18 +0300 Subject: [PATCH 14/19] Update package.json --- package.json | 5 ++++- server.js | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 076468d41..c0957db3b 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,13 @@ } }, "name": "sillytavern", - "version": "1.4.3", + "version": "1.4.4", "scripts": { "start": "node server.js" }, + "bin": { + "sillytavern": "./server.js" + }, "rules": { "no-path-concat": "off", "no-var": "off" diff --git a/server.js b/server.js index 1adbf6286..73b78cc3a 100644 --- a/server.js +++ b/server.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node const express = require('express'); const compression = require('compression'); const app = express(); From ca8b921e30ebc6b009a27a5050037ecca25816eb Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 20:34:01 +0300 Subject: [PATCH 15/19] Adjustments for npm package --- package.json | 2 +- server.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c0957db3b..54df7c5af 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ } }, "name": "sillytavern", - "version": "1.4.4", + "version": "1.4.5", "scripts": { "start": "node server.js" }, diff --git a/server.js b/server.js index 73b78cc3a..b75faf232 100644 --- a/server.js +++ b/server.js @@ -30,10 +30,10 @@ const ExifReader = require('exifreader'); const exif = require('piexifjs'); const webp = require('webp-converter'); -const config = require(path.join(process.cwd(), './config.conf')); +const config = require(path.join(__dirname, './config.conf')); const server_port = process.env.SILLY_TAVERN_PORT || config.port; -const whitelistPath = path.join(process.cwd(), "./whitelist.txt"); +const whitelistPath = path.join(__dirname, "./whitelist.txt"); let whitelist = config.whitelist; if (fs.existsSync(whitelistPath)) { @@ -212,7 +212,7 @@ app.use((req, res, next) => { app.use(express.static(__dirname + "/public", { refresh: true })); app.use('/backgrounds', (req, res) => { - const filePath = decodeURIComponent(path.join(process.cwd(), 'public/backgrounds', req.url.replace(/%20/g, ' '))); + const filePath = decodeURIComponent(path.join(__dirname, 'public/backgrounds', req.url.replace(/%20/g, ' '))); fs.readFile(filePath, (err, data) => { if (err) { res.status(404).send('File not found'); @@ -224,7 +224,7 @@ app.use('/backgrounds', (req, res) => { }); app.use('/characters', (req, res) => { - const filePath = decodeURIComponent(path.join(process.cwd(), charactersPath, req.url.replace(/%20/g, ' '))); + const filePath = decodeURIComponent(path.join(__dirname, charactersPath, req.url.replace(/%20/g, ' '))); fs.readFile(filePath, (err, data) => { if (err) { res.status(404).send('File not found'); From 90132e5c524be20c6ead6e69bde4dbe12707ae4c Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 20:58:47 +0300 Subject: [PATCH 16/19] Add .npmignore --- package.json | 2 +- public/.npmignore | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 public/.npmignore diff --git a/package.json b/package.json index 54df7c5af..2577eeb3c 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ } }, "name": "sillytavern", - "version": "1.4.5", + "version": "1.4.6", "scripts": { "start": "node server.js" }, diff --git a/public/.npmignore b/public/.npmignore new file mode 100644 index 000000000..3311d99ac --- /dev/null +++ b/public/.npmignore @@ -0,0 +1,4 @@ +node_modules/ +/uploads/ +.DS_Store +/thumbnails From e2a77067b865f89891a1c0f3c578963ca4995b3b Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 21:05:43 +0300 Subject: [PATCH 17/19] Massive skill issue --- public/.npmignore => .npmignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename public/.npmignore => .npmignore (100%) diff --git a/public/.npmignore b/.npmignore similarity index 100% rename from public/.npmignore rename to .npmignore From 7dd59a26fa977a6c8b37eaa3f77dee35d799ba0d Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 21:06:49 +0300 Subject: [PATCH 18/19] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2577eeb3c..dfb9b2d45 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ } }, "name": "sillytavern", - "version": "1.4.6", + "version": "1.4.7", "scripts": { "start": "node server.js" }, From 21586ab139e4708104308aaabc3b17937d4dbd08 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Sat, 22 Apr 2023 21:49:50 +0300 Subject: [PATCH 19/19] Update relative paths --- package.json | 2 +- server.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index dfb9b2d45..953687ac1 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ } }, "name": "sillytavern", - "version": "1.4.7", + "version": "1.4.8", "scripts": { "start": "node server.js" }, diff --git a/server.js b/server.js index b75faf232..410385c63 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,9 @@ #!/usr/bin/env node + +// change all relative paths +const process = require('process') +process.chdir(__dirname) + const express = require('express'); const compression = require('compression'); const app = express();