From 99eb5d2f14e877025ca780314369b6fa056151fe Mon Sep 17 00:00:00 2001 From: Eduard-Constantin Ibinceanu Date: Tue, 10 Dec 2024 03:38:01 +0200 Subject: [PATCH] feat(community): Add additional fields to airtable loader (#7322) Co-authored-by: Jacob Lee --- .../src/document_loaders/web/airtable.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libs/langchain-community/src/document_loaders/web/airtable.ts b/libs/langchain-community/src/document_loaders/web/airtable.ts index 7d01bfa9ea64..6ec5bb094310 100644 --- a/libs/langchain-community/src/document_loaders/web/airtable.ts +++ b/libs/langchain-community/src/document_loaders/web/airtable.ts @@ -4,10 +4,16 @@ import { Document } from "@langchain/core/documents"; import { getEnvironmentVariable } from "@langchain/core/utils/env"; import { AsyncCaller } from "@langchain/core/utils/async_caller"; +export interface AirtableRequestParams { + view?: string; + maxRecords?: number; + filterByFormula?: string; +} + export interface AirtableLoaderOptions { tableId: string; baseId: string; - kwargs?: Record; + kwargs?: AirtableRequestParams; } interface AirtableRecord { @@ -28,7 +34,7 @@ export class AirtableLoader extends BaseDocumentLoader { private readonly baseId: string; - private readonly kwargs: Record; + private readonly kwargs: AirtableRequestParams; private static readonly BASE_URL = "https://api.airtable.com/v0"; @@ -123,6 +129,10 @@ export class AirtableLoader extends BaseDocumentLoader { ); if (offset) url.searchParams.append("offset", offset); if (this.kwargs.view) url.searchParams.append("view", this.kwargs.view); + if (this.kwargs.maxRecords) + url.searchParams.append("maxRecords", this.kwargs.maxRecords.toString()); + if (this.kwargs.filterByFormula) + url.searchParams.append("filterByFormula", this.kwargs.filterByFormula); return url.toString(); }