feat: optimized channel testing (1)
This commit is contained in:
parent
4928319494
commit
12365ccf69
@ -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",
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user