Skip to content

Commit

Permalink
feat(community): Add additional fields to airtable loader (#7322)
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Lee <[email protected]>
  • Loading branch information
eduardconstantin and jacoblee93 authored Dec 10, 2024
1 parent 0c79483 commit 99eb5d2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libs/langchain-community/src/document_loaders/web/airtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>;
kwargs?: AirtableRequestParams;
}

interface AirtableRecord {
Expand All @@ -28,7 +34,7 @@ export class AirtableLoader extends BaseDocumentLoader {

private readonly baseId: string;

private readonly kwargs: Record<string, any>;
private readonly kwargs: AirtableRequestParams;

private static readonly BASE_URL = "https://api.airtable.com/v0";

Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 99eb5d2

Please sign in to comment.