Merge pull request #539 from devchat-ai/fix_log_insert_fail

Refactor DevChat log insertion for improved large value handling
This commit is contained in:
boob.yang 2024-05-27 14:13:19 +08:00 committed by GitHub
commit d2586a150b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -356,9 +356,17 @@ class DevChat {
"response_tokens": 1,
...parent? {"parent": parent} : {}
};
const insertValue = JSON.stringify(logData);
let insertValueOrFile = insertValue;
if (insertValue.length > 4 * 1024) {
const tempDir = os.tmpdir();
const tempFile = path.join(tempDir, 'devchat_log_insert.json');
await fs.promises.writeFile(tempFile, insertValue);
insertValueOrFile = tempFile;
}
// build args for log insert
const args = ["-m", "devchat", "log", "--insert", JSON.stringify(logData)];
const args = ["-m", "devchat", "log", "--insert", insertValueOrFile];
const {code, stdout, stderr} = await this.runCommand(args);

2
tools

@ -1 +1 @@
Subproject commit ab2abbdde678cf757707dc540b81efb465e7b3f5
Subproject commit b80f6402b6895d022a56598e9285baa39ad92670