* feat: model hub revamp UI * chore: model description - consistent markdown css * chore: add model versions dropdown * chore: integrate APIs - model sources * chore: update model display name * chore: lint fix * chore: page transition animation * feat: model search dropdown - deeplink * chore: bump cortex version * chore: add remote model sources * chore: model download state * chore: fix model metadata label * chore: polish model detail page markdown * test: fix test cases * chore: initialize default Hub model sources * chore: fix model stats * chore: clean up click outside and inside hooks * feat: change hub banner * chore: lint fix * chore: fix css long model id
32 lines
866 B
TypeScript
32 lines
866 B
TypeScript
/**
|
|
* This utility is to extract cortexso model description from README.md file
|
|
* @returns
|
|
*/
|
|
export const extractDescription = (text?: string) => {
|
|
if (!text) return text
|
|
const overviewPattern = /(?:##\s*Overview\s*\n)([\s\S]*?)(?=\n\s*##|$)/
|
|
const matches = text?.match(overviewPattern)
|
|
if (matches && matches[1]) {
|
|
return matches[1].trim()
|
|
}
|
|
return text?.slice(0, 500).trim()
|
|
}
|
|
|
|
/**
|
|
* Extract model name from repo path, e.g. cortexso/tinyllama -> tinyllama
|
|
* @param modelId
|
|
* @returns
|
|
*/
|
|
export const extractModelName = (model?: string) => {
|
|
return model?.split('/')[1] ?? model
|
|
}
|
|
|
|
/**
|
|
* Extract model name from repo path, e.g. https://huggingface.co/cortexso/tinyllama -> cortexso/tinyllama
|
|
* @param modelId
|
|
* @returns
|
|
*/
|
|
export const extractModelRepo = (model?: string) => {
|
|
return model?.replace('https://huggingface.co/', '')
|
|
}
|