Refactor CLI output formatting in cli.js to enhance readability by adding line breaks. Comment out verbose logging for OpenAI calls and error handling to reduce console clutter. Update patch_files.js description for clarity on functionality.
This commit is contained in:
15
cli.js
15
cli.js
@@ -14,7 +14,7 @@ function renderUsage(usage) {
|
|||||||
const inputTokens = usage.input_tokens - usage.input_tokens_details.cached_tokens;
|
const inputTokens = usage.input_tokens - usage.input_tokens_details.cached_tokens;
|
||||||
const cacheTokens = usage.input_tokens_details.cached_tokens;
|
const cacheTokens = usage.input_tokens_details.cached_tokens;
|
||||||
const outputToken = usage.output_tokens;
|
const outputToken = usage.output_tokens;
|
||||||
console.log(' Cost', inputTokens, cacheTokens, outputToken);
|
console.log('\nCost', inputTokens, cacheTokens, outputToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
function printIndented(indentNum, ...args) {
|
function printIndented(indentNum, ...args) {
|
||||||
@@ -48,6 +48,7 @@ term.on('key', (name) => {
|
|||||||
async function askUserForInput() {
|
async function askUserForInput() {
|
||||||
term.cyan("Enter your request: ");
|
term.cyan("Enter your request: ");
|
||||||
const input = await term.inputField({ mouse: false }).promise;
|
const input = await term.inputField({ mouse: false }).promise;
|
||||||
|
console.log('\n');
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,10 +104,10 @@ websearch - eine Google Suche machen mit Schlüsselwörtern`
|
|||||||
}
|
}
|
||||||
if(previousResponseId) call.previous_response_id = previousResponseId;
|
if(previousResponseId) call.previous_response_id = previousResponseId;
|
||||||
|
|
||||||
console.log("\n\n\n\n\n------NEW OPENAI CALL-"+input.length+"-------------"
|
//console.log("\n\n\n\n\n------NEW OPENAI CALL-"+input.length+"-------------"
|
||||||
,"\n",counter++,"\n",'----INPUT-----------------'
|
// ,"\n",counter++,"\n",'----INPUT-----------------'
|
||||||
,"\n",call.input.map(i => JSON.stringify(i)),"\n",
|
// ,"\n",call.input.map(i => JSON.stringify(i)),"\n",
|
||||||
'--------CALL-------------',call,"\n");
|
// '--------CALL-------------',call,"\n");
|
||||||
const stream = await openai.responses.stream(call);
|
const stream = await openai.responses.stream(call);
|
||||||
stream.on('response.created', (event) => {
|
stream.on('response.created', (event) => {
|
||||||
previousResponseId = event.response.id;
|
previousResponseId = event.response.id;
|
||||||
@@ -143,9 +144,9 @@ websearch - eine Google Suche machen mit Schlüsselwörtern`
|
|||||||
try {
|
try {
|
||||||
args = JSON.parse(event.item.arguments);
|
args = JSON.parse(event.item.arguments);
|
||||||
} catch (e){
|
} catch (e){
|
||||||
console.error('Error parsing arguments:', e, event.item.arguments);
|
// console.error('Error parsing arguments:', e, event.item.arguments);
|
||||||
}
|
}
|
||||||
console.log(' function call:', id, name);
|
//console.log(' function call:', id, name);
|
||||||
functionCalls.push({ id, name, args, promise: toolsByFile[name].run(args) });
|
functionCalls.push({ id, name, args, promise: toolsByFile[name].run(args) });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -786,7 +786,7 @@ function remove_file(filepath) {
|
|||||||
export default {
|
export default {
|
||||||
type: "function",
|
type: "function",
|
||||||
name: "patch_files",
|
name: "patch_files",
|
||||||
description: "Apply a unified diff patch " + desc,
|
description: "Generic Text File Editor create,edit,delete - Apply a unified diff patch " + desc,
|
||||||
parameters: {
|
parameters: {
|
||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
|
|||||||
27
tools/wget.js
Normal file
27
tools/wget.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
module.exports = async function wget(params) {
|
||||||
|
const { url } = params;
|
||||||
|
if (!url) throw new Error('missing url');
|
||||||
|
const res = await fetch(url);
|
||||||
|
const buffer = await res.buffer();
|
||||||
|
const filename = url.split('/').filter(Boolean).pop() || 'index.html';
|
||||||
|
const content = buffer.slice(0, 500).toString('utf8');
|
||||||
|
return { filename, content };
|
||||||
|
};
|
||||||
|
|
||||||
|
// metadata for the tool runner
|
||||||
|
module.exports.meta = {
|
||||||
|
type: 'function',
|
||||||
|
name: 'wget',
|
||||||
|
description: 'Download URL to filesystem',
|
||||||
|
strict: true,
|
||||||
|
parameters: {
|
||||||
|
type: 'object',
|
||||||
|
required: ['url'],
|
||||||
|
additionalProperties: false,
|
||||||
|
properties: {
|
||||||
|
url: { type: 'string', description: 'The url to get.' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user