-
Notifications
You must be signed in to change notification settings - Fork 189
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
Add additional properties to FileMetadataResponse #147
Conversation
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.
Not specific to this PR, but I noticed that we populate most of the time and duration fields from RPC responses as strings. I feel like this would be very inconvenient for the user if they want to add any logic based on these responses. To make it easier for users to add logic based on responses, would we eventually want to encode these into a nicer interface (e.g. a Date
for something like createTime
)? Otherwise it seems like the user has to find a way to parse this string to be able to add some logic.
It look like Python does this (https://github.com/google-gemini/generative-ai-python/blob/main/google/generativeai/types/file_types.py#L53), but they seem to be using some other library to do this for them.. (maybe this)?
packages/main/src/files/types.ts
Outdated
* Optional additional error details. | ||
* @public | ||
*/ | ||
export interface ErrorDetail { |
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.
Should we declare this is as ErrorDetails
instead? It would align with the description in the comment as well as how it's declared in Firebase https://github.com/firebase/firebase-js-sdk/pull/8240/files#diff-77b1ce06b31ee6396f7b59b30e945f2fd334f86146a1f555a1b921537a453751R107
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.
I guess it was a grammar nit but the property this is assigned to is details
(line 110) so it's details?: ErrorDetail[]
where details is an array of ErrorDetail
s so I figured the repeating object should be singular. Although actually the implementation elsewhere in this same repo is ErrorDetails
https://github.com/google-gemini/generative-ai-js/blob/main/packages/main/src/errors.ts#L70 so I'd rather not break it. I might even just import this type from there, it already has all fields optional and a [key: string]: unknown;
so it should be compatible.
They're using self.proto there, which is directly tapping into File.proto above - they're able to import and use the proto directly and convert it to a protobuf Timestamp string. Looking further into protobuf Timestamp it looks like the comments say using the JS Date object's Formatting Duration might be a little more complicated: https://source.corp.google.com/piper///depot/google3/google/protobuf/duration.proto (internal link) I don't know of a JS library that does that formatting (none are listed in the comment above) and I'd prefer not to add external deps to this project which curently has none. |
Add fields
error
andvideoMetadata
toFileMetadataResponse
.See file.proto (internal link)
Tested on backend - output looks as expected.