Closed DanielZhao1990 closed 8 months ago
api key 应该走 platform 接口,参考 example 文件夹 platform.http 里面的例子
找到问题了,代理接口返回的数据,没有返回Content-Type, 直接返回了taxt,而openai标准库是使用这个进行解析的,最终导致无法解析报. 增加了一行代码解决了:c.Writer.Header().Set("Content-Type", resp.Header.Get("Content-Type")) ` defer resp.Body.Close() if resp.StatusCode != http.StatusOK { if resp.StatusCode == http.StatusUnauthorized { logger.Error(fmt.Sprintf(AccountDeactivatedErrorMessage, c.GetString(EmailKey))) }
responseMap := make(map[string]interface{})
json.NewDecoder(resp.Body).Decode(&responseMap)
c.AbortWithStatusJSON(resp.StatusCode, responseMap)
return
}
c.Writer.Header().Set("Content-Type", resp.Header.Get("Content-Type"))
io.Copy(c.Writer, resp.Body)
} `
`import openai
openai.api_key = "" openai.api_base = "https://go-chatgpt-api-1y7c.onrender.com/chatgpt/backend-api/"
print(openai.Model.list()) ` 似乎不太一致,无法成功返回