Skip to content

Commit 70230ec

Browse files
authored
Merge pull request #31 from chaitin/develop/jw
chore: 移除前端错误消息显示并简化后端错误信息
2 parents 3cb2d75 + d367d72 commit 70230ec

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

ui/ModelModal/src/ModelModal.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ export const ModelModal: React.FC<ModelModalProps> = ({
159159
setModelLoading(false);
160160
}).
161161
catch((res) => {
162-
messageHandler.error("获取模型失败 " + res.error);
163162
setModelLoading(false);
164163
});
165164
};
@@ -219,7 +218,6 @@ export const ModelModal: React.FC<ModelModalProps> = ({
219218
setLoading(false);
220219
})
221220
.catch((res) => {
222-
messageHandler.error("修改模型失败 " + res.error);
223221
setLoading(false);
224222
});
225223
} else {
@@ -254,13 +252,11 @@ export const ModelModal: React.FC<ModelModalProps> = ({
254252
setLoading(false);
255253
})
256254
.catch((res) => {
257-
messageHandler.error("添加模型失败 " + res.error);
258255
setLoading(false);
259256
});
260257
}
261258
})
262259
.catch((res) => {
263-
messageHandler.error("添加模型失败");
264260
setLoading(false);
265261
});
266262
};

usecase/modelkit.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,19 @@ func CheckModel(ctx context.Context, req *domain.CheckModelReq) (*domain.CheckMo
198198
}
199199
body, err := json.Marshal(reqBody)
200200
if err != nil {
201-
checkResp.Error = fmt.Sprintf("序列化请求体失败: %s", err.Error())
201+
checkResp.Error = err.Error()
202202
return checkResp, nil
203203
}
204204
request, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewBuffer(body))
205205
if err != nil {
206-
checkResp.Error = fmt.Sprintf("创建HTTP请求失败: %s", err.Error())
206+
checkResp.Error = err.Error()
207207
return checkResp, nil
208208
}
209209
request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", req.APIKey))
210210
request.Header.Set("Content-Type", "application/json")
211211
resp, err := http.DefaultClient.Do(request)
212212
if err != nil {
213-
checkResp.Error = fmt.Sprintf("发送HTTP请求失败: %s", err.Error())
213+
checkResp.Error = err.Error()
214214
return checkResp, nil
215215
}
216216
defer func() {
@@ -219,7 +219,7 @@ func CheckModel(ctx context.Context, req *domain.CheckModelReq) (*domain.CheckMo
219219
}
220220
}()
221221
if resp.StatusCode != http.StatusOK {
222-
checkResp.Error = fmt.Sprintf("HTTP请求失败: %s", resp.Status)
222+
checkResp.Error = resp.Status
223223
return checkResp, nil
224224
}
225225
return checkResp, nil
@@ -235,15 +235,15 @@ func CheckModel(ctx context.Context, req *domain.CheckModelReq) (*domain.CheckMo
235235
ModelType: modelType,
236236
})
237237
if err != nil {
238-
checkResp.Error = fmt.Sprintf("获取聊天模型失败: %s", err.Error())
238+
checkResp.Error = err.Error()
239239
return checkResp, nil
240240
}
241241
resp, err := chatModel.Generate(ctx, []*schema.Message{
242242
schema.SystemMessage("You are a helpful assistant."),
243243
schema.UserMessage("hi"),
244244
})
245245
if err != nil {
246-
checkResp.Error = fmt.Sprintf("生成聊天内容失败: %s", err.Error())
246+
checkResp.Error = err.Error()
247247
return checkResp, nil
248248
}
249249
content := resp.Content

0 commit comments

Comments
 (0)