mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-27 11:00:34 +03:00
Added support to exclude specific Airtable Field Ids
This commit is contained in:
@@ -64,6 +64,16 @@ class Airtable_DocumentLoaders implements INode {
|
||||
'If your view URL looks like: https://airtable.com/app11RobdGoX0YNsC/tblJdmvbrgizbYICO/viw9UrP77Id0CE4ee, viw9UrP77Id0CE4ee is the view id',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Exclude Field Ids',
|
||||
name: 'excludeFieldIds',
|
||||
type: 'string',
|
||||
placeholder: 'fld1u0qUz0SoOQ9Gg, fldAMOvPfwxr12VrK',
|
||||
optional: true,
|
||||
additionalParams: true,
|
||||
description:
|
||||
'Comma-separated list of field ids to exclude'
|
||||
},
|
||||
{
|
||||
label: 'Return All',
|
||||
name: 'returnAll',
|
||||
@@ -93,6 +103,7 @@ class Airtable_DocumentLoaders implements INode {
|
||||
const baseId = nodeData.inputs?.baseId as string
|
||||
const tableId = nodeData.inputs?.tableId as string
|
||||
const viewId = nodeData.inputs?.viewId as string
|
||||
const excludeFieldIds = nodeData.inputs?.excludeFieldIds as string
|
||||
const returnAll = nodeData.inputs?.returnAll as boolean
|
||||
const limit = nodeData.inputs?.limit as string
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
@@ -105,6 +116,7 @@ class Airtable_DocumentLoaders implements INode {
|
||||
baseId,
|
||||
tableId,
|
||||
viewId,
|
||||
excludeFieldIds: excludeFieldIds ? excludeFieldIds.split(',').map(id => id.trim()) : [],
|
||||
returnAll,
|
||||
accessToken,
|
||||
limit: limit ? parseInt(limit, 10) : 100
|
||||
@@ -145,6 +157,7 @@ interface AirtableLoaderParams {
|
||||
tableId: string
|
||||
accessToken: string
|
||||
viewId?: string
|
||||
excludeFieldIds?: string[]
|
||||
limit?: number
|
||||
returnAll?: boolean
|
||||
}
|
||||
@@ -167,17 +180,20 @@ class AirtableLoader extends BaseDocumentLoader {
|
||||
|
||||
public readonly viewId?: string
|
||||
|
||||
public readonly excludeFieldIds: string[]
|
||||
|
||||
public readonly accessToken: string
|
||||
|
||||
public readonly limit: number
|
||||
|
||||
public readonly returnAll: boolean
|
||||
|
||||
constructor({ baseId, tableId, viewId, accessToken, limit = 100, returnAll = false }: AirtableLoaderParams) {
|
||||
constructor({ baseId, tableId, viewId, excludeFieldIds = [], accessToken, limit = 100, returnAll = false }: AirtableLoaderParams) {
|
||||
super()
|
||||
this.baseId = baseId
|
||||
this.tableId = tableId
|
||||
this.viewId = viewId
|
||||
this.excludeFieldIds = excludeFieldIds
|
||||
this.accessToken = accessToken
|
||||
this.limit = limit
|
||||
this.returnAll = returnAll
|
||||
@@ -207,10 +223,16 @@ class AirtableLoader extends BaseDocumentLoader {
|
||||
private createDocumentFromPage(page: AirtableLoaderPage): Document {
|
||||
// Generate the URL
|
||||
const pageUrl = `https://api.airtable.com/v0/${this.baseId}/${this.tableId}/${page.id}`
|
||||
const fields = { ...page.fields };
|
||||
|
||||
// Exclude any specified fields
|
||||
this.excludeFieldIds.forEach(id => {
|
||||
delete fields[id];
|
||||
});
|
||||
|
||||
// Return a langchain document
|
||||
return new Document({
|
||||
pageContent: JSON.stringify(page.fields, null, 2),
|
||||
pageContent: JSON.stringify(fields, null, 2),
|
||||
metadata: {
|
||||
url: pageUrl
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user