-
Notifications
You must be signed in to change notification settings - Fork 0
fix: resolve embeddings package build errors #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Stub types for Firebase Data Connect SDK | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * The real SDK is generated by `firebase dataconnect:sdk:generate`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * These stubs allow the package to compile independently. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type UUID = `${string}-${string}-${string}-${string}-${string}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface VideoEmbeddingRow { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| segmentType: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| segmentIndex: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| content: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createdAt: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| job?: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| videoUrl?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface ListEmbeddingsResponse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { videoEmbeddings: VideoEmbeddingRow[] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface GetJobEmbeddingsResponse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { videoEmbeddings: VideoEmbeddingRow[] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface DeleteJobEmbeddingsResponse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { videoEmbedding_deleteMany: number }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export declare function listEmbeddings(vars: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| limit: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }): Promise<ListEmbeddingsResponse>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export declare function getJobEmbeddings(vars: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jobId: UUID; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }): Promise<GetJobEmbeddingsResponse>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export declare function deleteJobEmbeddings(vars: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jobId: UUID; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }): Promise<DeleteJobEmbeddingsResponse>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+45
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export declare function listEmbeddings(vars: { | |
| limit: number; | |
| }): Promise<ListEmbeddingsResponse>; | |
| export declare function getJobEmbeddings(vars: { | |
| jobId: UUID; | |
| }): Promise<GetJobEmbeddingsResponse>; | |
| export declare function deleteJobEmbeddings(vars: { | |
| jobId: UUID; | |
| }): Promise<DeleteJobEmbeddingsResponse>; | |
| export async function listEmbeddings(vars: { | |
| limit: number; | |
| }): Promise<ListEmbeddingsResponse> { | |
| throw new Error( | |
| "Firebase Data Connect SDK not generated. " + | |
| "Run `firebase dataconnect:sdk:generate` to generate the runtime implementation for listEmbeddings." | |
| ); | |
| } | |
| export async function getJobEmbeddings(vars: { | |
| jobId: UUID; | |
| }): Promise<GetJobEmbeddingsResponse> { | |
| throw new Error( | |
| "Firebase Data Connect SDK not generated. " + | |
| "Run `firebase dataconnect:sdk:generate` to generate the runtime implementation for getJobEmbeddings." | |
| ); | |
| } | |
| export async function deleteJobEmbeddings(vars: { | |
| jobId: UUID; | |
| }): Promise<DeleteJobEmbeddingsResponse> { | |
| throw new Error( | |
| "Firebase Data Connect SDK not generated. " + | |
| "Run `firebase dataconnect:sdk:generate` to generate the runtime implementation for deleteJobEmbeddings." | |
| ); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ import { | |
| listEmbeddings, | ||
| getJobEmbeddings, | ||
| deleteJobEmbeddings, | ||
| } from "../dataconnect-generated"; | ||
| } from "./dataconnect-generated/index.js"; | ||
|
|
||
| // ============================================================================= | ||
| // Types | ||
|
|
@@ -108,7 +108,7 @@ export async function generateEmbedding(text: string): Promise<number[]> { | |
| throw new Error(`Embedding API error: ${response.status} ${await response.text()}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| const data = (await response.json()) as { predictions: { embeddings: { values: number[] } }[] }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this type assertion works, the inline type For example: interface VertexEmbeddingResponse {
predictions: {
embeddings: {
values: number[];
};
}[];
}Then you could simply use |
||
| return data.predictions[0].embeddings.values; | ||
| } | ||
|
|
||
|
|
@@ -134,8 +134,8 @@ export async function generateEmbeddings(texts: string[]): Promise<number[][]> { | |
| throw new Error(`Embedding API error: ${response.status} ${await response.text()}`); | ||
| } | ||
|
|
||
| const data = await response.json(); | ||
| return data.predictions.map((p: { embeddings: { values: number[] } }) => p.embeddings.values); | ||
| const data = (await response.json()) as { predictions: { embeddings: { values: number[] } }[] }; | ||
| return data.predictions.map((p) => p.embeddings.values); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -148,7 +148,7 @@ async function getAccessToken(): Promise<string> { | |
| "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token", | ||
| { headers: { "Metadata-Flavor": "Google" } } | ||
| ); | ||
| const data = await response.json(); | ||
| const data = (await response.json()) as { access_token: string }; | ||
| return data.access_token; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The new DataConnect SDK stubs have no runtime implementation. Calls to these functions will fail with a
TypeErrorunless an external process generates the real SDK before deployment.Severity: CRITICAL
Suggested Fix
Ensure the CI/CD or deployment pipeline explicitly runs the
firebase dataconnect:sdk:generatecommand to replace the stub files with the actual SDK implementation before the application is deployed. Alternatively, add this command as aprebuildorpreparescript inpackage.jsonto make the dependency explicit.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.