Refactor logging in CLI and ModelDialog to improve clarity by commenting out verbose console outputs. Update function call result logging to include limited arguments and JSON stringification for better readability. Enhance error handling in read_file.js to check for file existence before processing.
This commit is contained in:
4
cli2.js
4
cli2.js
@@ -10,10 +10,10 @@ import chalk from 'chalk';
|
||||
const modelDialog = new ModelDialog();
|
||||
|
||||
modelDialog.on('outputUpdate', (output) => {
|
||||
console.log(chalk.blue('output event'),output);
|
||||
//console.log(chalk.blue('output event'),output);
|
||||
});
|
||||
modelDialog.on('reasoningUpdate', (output) => {
|
||||
console.log(chalk.blue('reasoning event'),output);
|
||||
//console.log(chalk.blue('reasoning event'),output);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -135,10 +135,7 @@ class ModelDialog {
|
||||
const limitedArgs = typeof toolCall.arguments === 'string'
|
||||
? (toolCall.arguments.length > 400 ? toolCall.arguments.slice(0, 400) + '...[truncated]' : toolCall.arguments)
|
||||
: toolCall.arguments;
|
||||
console.log(
|
||||
chalk.green('tool call:'),
|
||||
{ ...toolCall, arguments: limitedArgs }
|
||||
);
|
||||
|
||||
const tool = toolsByFile[toolCall.name];
|
||||
let args;
|
||||
try{
|
||||
@@ -153,7 +150,7 @@ class ModelDialog {
|
||||
continue;
|
||||
}
|
||||
const result = await tool.run(args);
|
||||
console.log(chalk.green('function call result:'),'<toolCall.name>',toolCall.name,'</toolCall.name>\n','<args>',args,'</args>\n','<result>',result,'</result>');
|
||||
console.log(chalk.green('function call result:'),'<toolCall.name>',toolCall.name,'</toolCall.name>\n','<args>',limitedArgs,'</args>\n','<result>',JSON.stringify(result).slice(0,100),'...</result>');
|
||||
this.messages.push({
|
||||
type: "function_call_output",
|
||||
call_id: toolCall.call_id,
|
||||
|
||||
@@ -6,7 +6,7 @@ but the format of the diff specification is unique to this task, so pay careful
|
||||
To use the 'apply_patch' command, you should pass a message of the following structure as "input":
|
||||
|
||||
*** Begin Patch
|
||||
[YOUR_PATH]
|
||||
[YOUR_PATCH]
|
||||
*** End Patch
|
||||
|
||||
Where [YOUR_PATCH] is the actual content of your patch, specified in the following V4A diff format.
|
||||
@@ -36,8 +36,17 @@ For instructions on [context_before] and [context_after]:
|
||||
+ [new_code]
|
||||
[3 lines of post-context]
|
||||
|
||||
Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code. An example of a message that you might pass as "input" to this function, in order to apply a patch, is shown below.
|
||||
`;
|
||||
Note, then, that we do not use line numbers in this diff format, as the context is enough to uniquely identify code.
|
||||
|
||||
Complese Example:
|
||||
*** Begin Patch
|
||||
*** Add File: /test.js
|
||||
+ function method() {
|
||||
+ console.log("Hello, world!");
|
||||
+ }
|
||||
*** End Patch
|
||||
`;
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Domain objects
|
||||
// --------------------------------------------------------------------------- //
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createReadStream } from "node:fs";
|
||||
import { createInterface } from "node:readline";
|
||||
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const virtual_chroot = '/workspaces/aiTools/root';
|
||||
@@ -30,7 +30,10 @@ export async function run(args) {
|
||||
// Normalize linesToRead (1-400, with 0 or >400 meaning 400)
|
||||
const maxLines = (linesToRead <= 0 || linesToRead > 400) ? 400 : linesToRead;
|
||||
|
||||
// return 'FILE DOES NOT EXIST'
|
||||
// check if the file exists
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
return `read_file error: File does not exist`;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -53,7 +56,7 @@ export async function run(args) {
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join('\n');
|
||||
return 'Filecontent: ´´´'+lines.join('')+'´´´';
|
||||
} catch (error) {
|
||||
return `read_file error: ${error.message}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user