Skip to content

Commit

Permalink
feat: download_hub
Browse files Browse the repository at this point in the history
  • Loading branch information
yiboyasss committed Jul 11, 2024
1 parent 7fb3755 commit 402d856
Showing 1 changed file with 53 additions and 2 deletions.
55 changes: 53 additions & 2 deletions xinference/web/ui/src/scenes/launch_model/modelCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const llmAllDataKey = [
'request_limits',
'worker_ip',
'gpu_idx',
'download_hub',
'peft_model_config',
]

Expand Down Expand Up @@ -107,6 +108,7 @@ const ModelCard = ({
const [requestLimits, setRequestLimits] = useState('')
const [workerIp, setWorkerIp] = useState('')
const [GPUIdx, setGPUIdx] = useState('')
const [downloadHub, setDownloadHub] = useState('')

const [enginesObj, setEnginesObj] = useState({})
const [engineOptions, setEngineOptions] = useState([])
Expand Down Expand Up @@ -298,12 +300,14 @@ const ModelCard = ({
: Number(String(requestLimits).trim()),
worker_ip: workerIp.trim() === '' ? null : workerIp.trim(),
gpu_idx: GPUIdx.trim() === '' ? null : handleGPUIdx(GPUIdx.trim()),
download_hub: downloadHub === '' ? null : downloadHub,
}

let modelDataWithID_other = {
model_uid: modelUID.trim() === '' ? null : modelUID.trim(),
model_name: modelData.model_name,
model_type: modelType,
download_hub: downloadHub === '' ? null : downloadHub,
}

if (modelType === 'embedding' || modelType === 'rerank') {
Expand Down Expand Up @@ -359,6 +363,8 @@ const ModelCard = ({
const modelDataWithID =
modelType === 'LLM' ? modelDataWithID_LLM : modelDataWithID_other

console.log('modelDataWithID----', modelDataWithID);

// First fetcher request to initiate the model
fetchWrapper
.post('/v1/models', modelDataWithID)
Expand Down Expand Up @@ -552,6 +558,7 @@ const ModelCard = ({
request_limits,
worker_ip,
gpu_idx,
download_hub,
peft_model_config,
} = arr[0]

Expand All @@ -574,6 +581,7 @@ const ModelCard = ({
setRequestLimits(request_limits || '')
setWorkerIp(worker_ip || '')
setGPUIdx(gpu_idx?.join(',') || '')
setDownloadHub(download_hub || '')

let loraData = []
peft_model_config?.lora_list?.forEach((item) => {
Expand Down Expand Up @@ -609,7 +617,7 @@ const ModelCard = ({
}
setCustomArr(customData)

if (model_uid || request_limits || worker_ip || gpu_idx?.join(','))
if (model_uid || request_limits || worker_ip || gpu_idx?.join(',') || download_hub)
setIsOther(true)

if (
Expand All @@ -633,6 +641,7 @@ const ModelCard = ({
} else {
setModelUID(arr[0].model_uid || '')
}
setDownloadHub(arr[0].download_hub)
}
}

Expand Down Expand Up @@ -1336,11 +1345,34 @@ const ModelCard = ({
)}
</FormControl>
</Grid>
<Grid item xs={12}>
<FormControl variant="outlined" margin="normal" fullWidth>
<InputLabel id="quantization-label">
(Optional) Download_hub
</InputLabel>
<Select
labelId="download_hub-label"
value={downloadHub}
onChange={(e) => setDownloadHub(e.target.value)}
label="(Optional) Download_hub"
>
{["huggingface", "modelscope", "csghub"].map(item => {
return (
<MenuItem key={item} value={item}>
{item}
</MenuItem>
)
})}
</Select>
</FormControl>
</Grid>
<ListItemButton
onClick={() => setIsPeftModelConfig(!isPeftModelConfig)}
>
<ListItemText primary="Lora Config" />
<div style={{ display: 'flex', alignItems: 'center' }}>
<ListItemText primary="Lora Config" style={{ marginRight: 10 }} />
{isPeftModelConfig ? <ExpandLess /> : <ExpandMore />}
</div>
</ListItemButton>
<Collapse
in={isPeftModelConfig}
Expand Down Expand Up @@ -1476,6 +1508,25 @@ const ModelCard = ({
</FormControl>
</>
)}
<FormControl variant="outlined" margin="normal" fullWidth>
<InputLabel id="quantization-label">
(Optional) Download_hub
</InputLabel>
<Select
labelId="download_hub-label"
value={downloadHub}
onChange={(e) => setDownloadHub(e.target.value)}
label="(Optional) Download_hub"
>
{["huggingface", "modelscope"].map(item => {
return (
<MenuItem key={item} value={item}>
{item}
</MenuItem>
)
})}
</Select>
</FormControl>
</FormControl>
)}
<Box className="buttonsContainer">
Expand Down

0 comments on commit 402d856

Please sign in to comment.