-
Notifications
You must be signed in to change notification settings - Fork 512
feat: add Hugging Face model source support #8330
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 | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,6 +72,9 @@ export function getAssetDisplayName(asset: AssetItem): string { | |||||||||||||||||||||||||||||||||||||||||||
| * @returns The source URL or null if not present/parseable | ||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||
| export function getAssetSourceUrl(asset: AssetItem): string | null { | ||||||||||||||||||||||||||||||||||||||||||||
| if (typeof asset.metadata?.repo_url === 'string') { | ||||||||||||||||||||||||||||||||||||||||||||
| return asset.metadata.repo_url | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+75
to
+77
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. Validate 🔒️ Proposed fix (validate and safely fall through) export function getAssetSourceUrl(asset: AssetItem): string | null {
- if (typeof asset.metadata?.repo_url === 'string') {
- return asset.metadata.repo_url
- }
+ const repoUrl = asset.metadata?.repo_url
+ if (typeof repoUrl === 'string') {
+ const trimmed = repoUrl.trim()
+ if (trimmed) {
+ try {
+ const parsed = new URL(trimmed)
+ if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
+ return trimmed
+ }
+ } catch {
+ // fall through to source_arn
+ }
+ }
+ }
// Note: Reversed priority for backwards compatibility
const sourceArn =
asset.metadata?.source_arn ?? asset.user_metadata?.source_arn📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
| // Note: Reversed priority for backwards compatibility | ||||||||||||||||||||||||||||||||||||||||||||
| const sourceArn = | ||||||||||||||||||||||||||||||||||||||||||||
| asset.metadata?.source_arn ?? asset.user_metadata?.source_arn | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
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.
consider using a enum here
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.
Once we add a third source, definitely 🫡
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.
If this comes up again, it might be nice to extract the
img srcinto a computed usingswitch/case