feat(metaSearchAgent): handle `undefined` content for YT. search
This commit is contained in:
parent
2c5ca94b3c
commit
f30a61c4aa
|
@ -211,7 +211,11 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||||
const documents = res.results.map(
|
const documents = res.results.map(
|
||||||
(result) =>
|
(result) =>
|
||||||
new Document({
|
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: {
|
metadata: {
|
||||||
title: result.title,
|
title: result.title,
|
||||||
url: result.url,
|
url: result.url,
|
||||||
|
@ -414,7 +418,10 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
||||||
|
|
||||||
private processDocs(docs: Document[]) {
|
private processDocs(docs: Document[]) {
|
||||||
return docs
|
return docs
|
||||||
.map((_, index) => `${index + 1}. ${docs[index].pageContent}`)
|
.map(
|
||||||
|
(_, index) =>
|
||||||
|
`${index + 1}. ${docs[index].metadata.title} ${docs[index].pageContent}`,
|
||||||
|
)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue