Package com.unfbx.chatgpt.interceptor
Class DefaultOpenAiAuthInterceptor
- java.lang.Object
-
- com.unfbx.chatgpt.interceptor.OpenAiAuthInterceptor
-
- com.unfbx.chatgpt.interceptor.DefaultOpenAiAuthInterceptor
-
- All Implemented Interfaces:
okhttp3.Interceptor
public class DefaultOpenAiAuthInterceptor extends OpenAiAuthInterceptor
描述:请求增加header apikey- Since:
- 2023-03-23
- Author:
- https:www.unfbx.com
-
-
Constructor Summary
Constructors Constructor Description DefaultOpenAiAuthInterceptor()请求头处理DefaultOpenAiAuthInterceptor(Map warringConfig)构造方法
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description okhttp3.Responseintercept(okhttp3.Interceptor.Chain chain)拦截器鉴权protected voidnoHaveActiveKeyWarring()所有的key都失效后,自定义预警配置 可以通过warringConfig配置参数实现飞书、钉钉、企业微信、邮箱预警等protected List<String>onErrorDealApiKeys(String apiKey)key失效或者禁用后的处理逻辑 默认不处理-
Methods inherited from class com.unfbx.chatgpt.interceptor.OpenAiAuthInterceptor
auth, getKey
-
-
-
-
Constructor Detail
-
DefaultOpenAiAuthInterceptor
public DefaultOpenAiAuthInterceptor()
请求头处理
-
DefaultOpenAiAuthInterceptor
public DefaultOpenAiAuthInterceptor(Map warringConfig)
构造方法- Parameters:
warringConfig- 所有的key都失效后的告警参数配置
-
-
Method Detail
-
intercept
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException拦截器鉴权- Parameters:
chain- Chain- Returns:
- Response对象
- Throws:
IOException- io异常
-
onErrorDealApiKeys
protected List<String> onErrorDealApiKeys(String apiKey)
key失效或者禁用后的处理逻辑 默认不处理- Specified by:
onErrorDealApiKeysin classOpenAiAuthInterceptor- Parameters:
apiKey- 返回新的api keys集合- Returns:
- 新的apiKey集合
-
noHaveActiveKeyWarring
protected void noHaveActiveKeyWarring()
Description copied from class:OpenAiAuthInterceptor所有的key都失效后,自定义预警配置 可以通过warringConfig配置参数实现飞书、钉钉、企业微信、邮箱预警等- Specified by:
noHaveActiveKeyWarringin classOpenAiAuthInterceptor
-
-