Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: channel test false negative #2065

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ var UserContentRequestProxy = env.String("USER_CONTENT_REQUEST_PROXY", "")
var UserContentRequestTimeout = env.Int("USER_CONTENT_REQUEST_TIMEOUT", 30)

var EnforceIncludeUsage = env.Bool("ENFORCE_INCLUDE_USAGE", false)
var TestPrompt = env.String("TEST_PROMPT", "Print your model name exactly and do not output without any other text.")
var TestPrompt = env.String("TEST_PROMPT", "2 + 2 = ?")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我还是感觉模型名称有用一些,现在可以使用环境变量取代该默认值

19 changes: 12 additions & 7 deletions controller/channel-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,28 @@ func testChannel(ctx context.Context, channel *model.Channel, request *relaymode
logger.SysLog(string(jsonData))
requestBody := bytes.NewBuffer(jsonData)
c.Request.Body = io.NopCloser(requestBody)
resp, err := adaptor.DoRequest(c, meta, requestBody)
var resp *http.Response
resp, err = adaptor.DoRequest(c, meta, requestBody)
if err != nil {
return "", err, nil
}
if resp != nil && resp.StatusCode != http.StatusOK {
err := controller.RelayErrorHandler(resp)
errorMessage := err.Error.Message
wrappedErr := controller.RelayErrorHandler(resp)
errorMessage := wrappedErr.Error.Message
if errorMessage != "" {
errorMessage = ", error message: " + errorMessage
}
return "", fmt.Errorf("http status code: %d%s", resp.StatusCode, errorMessage), &err.Error
err = fmt.Errorf("http status code: %d%s", resp.StatusCode, errorMessage)
return "", err, &wrappedErr.Error
}
usage, respErr := adaptor.DoResponse(c, resp, meta)
if respErr != nil {
return "", fmt.Errorf("%s", respErr.Error.Message), &respErr.Error
err = fmt.Errorf("%s", respErr.Error.Message)
return "", err, &respErr.Error
}
if usage == nil {
return "", errors.New("usage is nil"), nil
err = errors.New("usage is nil")
return "", err, nil
}
rawResponse := w.Body.String()
_, responseMessage, err = parseTestResponse(rawResponse)
Expand All @@ -157,7 +161,8 @@ func testChannel(ctx context.Context, channel *model.Channel, request *relaymode
}
result := w.Result()
// print result.Body
respBody, err := io.ReadAll(result.Body)
var respBody []byte
respBody, err = io.ReadAll(result.Body)
if err != nil {
return "", err, nil
}
Expand Down