Replies: 1 comment
-
🤖 Hello, To allow the LLM agent to access the Here's how you can modify the async plan(
steps: AgentStep[],
inputs: ChainValues,
callbackManager?: CallbackManager
): Promise<AgentAction | AgentFinish> {
let log = "";
for (const { action, observation } of steps) {
log += `<tool>${action.tool}</tool><tool_input>${action.toolInput}</tool_input><observation>${observation}</observation>`;
}
let tools = "";
for (const tool of this.tools) {
tools += `${tool.name}: ${tool.description}\n`;
}
const _inputs = {
intermediate_steps: log,
tools,
question: inputs.input,
metadata: inputs.metadata, // Include metadata in the inputs
stop: ["</tool_input>", "</final_answer>"],
};
const response = await this.llmChain.call(_inputs, callbackManager);
return parseOutput(response[this.llmChain.outputKey]);
} Please note that this assumes You can find the As for how Here is the relevant code: const docs: Document[] = json.results.map((result: any) => {
const pageContent = this.includeRawContent
? result.raw_content
: result.content;
const metadata = {
title: result.title,
source: result.url,
...Object.fromEntries(
Object.entries(result).filter(
([k]) => !["content", "title", "url", "raw_content"].includes(k)
)
),
images: json.images,
};
return new Document({ pageContent, metadata });
}); You can find this code in the langchain/src/retrievers/metal.ts and langchain/src/retrievers/tavily_search_api.ts files. I hope this helps! Let me know if you have any other questions. Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following code:
The LLM agent doesn't get the
metadata
when using theevents
tool. The LLM agent needsmetadata
to do other queries using other tools.How to fix this?
Beta Was this translation helpful? Give feedback.
All reactions