-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/* | ||
.env | ||
.env | ||
config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import fs from "fs/promises" | ||
const PATH = "./configFile/config.json" | ||
let config = { | ||
"OPENAI_MODEL":"gpt-3.5-turbo", | ||
"MAX_TOKEN":1000, | ||
"ENABLE_DIRECT_MESSAGES":false, | ||
"CONVERSATION_START_PROMPT":"", | ||
"USE_EMBED":true | ||
} | ||
|
||
load() | ||
|
||
function get(key){ | ||
return config[key] | ||
} | ||
|
||
function set(key,value){ | ||
config[key] = value | ||
} | ||
|
||
function save(){ | ||
fs.writeFile(PATH,JSON.stringify(config)).then(()=>{ | ||
console.log("Config saved!") | ||
}).catch((err)=>{ | ||
console.error("Config save error! : ",err) | ||
}) | ||
} | ||
|
||
function load(){ | ||
|
||
fs.readFile(PATH).then((data)=>{ | ||
try{ | ||
data = data.toString() | ||
config = JSON.parse(data) | ||
console.log(new Date()+" --- Config loaded") | ||
}catch(e){ | ||
console.error("Config file corrupted! : ",e) | ||
} | ||
}).catch(()=>{ | ||
save() | ||
}) | ||
} | ||
|
||
export default { | ||
save, | ||
load, | ||
set, | ||
get | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"OPENAI_MODEL":"gpt-3.5-turbo", | ||
"MAX_TOKEN":1000, | ||
"ENABLE_DIRECT_MESSAGES":false, | ||
"CONVERSATION_START_PROMPT":"", | ||
"USE_EMBED":true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters