refactor(ChatAgent.js, handlers.js): stringify toolInput object in logs

The `toolInput` object was not being properly logged in the `ChatAgent.js` and `handlers.js` files. The `JSON.stringify()` method was added to properly log the object.
This commit is contained in:
Daniel Avila 2023-06-14 13:50:00 -04:00 committed by Danny Avila
parent 7541e9b3d3
commit dfec4bfe3a
2 changed files with 5 additions and 5 deletions

View file

@ -53,7 +53,7 @@ class ChatAgent {
if (actions[0]?.action && this.functionsAgent) {
actions = actions.map((step) => ({
log: `Action: ${step.action?.tool || ''}\nInput: ${step.action?.toolInput?.input || ''}\nObservation: ${step.observation}`
log: `Action: ${step.action?.tool || ''}\nInput: ${JSON.stringify(step.action?.toolInput) || ''}\nObservation: ${step.observation}`
}));
} else if (actions[0]?.action) {
actions = actions.map((step) => ({
@ -494,7 +494,7 @@ Only respond with your conversational reply to the following User Message:
};
// initialize agent
const initializer = this.options.agentOptions?.agent === 'functions' ? initializeFunctionsAgent : initializeCustomAgent;
const initializer = this.functionsAgent ? initializeFunctionsAgent : initializeCustomAgent;
this.executor = await initializer({
model,
signal,