feat: gpt-4-gizmo-g-* model is supported

This commit is contained in:
RockYang
2024-01-15 15:03:05 +08:00
parent 059f57db2d
commit 9f57fb1421
14 changed files with 86 additions and 31 deletions

View File

@@ -23,23 +23,28 @@ func NewLocalStorage(config *types.AppConfig) LocalStorage {
}
}
func (s LocalStorage) PutFile(ctx *gin.Context, name string) (string, error) {
func (s LocalStorage) PutFile(ctx *gin.Context, name string) (File, error) {
file, err := ctx.FormFile(name)
if err != nil {
return "", fmt.Errorf("error with get form: %v", err)
return File{}, fmt.Errorf("error with get form: %v", err)
}
filePath, err := utils.GenUploadPath(s.config.BasePath, file.Filename)
path, err := utils.GenUploadPath(s.config.BasePath, file.Filename)
if err != nil {
return "", fmt.Errorf("error with generate filename: %s", err.Error())
return File{}, fmt.Errorf("error with generate filename: %s", err.Error())
}
// 将文件保存到指定路径
err = ctx.SaveUploadedFile(file, filePath)
err = ctx.SaveUploadedFile(file, path)
if err != nil {
return "", fmt.Errorf("error with save upload file: %s", err.Error())
return File{}, fmt.Errorf("error with save upload file: %s", err.Error())
}
return utils.GenUploadUrl(s.config.BasePath, s.config.BaseURL, filePath), nil
ext := filepath.Ext(file.Filename)
return File{
URL: utils.GenUploadUrl(s.config.BasePath, s.config.BaseURL, path),
Ext: ext,
Size: file.Size,
}, nil
}
func (s LocalStorage) PutImg(imageURL string, useProxy bool) (string, error) {