fix: Fix the abnormal status of the ollama model (#8223)

This commit is contained in:
ssongliu 2025-03-24 17:35:31 +08:00 committed by GitHub
parent 818ef0e1f0
commit 7d81dad822
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View file

@ -164,7 +164,18 @@ func (u *AIToolService) Recreate(req dto.OllamaModelName) error {
taskItem.AddSubTask(i18n.GetWithName("OllamaModelPull", req.Name), func(t *task.Task) error { taskItem.AddSubTask(i18n.GetWithName("OllamaModelPull", req.Name), func(t *task.Task) error {
return cmd.ExecShellWithTask(taskItem, time.Hour, "docker", "exec", containerName, "ollama", "pull", req.Name) return cmd.ExecShellWithTask(taskItem, time.Hour, "docker", "exec", containerName, "ollama", "pull", req.Name)
}, nil) }, nil)
_ = taskItem.Execute() taskItem.AddSubTask(i18n.GetWithName("OllamaModelSize", req.Name), func(t *task.Task) error {
itemSize, err := loadModelSize(modelInfo.Name, containerName)
if len(itemSize) != 0 {
_ = aiRepo.Update(modelInfo.ID, map[string]interface{}{"status": constant.StatusSuccess, "size": itemSize})
} else {
_ = aiRepo.Update(modelInfo.ID, map[string]interface{}{"status": constant.StatusFailed, "message": err.Error()})
}
return nil
}, nil)
if err := taskItem.Execute(); err != nil {
_ = aiRepo.Update(modelInfo.ID, map[string]interface{}{"status": constant.StatusFailed, "message": err.Error()})
}
}() }()
return nil return nil
} }

View file

@ -12,7 +12,7 @@
:indeterminate="isIndeterminate" :indeterminate="isIndeterminate"
@change="handleCheckAllChange" @change="handleCheckAllChange"
> >
{{ $t('setting.all') }} {{ $t('commons.table.all') }}
</el-checkbox> </el-checkbox>
<el-checkbox-group v-model="checkedItems" @change="handleCheckedChange"> <el-checkbox-group v-model="checkedItems" @change="handleCheckedChange">
<el-checkbox v-for="(item, index) in list" :key="index" :label="item.name" :value="item.id" /> <el-checkbox v-for="(item, index) in list" :key="index" :label="item.name" :value="item.id" />
@ -55,9 +55,10 @@ interface DialogProps {
list: Array<AI.OllamaModelDropInfo>; list: Array<AI.OllamaModelDropInfo>;
} }
const acceptParams = (props: DialogProps): void => { const acceptParams = (props: DialogProps): void => {
checkAll.value = false;
checkedItems.value = [];
list.value = props.list; list.value = props.list;
checkAll.value = true; checkAll.value = true;
handleCheckAllChange(true);
open.value = true; open.value = true;
}; };

View file

@ -42,7 +42,7 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
const initTerm = () => { const initTerm = () => {
nextTick(() => { nextTick(() => {
terminalRef.value.acceptParams({ terminalRef.value.acceptParams({
endpoint: '/api/v2/ai/containers/exec', endpoint: '/api/v2/containers/exec',
args: `source=ollama&name=${itemName.value}`, args: `source=ollama&name=${itemName.value}`,
error: '', error: '',
initCmd: '', initCmd: '',