feat: optimized channel testing (1)

This commit is contained in:
ckt1031 2023-07-11 17:11:55 +08:00
parent 4928319494
commit 12365ccf69
2 changed files with 7 additions and 4 deletions

View File

@ -99,10 +99,6 @@ func testChannel(channel *model.Channel, request ChatRequest) error {
}
}
}
if streamResponseText == "" {
return errors.New("empty stream response")
}
} else {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
@ -121,6 +117,11 @@ func testChannel(channel *model.Channel, request ChatRequest) error {
defer resp.Body.Close()
// Check if streaming is complete and streamResponseText is populated
if isStream && streamResponseText == "" {
return errors.New("Streaming not complete")
}
return nil
}
@ -128,6 +129,7 @@ func buildTestRequest() *ChatRequest {
testRequest := &ChatRequest{
Model: "", // this will be set later
MaxTokens: 1,
Stream: false,
}
testMessage := Message{
Role: "user",

View File

@ -45,6 +45,7 @@ type ChatRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens int `json:"max_tokens"`
Stream bool `json:"stream"`
}
type TextRequest struct {