Skip to content

Commit

Permalink
Merge branch 'main' into CHORE/Upgrade-Analytic-Dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryHengZJ authored Jan 4, 2024
2 parents c0d311c + 247f1e9 commit 1d1c6cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions packages/components/nodes/documentloaders/Airtable/Airtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Airtable_DocumentLoaders implements INode {
constructor() {
this.label = 'Airtable'
this.name = 'airtable'
this.version = 1.0
this.version = 2.0
this.type = 'Document'
this.icon = 'airtable.svg'
this.category = 'Document Loaders'
Expand Down Expand Up @@ -55,6 +55,15 @@ class Airtable_DocumentLoaders implements INode {
description:
'If your table URL looks like: https://airtable.com/app11RobdGoX0YNsC/tblJdmvbrgizbYICO/viw9UrP77Id0CE4ee, tblJdmvbrgizbYICO is the table id'
},
{
label: 'View Id',
name: 'viewId',
type: 'string',
placeholder: 'viw9UrP77Id0CE4ee',
description:
'If your view URL looks like: https://airtable.com/app11RobdGoX0YNsC/tblJdmvbrgizbYICO/viw9UrP77Id0CE4ee, viw9UrP77Id0CE4ee is the view id',
optional: true
},
{
label: 'Return All',
name: 'returnAll',
Expand Down Expand Up @@ -83,6 +92,7 @@ class Airtable_DocumentLoaders implements INode {
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const baseId = nodeData.inputs?.baseId as string
const tableId = nodeData.inputs?.tableId as string
const viewId = nodeData.inputs?.viewId as string
const returnAll = nodeData.inputs?.returnAll as boolean
const limit = nodeData.inputs?.limit as string
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
Expand All @@ -94,6 +104,7 @@ class Airtable_DocumentLoaders implements INode {
const airtableOptions: AirtableLoaderParams = {
baseId,
tableId,
viewId,
returnAll,
accessToken,
limit: limit ? parseInt(limit, 10) : 100
Expand Down Expand Up @@ -133,6 +144,7 @@ interface AirtableLoaderParams {
baseId: string
tableId: string
accessToken: string
viewId?: string
limit?: number
returnAll?: boolean
}
Expand All @@ -153,16 +165,19 @@ class AirtableLoader extends BaseDocumentLoader {

public readonly tableId: string

public readonly viewId?: string

public readonly accessToken: string

public readonly limit: number

public readonly returnAll: boolean

constructor({ baseId, tableId, accessToken, limit = 100, returnAll = false }: AirtableLoaderParams) {
constructor({ baseId, tableId, viewId, accessToken, limit = 100, returnAll = false }: AirtableLoaderParams) {
super()
this.baseId = baseId
this.tableId = tableId
this.viewId = viewId
this.accessToken = accessToken
this.limit = limit
this.returnAll = returnAll
Expand Down Expand Up @@ -203,7 +218,7 @@ class AirtableLoader extends BaseDocumentLoader {
}

private async loadLimit(): Promise<Document[]> {
const params = { maxRecords: this.limit }
const params = { maxRecords: this.limit, view: this.viewId }
const data = await this.fetchAirtableData(`https://api.airtable.com/v0/${this.baseId}/${this.tableId}`, params)
if (data.records.length === 0) {
return []
Expand All @@ -212,7 +227,7 @@ class AirtableLoader extends BaseDocumentLoader {
}

private async loadAll(): Promise<Document[]> {
const params: ICommonObject = { pageSize: 100 }
const params: ICommonObject = { pageSize: 100, view: this.viewId }
let data: AirtableLoaderResponse
let returnPages: AirtableLoaderPage[] = []

Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"html-to-text": "^9.0.5",
"husky": "^8.0.3",
"ioredis": "^5.3.2",
"langchain": "^0.0.213",
"langchain": "^0.0.214",
"langfuse": "2.0.2",
"langfuse-langchain": "2.0.2",
"langsmith": "0.0.53",
Expand Down

0 comments on commit 1d1c6cd

Please sign in to comment.