@@ -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