Skip to content

Commit 56c08a4

Browse files
committed
Add stripe-customer-id header to GitHub ingest flow
- Add headers parameter to RAG ingest pipeline options - Pass headers through GitHub blob, PR, and issue ingest functions - Call buildAiGatewayHeaders in processRepository This ensures AI Gateway requests during GitHub repository ingestion include Stripe customer ID for billing attribution.
1 parent fa3b2ed commit 56c08a4

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

apps/studio.giselles.ai/lib/vector-stores/github/ingest/blobs/ingest-github-blobs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export async function ingestGitHubBlobs(params: {
2424
teamDbId: number;
2525
embeddingProfileId: EmbeddingProfileId;
2626
embeddingComplete?: EmbeddingCompleteCallback;
27+
headers?: Record<string, string>;
2728
}): Promise<void> {
2829
const { repositoryIndexDbId, isInitialIngest } = await getRepositoryIndexInfo(
2930
params.source,
@@ -55,6 +56,7 @@ export async function ingestGitHubBlobs(params: {
5556
}),
5657
embeddingProfileId: params.embeddingProfileId,
5758
embeddingComplete: params.embeddingComplete,
59+
headers: params.headers,
5860
});
5961

6062
const result = await ingest();

apps/studio.giselles.ai/lib/vector-stores/github/ingest/issues/ingest-github-issues.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function ingestGitHubIssues(params: {
2121
teamDbId: number;
2222
embeddingProfileId: EmbeddingProfileId;
2323
embeddingComplete?: EmbeddingCompleteCallback;
24+
headers?: Record<string, string>;
2425
}): Promise<void> {
2526
const { repositoryIndexDbId } = await getRepositoryIndexInfo(
2627
params.source,
@@ -80,6 +81,7 @@ export async function ingestGitHubIssues(params: {
8081
},
8182
embeddingProfileId: params.embeddingProfileId,
8283
embeddingComplete: params.embeddingComplete,
84+
headers: params.headers,
8385
});
8486

8587
const result = await ingest();

apps/studio.giselles.ai/lib/vector-stores/github/ingest/process-repository.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from "@/db";
1616
import type { TeamWithSubscription } from "@/services/teams";
1717
import { fetchTeamByDbId } from "@/services/teams/fetch-team";
18+
import { buildAiGatewayHeaders } from "../../shared/ai-gateway-headers";
1819
import type { RepositoryWithStatuses } from "../types";
1920
import {
2021
createBlobMetadata,
@@ -76,12 +77,15 @@ const CONTENT_PROCESSORS: Record<
7677
},
7778
});
7879

80+
const headers = buildAiGatewayHeaders(team);
81+
7982
await ingestGitHubBlobs({
8083
octokitClient: octokit,
8184
source: { owner, repo, commitSha: commit.sha },
8285
teamDbId,
8386
embeddingProfileId,
8487
embeddingComplete,
88+
headers,
8589
});
8690

8791
return {
@@ -108,12 +112,15 @@ const CONTENT_PROCESSORS: Record<
108112
},
109113
});
110114

115+
const headers = buildAiGatewayHeaders(team);
116+
111117
await ingestGitHubPullRequests({
112118
githubAuthConfig: buildGitHubAuthConfig(installationId),
113119
source: { owner, repo },
114120
teamDbId,
115121
embeddingProfileId,
116122
embeddingComplete,
123+
headers,
117124
});
118125

119126
const lastPrNumber = await getLastIngestedPrNumber(
@@ -144,12 +151,15 @@ const CONTENT_PROCESSORS: Record<
144151
},
145152
});
146153

154+
const headers = buildAiGatewayHeaders(team);
155+
147156
await ingestGitHubIssues({
148157
githubAuthConfig: buildGitHubAuthConfig(installationId),
149158
source: { owner, repo },
150159
teamDbId,
151160
embeddingProfileId,
152161
embeddingComplete,
162+
headers,
153163
});
154164

155165
const lastIssueNumber = await getLastIngestedIssueNumber(

apps/studio.giselles.ai/lib/vector-stores/github/ingest/pull-requests/ingest-github-pull-requests.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export async function ingestGitHubPullRequests(params: {
2626
teamDbId: number;
2727
embeddingProfileId: EmbeddingProfileId;
2828
embeddingComplete?: EmbeddingCompleteCallback;
29+
headers?: Record<string, string>;
2930
}): Promise<void> {
3031
const { repositoryIndexDbId } = await getRepositoryIndexInfo(
3132
params.source,
@@ -59,6 +60,7 @@ export async function ingestGitHubPullRequests(params: {
5960
}),
6061
embeddingProfileId: params.embeddingProfileId,
6162
embeddingComplete: params.embeddingComplete,
63+
headers: params.headers,
6264
});
6365

6466
const result = await ingest();

packages/rag/src/ingest/pipeline.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export interface IngestPipelineOptions<
4545
parallelLimit?: number;
4646
onProgress?: (progress: IngestProgress) => void;
4747
onError?: (error: IngestError) => void;
48+
49+
// Optional headers for AI Gateway requests
50+
headers?: Record<string, string>;
4851
}
4952

5053
const DEFAULT_MAX_BATCH_SIZE = 100;
@@ -113,6 +116,7 @@ export function createPipeline<
113116
{
114117
embeddingComplete,
115118
transport: useGateway ? "gateway" : "provider",
119+
headers: useGateway ? options.headers : undefined,
116120
},
117121
);
118122

0 commit comments

Comments
 (0)