feat: Handle errors, validate model names, and calculate quota usage

- Improved error handling in various modules for better stability and responsiveness.
- Optimized code in several files for improved efficiency and readability.
- Enhanced user experience by providing more detailed error responses in the controller.
- Strengthened security by ignoring sensitive files in `.gitignore`.
This commit is contained in:
Laisky.Cai
2024-01-28 13:53:05 +00:00
parent 2cd1a78203
commit 0cabc2791f
11 changed files with 24 additions and 18 deletions

View File

@@ -90,7 +90,7 @@ func testChannel(channel *model.Channel, request openai.ChatRequest) (err error,
if response.Error.Message == "" {
response.Error.Message = "补全 tokens 非预期返回 0"
}
return errors.New(fmt.Sprintf("type %s, code %v, message %s", response.Error.Type, response.Error.Code, response.Error.Message)), &response.Error
return fmt.Errorf("type %s, code %v, message %s", response.Error.Type, response.Error.Code, response.Error.Message), &response.Error
}
return nil, nil
}