lzhpo / chatgpt-spring-boot-starter Goto Github PK
View Code? Open in Web Editor NEW支持OpenAi所有可用的接口,包括但不限于流式输出和Token计算等,可配置多个API-Key、权重、代理、自定义API等诸多功能...
Home Page: http://www.lzhpo.com
License: Apache License 2.0
支持OpenAi所有可用的接口,包括但不限于流式输出和Token计算等,可配置多个API-Key、权重、代理、自定义API等诸多功能...
Home Page: http://www.lzhpo.com
License: Apache License 2.0
初步怀疑是异步导致的,就算在controller的接口try catch也捕捉不到异常
1.0.8正常
升级到1.0.9出错。
在本项目中可以重现:
设置 apikey
运行 test application
调用 curl http://127.0.0.1:6060/chat/sse\?message\=what%20is%20python
出错信息如下:
2023-07-04 14:27:36.873 ERROR 50758 --- [.openai.com/...] c.l.c.sse.AbstractEventSourceListener : Execute onFailure method, response: Response{protocol=http/1.1, code=200, message=OK, url=https://api.openai.com/v1/chat/completions}, error: closed
Exception in thread "OkHttp Dispatcher" com.lzhpo.chatgpt.exception.OpenAiException: closed
at com.lzhpo.chatgpt.sse.AbstractEventSourceListener.onFailure(AbstractEventSourceListener.java:55)
如题
apikey可能被限流或者钱用完了等异常情况下,自动踢出这个key。
或者留一个口子,当出现这类异常的时候,有listener可以操作
`@Configuration
class OpenApiInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val response = chain.proceed(chain.request())
return response.newBuilder()
.addHeader("Access-Control-Allow-Origin", "*")
.addHeader("Access-Control-Allow-Methods", "*")
.addHeader("Access-Control-Allow-Headers", "*")
.build()
}
}`
@Bean fun corsConfigurer(): WebMvcConfigurer = object : WebMvcConfigurer { override fun addCorsMappings(registry: CorsRegistry) { registry.addMapping("/**") .allowedOrigins("*") // .allowCredentials(true) .allowedMethods("*") // GET POST PUT DELETE .allowedHeaders("*") } }
找不到解决方案
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.