Skip to content

Commit

Permalink
feat: err if cannot connect to yocsef inference
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed May 24, 2024
1 parent d191aca commit 0027af1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apis/record/yocsef.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func InferYocsefAsyncAPI(c *websocket.Conn) {
}

if body.Request == "" {
return BadRequest("request is empty")
return BadRequest("内容不能为空")
}

ctx, cancel := context.WithCancelCause(context.Background())
Expand Down
6 changes: 5 additions & 1 deletion service/yocsef.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func InferYocsef(
}
defer res.Body.Close()

if res.StatusCode != http.StatusOK {
return nil, errors.New("yocsef 推理模型暂不可用")
}

var reader = bufio.NewReader(res.Body)
var resultBuilder strings.Builder
var nowOutput string
Expand Down Expand Up @@ -143,7 +147,7 @@ func InferYocsef(
})
}

err = w.WriteJSON(InferResponseModel{
_ = w.WriteJSON(InferResponseModel{
Status: 0,
Output: nowOutput,
Stage: "MOSS",
Expand Down

0 comments on commit 0027af1

Please sign in to comment.