-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch the Hugging Face README file using a URL
- Loading branch information
Showing
23 changed files
with
203 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { baiSignedRequestWithPromise } from '../helper'; | ||
import { useSuspendedBackendaiClient } from '../hooks'; | ||
import { useSuspenseTanQuery } from '../hooks/reactQueryAlias'; | ||
import Flex from './Flex'; | ||
import { FilterOutlined } from '@ant-design/icons'; | ||
import { Card, CardProps, theme } from 'antd'; | ||
import React from 'react'; | ||
import Markdown from 'react-markdown'; | ||
|
||
interface HuggingFaceReadmeCardProps extends CardProps { | ||
huggingFaceUrl: string; | ||
} | ||
|
||
const HuggingFaceReadmeCard: React.FC<HuggingFaceReadmeCardProps> = ({ | ||
huggingFaceUrl, | ||
...cardProps | ||
}) => { | ||
const baiClient = useSuspendedBackendaiClient(); | ||
const { token } = theme.useToken(); | ||
|
||
const { data } = useSuspenseTanQuery<{ | ||
author: string; | ||
model_name: string; | ||
markdown: string; | ||
}>({ | ||
queryKey: ['huggingFaceReadme', huggingFaceUrl], | ||
queryFn: () => { | ||
return baiSignedRequestWithPromise({ | ||
method: 'GET', | ||
url: `/services/_/huggingface/models?huggingface_url=${huggingFaceUrl}`, | ||
client: baiClient, | ||
}); | ||
}, | ||
}); | ||
|
||
return ( | ||
<Card | ||
size="small" | ||
title={ | ||
<Flex direction="row" gap="xs"> | ||
<FilterOutlined /> | ||
README.md | ||
</Flex> | ||
} | ||
styles={{ | ||
body: { | ||
padding: token.paddingLG, | ||
overflow: 'auto', | ||
minHeight: 200, | ||
maxHeight: token.screenXS, | ||
}, | ||
}} | ||
{...cardProps} | ||
> | ||
<Markdown>{data?.markdown}</Markdown> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default HuggingFaceReadmeCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.