-
Notifications
You must be signed in to change notification settings - Fork 259
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
Proposal: widget types #980
Conversation
js/src/lib/components/InferenceWidget/shared/WidgetInputSamples/WidgetInputSamples.svelte
Outdated
Show resolved
Hide resolved
…s/WidgetInputSamples.svelte Co-authored-by: Julien Chaumond <[email protected]>
...omponents/InferenceWidget/widgets/AudioClassificationWidget/AudioClassificationWidget.svelte
Outdated
Show resolved
Hide resolved
import type { WidgetExample } from "../WidgetExample"; | ||
type T = $$Generic<WidgetExample>; |
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.
like TOutput
, maybe a more descriptive name like TWidgetInput
or TWidgetExample
would make it clear. If so, should apply to other files as well
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.
you prefer this syntax to the generics="T extends WidgetExample">
syntax BTW @SBrandeis?
(i think both are equivalent no?)
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.
Except this nit & failing svelte-check
, lgtm!
export interface WidgetExampleTextAndTableInput<TOutput = WidgetExampleOutput> extends WidgetExampleTextInput<TOutput> { | ||
table: (string | number)[][]; | ||
} |
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 think this one is not compatible with the server-side validation of https://github.com/huggingface/moon-landing/pull/7601 @julien-c
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.
arf yes, correct. will fix the moon-landing PR
function _isZeroShotTextInput<TOutput>( | ||
sample: WidgetExample<TOutput> | ||
): sample is Exclude<WidgetExampleZeroShotTextInput<TOutput>, "text"> { | ||
return "candidate_labels" in sample && "multi_class" in sample; |
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.
you don't check the types because you trust moon-landing validation, is that correct?
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.
LOVE IT ❤️❤️❤️
* Typings for all kinds of widget examples * Add a //#region block * Tweaks * Fix some part of the CI already(?) cc @krampstudio @mishig25 for review 🙏 * Revert "Fix some part of the CI already(?)" This reverts commit 3e89028. * nvm, probably better like this * sorry this was wrong * 🤯 Use generics in Svelte (i guess...) * Proposal: widget types (#980) * wip * 🩹 Fix types in widgets * 🩹 Minimize diff * 💄 Lint * Update js/src/lib/components/InferenceWidget/shared/WidgetInputSamples/WidgetInputSamples.svelte Co-authored-by: Julien Chaumond <[email protected]> * 🧹 cleanup unwanted change * 🩹 wip: type safety * ✨ Typing & validation for ALL widgets * ♻️ Slightly less verbose version * 🩹 * 🩹 Import type? * 🩹 Alternative generic syntax to satisfy svelte-check --------- Co-authored-by: Julien Chaumond <[email protected]> * 💄 Lint & checks * Go for same syntax everywhere --------- Co-authored-by: Simon Brandeis <[email protected]> Co-authored-by: SBrandeis <[email protected]>
wdyt @julien-c @mishig25 ?