feat(metaSearchAgent): handle `undefined` content for YT. search

This commit is contained in:
ItzCrazyKns 2024-12-16 18:24:01 +05:30
parent 2c5ca94b3c
commit f30a61c4aa
1 changed files with 9 additions and 2 deletions

View File

@ -211,7 +211,11 @@ class MetaSearchAgent implements MetaSearchAgentType {
const documents = res.results.map(
(result) =>
new Document({
pageContent: result.content,
pageContent:
result.content ||
this.config.activeEngines.includes('youtube')
? result.title
: '' /* Todo: Implement transcript grabbing using Youtubei (source: https://www.npmjs.com/package/youtubei) */,
metadata: {
title: result.title,
url: result.url,
@ -414,7 +418,10 @@ class MetaSearchAgent implements MetaSearchAgentType {
private processDocs(docs: Document[]) {
return docs
.map((_, index) => `${index + 1}. ${docs[index].pageContent}`)
.map(
(_, index) =>
`${index + 1}. ${docs[index].metadata.title} ${docs[index].pageContent}`,
)
.join('\n');
}