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:
commit
d2586a150b
@ -356,9 +356,17 @@ class DevChat {
|
|||||||
"response_tokens": 1,
|
"response_tokens": 1,
|
||||||
...parent? {"parent": parent} : {}
|
...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
|
// 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);
|
const {code, stdout, stderr} = await this.runCommand(args);
|
||||||
|
|
||||||
|
2
tools
2
tools
@ -1 +1 @@
|
|||||||
Subproject commit ab2abbdde678cf757707dc540b81efb465e7b3f5
|
Subproject commit b80f6402b6895d022a56598e9285baa39ad92670
|
Loading…
x
Reference in New Issue
Block a user