Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/ModelModal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yokowu/modelkit-ui",
"version": "0.7.0",
"version": "0.7.1",
"description": "A reusable AI model configuration modal component for React applications",
"private": false,
"type": "module",
Expand Down
12 changes: 5 additions & 7 deletions ui/ModelModal/src/ModelModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,11 @@ export const ModelModal: React.FC<ModelModalProps> = ({
value: true,
message: 'URL 不能为空',
},
validate: (value) => {
if (!value) return true; // 空值由required规则处理
const hasScheme = /^https?:\/\//i.test(value);
return hasScheme || 'API地址必须包含协议(http://或https://)';
},
}}
render={({ field }) => (
<TextField
Expand Down Expand Up @@ -682,7 +687,6 @@ export const ModelModal: React.FC<ModelModalProps> = ({
</Box>
</>
) : modelUserList.length === 0 ? (
<>
<Button
fullWidth
variant='outlined'
Expand All @@ -699,12 +703,6 @@ export const ModelModal: React.FC<ModelModalProps> = ({
>
获取模型列表
</Button>
{addModelError && (
<Box sx={{ fontSize: 12, color: 'error.main', mt: 1 }}>
{addModelError}
</Box>
)}
</>
) : (
<>
<Box sx={{ fontSize: 14, lineHeight: '32px', mt: 2 }}>
Expand Down
6 changes: 3 additions & 3 deletions usecase/modelkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,12 @@ func generateBaseURLFixSuggestion(errContent string, baseURL string) string {
hasPath = true
}

errType := consts.AddModelBaseURLErrTypeHost
var errType consts.AddModelBaseURLErrType
// 404 且是本地地址,建议使用宿主机主机名
if is404 && isLocal {
errType = consts.AddModelBaseURLErrTypeHost
} else if !isLocal && !hasPath && !is404 {
// 不是本地地址,且没有path,且不是404,建议在API地址末尾添加/v1
} else if !isLocal && !hasPath {
// 不是本地地址,且没有path,建议在API地址末尾添加/v1
errType = consts.AddModelBaseURLErrTypeV1Path
} else {
return ""
Expand Down