forked from ztjhz/BetterChatGPT
-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from animalnots/dev
v.1.7.0
- Loading branch information
Showing
12 changed files
with
5,215 additions
and
172 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 |
---|---|---|
|
@@ -25,4 +25,5 @@ dist-ssr | |
|
||
release/ | ||
|
||
.env | ||
.env | ||
models.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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
{ | ||
"notifications": { | ||
"invalidOpenAIDataFormat" : "Invalid openai data format", | ||
"invalidChatsDataFormat" : "Invalid chats data format", | ||
"invalidFormatForVersion" : "Invalid format for specified version", | ||
"successfulImport" : "Succesfully imported!", | ||
"unrecognisedDataFormat" : "Unrecognised data format. Supported formats are: BetterGPT export, OpenAI export, OpenAI Playground (JSON)" | ||
} | ||
} | ||
"invalidOpenAIDataFormat": "Invalid openai data format", | ||
"invalidChatsDataFormat": "Invalid chats data format", | ||
"invalidFormatForVersion": "Invalid format for specified version", | ||
"quotaExceeded": "Storage quota exceeded", | ||
"textSavedOnly": "Only text was saved", | ||
"successfulImport": "Successfully imported!", | ||
"nothingImported": "No data has been imported", | ||
"unrecognisedDataFormat": "Unrecognised data format. Supported formats are: BetterGPT export, OpenAI export, OpenAI Playground (JSON)", | ||
"chatsImported": "{{imported}} chats were imported out of {{total}}." | ||
}, | ||
"reduceMessagesSuccess": "{{count}} messages were reduced." | ||
} | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,43 @@ | ||
import fs from 'fs/promises'; | ||
|
||
// Function to recursively sort object keys | ||
function sortObjectKeys(obj) { | ||
if (Array.isArray(obj)) { | ||
return obj.map(sortObjectKeys); | ||
} else if (obj !== null && typeof obj === 'object') { | ||
return Object.keys(obj).sort().reduce((sortedObj, key) => { | ||
sortedObj[key] = sortObjectKeys(obj[key]); | ||
return sortedObj; | ||
}, {}); | ||
} | ||
return obj; | ||
} | ||
|
||
// Read the JSON file | ||
async function processJsonFile(inputFilePath, outputFilePath) { | ||
try { | ||
const data = await fs.readFile(inputFilePath, 'utf8'); | ||
|
||
// Parse the JSON data | ||
const jsonData = JSON.parse(data); | ||
|
||
// Sort the JSON data | ||
const sortedJsonData = sortObjectKeys(jsonData); | ||
|
||
// Convert the sorted JSON data back to a string | ||
const sortedJsonString = JSON.stringify(sortedJsonData, null, 2); | ||
|
||
// Write the sorted JSON data to a new file | ||
await fs.writeFile(outputFilePath, sortedJsonString, 'utf8'); | ||
console.log('File has been saved with sorted keys.'); | ||
} catch (err) { | ||
console.error('Error processing the file:', err); | ||
} | ||
} | ||
|
||
// Define file paths | ||
const inputFilePath = 'models.json'; | ||
const outputFilePath = 'public/models.json'; | ||
|
||
// Process the JSON file | ||
processJsonFile(inputFilePath, outputFilePath); |
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
Oops, something went wrong.