From 7b1068b80ba65e21a281649bdb4322ebc59895c9 Mon Sep 17 00:00:00 2001 From: ChatBookAI Date: Sun, 2 Jun 2024 13:10:39 +0800 Subject: [PATCH] enableDir --- express/main.js | 10 +++++++++- express/src/app.js | 3 ++- express/src/utils/lancedb.js | 2 +- express/src/utils/llms.js | 2 +- express/src/utils/user.js | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/express/main.js b/express/main.js index c39dfa9..724828c 100644 --- a/express/main.js +++ b/express/main.js @@ -1,9 +1,12 @@ import { app, BrowserWindow, Menu, ipcMain, dialog } from 'electron'; import isDev from 'electron-is-dev' import settings from 'electron-settings'; +import os from 'os'; import { server, getPort } from './src/app.js'; import { initChatBookSetting, ChatBookDbInit } from './src/utils/db.js'; +import { enableDir } from './src/utils/utils.js'; + const PORT = getPort(); @@ -21,7 +24,12 @@ function createMainWindow() { }); //Start Setting Page - mainWindow.loadFile('src/settings/index.html'); + //mainWindow.loadFile('src/settings/index.html'); + const userHomeDir = os.homedir() + enableDir(userHomeDir + '/ChatBookData') + initChatBookSetting({NodeStorageDirectory: userHomeDir + '/ChatBookData'}) + ChatBookDbInit(); + mainWindow.loadURL('http://localhost:' + PORT); ipcMain.on('start-chatbook', async (event, data) => { ChatBookSetting = await settings.get('chatbook'); diff --git a/express/src/app.js b/express/src/app.js index 81a15fe..5daa5c8 100644 --- a/express/src/app.js +++ b/express/src/app.js @@ -25,6 +25,7 @@ const __dirname = dirname(__filename); //import getimgRouter from './router/Backup/getimg' //import seaartRouter from './router/seaart' + //Start Express Server const app = express(); const port = 1988; @@ -32,7 +33,7 @@ app.use(cors()); app.use(bodyParser.json()); dotenv.config(); -console.log("process.env: ", process.env); +// console.log("process.env: ", process.env); //Initial Database and Folder diff --git a/express/src/utils/lancedb.js b/express/src/utils/lancedb.js index 944d3fd..beec1b3 100644 --- a/express/src/utils/lancedb.js +++ b/express/src/utils/lancedb.js @@ -12,7 +12,7 @@ import { DataDir } from './const.js'; import dotenv from 'dotenv'; dotenv.config(); -console.log("process.env: ", process.env); +// console.log("process.env: ", process.env); const OPENAI_API_KEY = process.env.OPENAI_API_KEY ?? '' diff --git a/express/src/utils/llms.js b/express/src/utils/llms.js index 8c3b771..b007387 100644 --- a/express/src/utils/llms.js +++ b/express/src/utils/llms.js @@ -51,7 +51,7 @@ import { createEmbeddingsFromList, getWebsiteUrlContext, formatMessage, rephrase import dotenv from 'dotenv'; dotenv.config(); -console.log("process.env: ", process.env); +// console.log("process.env: ", process.env); const OPENAI_BASE_URL = process.env.OPENAI_BASE_URL ?? "https://openkey.cloud/v1"; const OPENAI_API_KEY = process.env.OPENAI_API_KEY ?? "sk-Bm6p9ej7BIZU3F5tFe2e1f899097474aBeA3E7E034A723B8"; diff --git a/express/src/utils/user.js b/express/src/utils/user.js index e904b1c..cae3e97 100644 --- a/express/src/utils/user.js +++ b/express/src/utils/user.js @@ -8,7 +8,7 @@ dotenv.config(); - console.log("process.env: ", process.env); + // console.log("process.env: ", process.env); import { ChatBookDbPool } from './db.js'