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 {
|
} else {
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -121,6 +117,11 @@ func testChannel(channel *model.Channel, request ChatRequest) error {
|
|||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// Check if streaming is complete and streamResponseText is populated
|
||||||
|
if isStream && streamResponseText == "" {
|
||||||
|
return errors.New("Streaming not complete")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +129,7 @@ func buildTestRequest() *ChatRequest {
|
|||||||
testRequest := &ChatRequest{
|
testRequest := &ChatRequest{
|
||||||
Model: "", // this will be set later
|
Model: "", // this will be set later
|
||||||
MaxTokens: 1,
|
MaxTokens: 1,
|
||||||
|
Stream: false,
|
||||||
}
|
}
|
||||||
testMessage := Message{
|
testMessage := Message{
|
||||||
Role: "user",
|
Role: "user",
|
||||||
|
@ -45,6 +45,7 @@ type ChatRequest struct {
|
|||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
Messages []Message `json:"messages"`
|
Messages []Message `json:"messages"`
|
||||||
MaxTokens int `json:"max_tokens"`
|
MaxTokens int `json:"max_tokens"`
|
||||||
|
Stream bool `json:"stream"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TextRequest struct {
|
type TextRequest struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user