forked from ggerganov/llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a typescript jsonrepair to fix json. This is a temp solution, ide…
…ally the jsonrepair code should be written in c++
- Loading branch information
Showing
3 changed files
with
110 additions
and
2 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,3 +1,6 @@ | ||
*package-lock.json | ||
*package.json | ||
*node_modules | ||
*.ipynb | ||
*.o | ||
*.a | ||
|
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,24 @@ | ||
const fs = require('fs'); | ||
const { jsonrepair } = require('jsonrepair'); | ||
|
||
// This script processes command-line arguments | ||
const filename = process.argv[2]; // Skip the first two elements | ||
// Simple processing: join arguments into a stri | ||
|
||
function processFile(filePath) { | ||
try { | ||
const data = fs.readFileSync(filePath, { encoding: 'utf8' }); | ||
const repairData = jsonrepair(data); | ||
console.log(repairData); | ||
fs.unlinkSync(filePath); | ||
return repairData; | ||
} catch (error) { | ||
console.error('Error reading file:', error); | ||
return ''; | ||
} | ||
} | ||
|
||
|
||
processFile(filename); | ||
// Output the result | ||
|