Skip to content

Commit

Permalink
Syntex error correction in Azureblob, Airtable etc
Browse files Browse the repository at this point in the history
  • Loading branch information
vgees committed Oct 23, 2023
1 parent 4b382af commit a5644d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/components/nodes/documentloaders/API/APILoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ class ApiLoader extends BaseDocumentLoader {
module.exports = {
nodeClass: API_DocumentLoaders
}
*/
*/
15 changes: 13 additions & 2 deletions packages/components/nodes/documentloaders/Airtable/Airtable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{/*
/*
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter'
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
Expand Down Expand Up @@ -228,5 +228,16 @@ class AirtableLoader extends BaseDocumentLoader {
module.exports = {
nodeClass: Airtable_DocumentLoaders
class Airtable_DocumentLoaders extends DocumentLoader {
public async load(): Promise<Document[]> {
const airtableLoader = new AirtableLoader({
baseId: this.getParameter('baseId'),
tableId: this.getParameter('tableId'),
accessToken: this.getParameter('accessToken'),
limit: this.getParameter('limit'),
returnAll: this.getParameter('returnAll')
})
return airtableLoader.load()
}
}
*/}
*/

Check failure on line 243 in packages/components/nodes/documentloaders/Airtable/Airtable.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Insert `⏎`
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
}
module.exports = { nodeClass: ApifyWebsiteContentCrawler_DocumentLoaders }
*/
*/
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class AzureBlobStorage_DocumentLoaders implements INode {
{
label: 'NarrativeText Only',
name: 'narrativeTextOnly',
description:
'Only load documents with NarrativeText metadata from Unstructured',
description:'Only load documents with NarrativeText metadata from Unstructured',

Check failure on line 52 in packages/components/nodes/documentloaders/AzureBlobStorage/AzureBlobStorage.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Insert `·`
type: 'boolean',
optional: true,
additionalParams: true
Expand All @@ -71,8 +70,8 @@ class AzureBlobStorage_DocumentLoaders implements INode {
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
const metadata = nodeData.inputs?.metadata1
const narrativeTextOnly = nodeData.inputs?.narrativeTextOnly as boolean
try{
if (constring && contname && Blobname1){
try {
if (constring && contname && Blobname1) {
const loader = new AzureBlobStorageFileLoader({
azureConfig: {
connectionString: constring,
Expand All @@ -85,7 +84,7 @@ class AzureBlobStorage_DocumentLoaders implements INode {
}
})
if (textSplitter) {
try{
try {
const docs = await loader.loadAndSplit(textSplitter)
if (metadata) {
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
Expand All @@ -95,21 +94,20 @@ class AzureBlobStorage_DocumentLoaders implements INode {
metadata: {
...doc.metadata,
...parsedMetadata
}
}

Check failure on line 97 in packages/components/nodes/documentloaders/AzureBlobStorage/AzureBlobStorage.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Delete `·`
}

Check failure on line 98 in packages/components/nodes/documentloaders/AzureBlobStorage/AzureBlobStorage.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Delete `·`
})
return narrativeTextOnly ? finaldocs.filter((doc) => doc.metadata.category === 'NarrativeText') : finaldocs
}
return narrativeTextOnly ? docs.filter((doc) => doc.metadata.category === 'NarrativeText') : docs
}
catch(e:any){
} catch(e:any){

Check failure on line 103 in packages/components/nodes/documentloaders/AzureBlobStorage/AzureBlobStorage.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Replace `(e:any)` with `·(e:·any)·`
throw new Error(`${e}`)
}

Check failure on line 106 in packages/components/nodes/documentloaders/AzureBlobStorage/AzureBlobStorage.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Replace `········⏎········⏎························}⏎················else` with `}·else·`

}
else{
try{
try {
const docs = await loader.load()
if (metadata) {
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
Expand All @@ -125,19 +123,16 @@ class AzureBlobStorage_DocumentLoaders implements INode {
return narrativeTextOnly ? finaldocs.filter((doc) => doc.metadata.category === 'NarrativeText') : finaldocs
}
return narrativeTextOnly ? docs.filter((doc) => doc.metadata.category === 'NarrativeText') : docs
}
catch(e:any){
} catch(e:any){

Check failure on line 126 in packages/components/nodes/documentloaders/AzureBlobStorage/AzureBlobStorage.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Replace `(e:any)` with `·(e:·any)·`
throw new Error(`${e}`)
}
}
} else {
console.error('Some required properties are undefined.')
}
}

Check failure on line 133 in packages/components/nodes/documentloaders/AzureBlobStorage/AzureBlobStorage.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 18.15.0)

Replace `⏎········catch·(error)·{` with `·catch·(error)·{⏎···········`
catch (error) {
console.error('An error occurred:', error)
catch (error) { console.error('An error occurred:', error)
throw error

}
}
}
Expand Down

0 comments on commit a5644d4

Please sign in to comment.