agsamantha/node_modules/langchain/dist/agents/format_scratchpad/log.js

13 lines
567 B
JavaScript
Raw Normal View History

2024-10-02 15:15:21 -05:00
/**
* Construct the scratchpad that lets the agent continue its thought process.
* @param intermediateSteps
* @param observationPrefix
* @param llmPrefix
* @returns a string with the formatted observations and agent logs
*/
export function formatLogToString(intermediateSteps, observationPrefix = "Observation: ", llmPrefix = "Thought: ") {
const formattedSteps = intermediateSteps.reduce((thoughts, { action, observation }) => thoughts +
[action.log, `\n${observationPrefix}${observation}`, llmPrefix].join("\n"), "");
return formattedSteps;
}