Giter Site home page Giter Site logo

Comments (2)

linweiyuan avatar linweiyuan commented on September 28, 2024

api key 应该走 platform 接口,参考 example 文件夹 platform.http 里面的例子

from go-chatgpt-api.

DanielZhao1990 avatar DanielZhao1990 commented on September 28, 2024

找到问题了,代理接口返回的数据,没有返回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)

}
`

from go-chatgpt-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.