You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⨯ TypeError: Cannot read properties of undefined (reading 'markdown')
at Array.map ()
at async addKnowledgeFormExternalSource (./src/app/_actions/dbi/addKnowledge.tsx:86:18)
Description
I am trying to build a rag app where i can pull in knowledge from youtube , website and webpages.
For the website. I am using firecrawl but is gives me this error.
I know the firecrawl api is working because I can see the activity logs from firecrawl logs.
System Info
pnpm 9.4.0
@langchain/community 0.2.33
The text was updated successfully, but these errors were encountered:
The TypeError: Cannot read properties of undefined (reading 'markdown') occurs because the firecrawlDocs array contains an element that is undefined or does not have the markdown property. This can happen if the response from the Firecrawl API does not include the expected data structure.
To fix this issue, you should add a check to ensure that each document in firecrawlDocs is defined and has the markdown property before attempting to access it. Here is the modified load method with the necessary checks:
publicasyncload(): Promise<DocumentInterface[]>{constparams: ConstructorParameters<typeofFirecrawlApp>[0]={apiKey: this.apiKey,};if(this.apiUrl!==undefined){params.apiUrl=this.apiUrl;}constapp=newFirecrawlApp(params);letfirecrawlDocs: FirecrawlDocument[];if(this.mode==="scrape"){constresponse=awaitapp.scrapeUrl(this.url,this.params);if(!response.success){thrownewError(`Firecrawl: Failed to scrape URL. Error: ${response.error}`);}firecrawlDocs=[response.dataasFirecrawlDocument];}elseif(this.mode==="crawl"){constresponse=awaitapp.crawlUrl(this.url,this.params,true);firecrawlDocs=responseasFirecrawlDocument[];}else{thrownewError(`Unrecognized mode '${this.mode}'. Expected one of 'crawl', 'scrape'.`);}returnfirecrawlDocs.filter((doc)=>doc&&doc.markdown!==undefined).map((doc)=>newDocument({pageContent: doc.markdown||"",metadata: doc.metadata||{},}));}
This code filters out any undefined documents or documents that do not have the markdown property before mapping them to Document instances [1].
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
⨯ TypeError: Cannot read properties of undefined (reading 'markdown')
at Array.map ()
at async addKnowledgeFormExternalSource (./src/app/_actions/dbi/addKnowledge.tsx:86:18)
Description
I am trying to build a rag app where i can pull in knowledge from youtube , website and webpages.
For the website. I am using firecrawl but is gives me this error.
I know the firecrawl api is working because I can see the activity logs from firecrawl logs.
System Info
pnpm 9.4.0
@langchain/community 0.2.33
The text was updated successfully, but these errors were encountered: