mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +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',
|
'If your view URL looks like: https://airtable.com/app11RobdGoX0YNsC/tblJdmvbrgizbYICO/viw9UrP77Id0CE4ee, viw9UrP77Id0CE4ee is the view id',
|
||||||
optional: true
|
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',
|
label: 'Return All',
|
||||||
name: 'returnAll',
|
name: 'returnAll',
|
||||||
@@ -93,6 +103,7 @@ class Airtable_DocumentLoaders implements INode {
|
|||||||
const baseId = nodeData.inputs?.baseId as string
|
const baseId = nodeData.inputs?.baseId as string
|
||||||
const tableId = nodeData.inputs?.tableId as string
|
const tableId = nodeData.inputs?.tableId as string
|
||||||
const viewId = nodeData.inputs?.viewId as string
|
const viewId = nodeData.inputs?.viewId as string
|
||||||
|
const excludeFieldIds = nodeData.inputs?.excludeFieldIds as string
|
||||||
const returnAll = nodeData.inputs?.returnAll as boolean
|
const returnAll = nodeData.inputs?.returnAll as boolean
|
||||||
const limit = nodeData.inputs?.limit as string
|
const limit = nodeData.inputs?.limit as string
|
||||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||||
@@ -105,6 +116,7 @@ class Airtable_DocumentLoaders implements INode {
|
|||||||
baseId,
|
baseId,
|
||||||
tableId,
|
tableId,
|
||||||
viewId,
|
viewId,
|
||||||
|
excludeFieldIds: excludeFieldIds ? excludeFieldIds.split(',').map(id => id.trim()) : [],
|
||||||
returnAll,
|
returnAll,
|
||||||
accessToken,
|
accessToken,
|
||||||
limit: limit ? parseInt(limit, 10) : 100
|
limit: limit ? parseInt(limit, 10) : 100
|
||||||
@@ -145,6 +157,7 @@ interface AirtableLoaderParams {
|
|||||||
tableId: string
|
tableId: string
|
||||||
accessToken: string
|
accessToken: string
|
||||||
viewId?: string
|
viewId?: string
|
||||||
|
excludeFieldIds?: string[]
|
||||||
limit?: number
|
limit?: number
|
||||||
returnAll?: boolean
|
returnAll?: boolean
|
||||||
}
|
}
|
||||||
@@ -167,17 +180,20 @@ class AirtableLoader extends BaseDocumentLoader {
|
|||||||
|
|
||||||
public readonly viewId?: string
|
public readonly viewId?: string
|
||||||
|
|
||||||
|
public readonly excludeFieldIds: string[]
|
||||||
|
|
||||||
public readonly accessToken: string
|
public readonly accessToken: string
|
||||||
|
|
||||||
public readonly limit: number
|
public readonly limit: number
|
||||||
|
|
||||||
public readonly returnAll: boolean
|
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()
|
super()
|
||||||
this.baseId = baseId
|
this.baseId = baseId
|
||||||
this.tableId = tableId
|
this.tableId = tableId
|
||||||
this.viewId = viewId
|
this.viewId = viewId
|
||||||
|
this.excludeFieldIds = excludeFieldIds
|
||||||
this.accessToken = accessToken
|
this.accessToken = accessToken
|
||||||
this.limit = limit
|
this.limit = limit
|
||||||
this.returnAll = returnAll
|
this.returnAll = returnAll
|
||||||
@@ -207,10 +223,16 @@ class AirtableLoader extends BaseDocumentLoader {
|
|||||||
private createDocumentFromPage(page: AirtableLoaderPage): Document {
|
private createDocumentFromPage(page: AirtableLoaderPage): Document {
|
||||||
// Generate the URL
|
// Generate the URL
|
||||||
const pageUrl = `https://api.airtable.com/v0/${this.baseId}/${this.tableId}/${page.id}`
|
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 a langchain document
|
||||||
return new Document({
|
return new Document({
|
||||||
pageContent: JSON.stringify(page.fields, null, 2),
|
pageContent: JSON.stringify(fields, null, 2),
|
||||||
metadata: {
|
metadata: {
|
||||||
url: pageUrl
|
url: pageUrl
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user