File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ export * from "./bills"
33export * from "./search"
44export * from "./updateBillReferences"
55export * from "./updateBillSearchIndex"
6+ export * from "./vector"
Original file line number Diff line number Diff line change 77 syncBillToSearchIndex ,
88 updateBillReferences ,
99 updateBillSearchIndex ,
10- upgradeBillSearchIndex
10+ upgradeBillSearchIndex ,
11+ syncBillToVectorIndex
1112} from "./bills"
1213export { updateBillTracker } from "./analysis"
1314export { fetchCityBatch , startCityBatches } from "./cities"
@@ -41,7 +42,8 @@ export {
4142 runTestimonyBackfillChunk ,
4243 syncTestimonyToSearchIndex ,
4344 upgradeTestimonySearchIndex ,
44- resolveReportV2 as adminResolveReportV2
45+ resolveReportV2 as adminResolveReportV2 ,
46+ syncTestimonyToVectorIndex
4547} from "./testimony"
4648export {
4749 publishNotifications ,
@@ -67,6 +69,8 @@ export { transcriptionV2 } from "./webhooks"
6769export { matchOcpfMembersV2 } from "./ocpf/matchOcpfMembers"
6870export { scrapeOcpfFinanceV2 } from "./ocpf/scrapeOcpfFinance"
6971
72+ export { syncBallotQuestionToVectorIndex } from "./ballotQuestions/vector"
73+
7074export * from "./triggerPubsubFunction"
7175
7276export { mcpProxyV2 } from "./mcp/proxy"
Original file line number Diff line number Diff line change 1- import { runWith } from "firebase-functions"
1+ import { onDocumentWritten } from "firebase-functions/v2/firestore "
22import * as admin from "firebase-admin"
33import { FieldValue } from "firebase-admin/firestore"
44import { PredictionServiceClient , helpers } from "@google-cloud/aiplatform"
@@ -16,12 +16,15 @@ export function createVectorIndexer(config: VectorIndexerConfig) {
1616 const publisher = "google"
1717 const model = "text-embedding-005"
1818
19- return runWith ( {
20- timeoutSeconds : 60 ,
21- memory : "512MB"
22- } )
23- . firestore . document ( config . documentTrigger )
24- . onWrite ( async change => {
19+ return onDocumentWritten (
20+ {
21+ document : config . documentTrigger ,
22+ timeoutSeconds : 60 ,
23+ memory : "512MiB"
24+ } ,
25+ async event => {
26+ const change = event . data
27+ if ( ! change ) return
2528 const data = change . after . exists ? change . after . data ( ) : null
2629 if ( ! data ) return // Deleted
2730
@@ -103,5 +106,6 @@ export function createVectorIndexer(config: VectorIndexerConfig) {
103106 [ config . vectorField ] : fieldValue . vector ( embedding ) ,
104107 [ `${ config . vectorField } _hash` ] : textHash // Store hash to track changes
105108 } )
106- } )
109+ }
110+ )
107111}
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ export * from "./deleteTestimony"
22export * from "./publishTestimony"
33export * from "./search"
44export * from "./resolveReport"
5+ export * from "./vector"
You can’t perform that action at this time.
0 commit comments