mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
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:
parent
7541e9b3d3
commit
dfec4bfe3a
2 changed files with 5 additions and 5 deletions
|
|
@ -53,7 +53,7 @@ class ChatAgent {
|
||||||
|
|
||||||
if (actions[0]?.action && this.functionsAgent) {
|
if (actions[0]?.action && this.functionsAgent) {
|
||||||
actions = actions.map((step) => ({
|
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) {
|
} else if (actions[0]?.action) {
|
||||||
actions = actions.map((step) => ({
|
actions = actions.map((step) => ({
|
||||||
|
|
@ -494,7 +494,7 @@ Only respond with your conversational reply to the following User Message:
|
||||||
};
|
};
|
||||||
|
|
||||||
// initialize agent
|
// initialize agent
|
||||||
const initializer = this.options.agentOptions?.agent === 'functions' ? initializeFunctionsAgent : initializeCustomAgent;
|
const initializer = this.functionsAgent ? initializeFunctionsAgent : initializeCustomAgent;
|
||||||
this.executor = await initializer({
|
this.executor = await initializer({
|
||||||
model,
|
model,
|
||||||
signal,
|
signal,
|
||||||
|
|
|
||||||
|
|
@ -99,14 +99,14 @@ function formatSteps(steps) {
|
||||||
|
|
||||||
for (let i = 0; i < steps.length; i++) {
|
for (let i = 0; i < steps.length; i++) {
|
||||||
const step = steps[i];
|
const step = steps[i];
|
||||||
const actionInput = step.action.toolInput;
|
const actionInput = getString(step.action.toolInput);
|
||||||
const observation = step.observation;
|
const observation = step.observation;
|
||||||
|
|
||||||
if (actionInput === 'N/A' || observation?.trim()?.length === 0) {
|
if (actionInput === 'N/A' || observation?.trim()?.length === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
output += `Input: ${actionInput?.input || actionInput}\nOutput: ${getString(observation)}`;
|
output += `Input: ${actionInput}\nOutput: ${getString(observation)}`;
|
||||||
|
|
||||||
if (steps.length > 1 && i !== steps.length - 1) {
|
if (steps.length > 1 && i !== steps.length - 1) {
|
||||||
output += '\n---\n';
|
output += '\n---\n';
|
||||||
|
|
@ -131,7 +131,7 @@ function formatAction(action) {
|
||||||
|
|
||||||
const formattedAction = {
|
const formattedAction = {
|
||||||
plugin: capitalizeWords(action.tool) || action.tool,
|
plugin: capitalizeWords(action.tool) || action.tool,
|
||||||
input: action.toolInput?.input || action.toolInput,
|
input: getString(action.toolInput),
|
||||||
thought: action.log.includes('Thought: ')
|
thought: action.log.includes('Thought: ')
|
||||||
? action.log.split('\n')[0].replace('Thought: ', '')
|
? action.log.split('\n')[0].replace('Thought: ', '')
|
||||||
: action.log.split('\n')[0]
|
: action.log.split('\n')[0]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue