add common ai support

This commit is contained in:
robin
2023-10-03 16:47:50 +08:00
parent d37c1a9646
commit 2dabb8eb39

View File

@ -1,7 +1,9 @@
package ai.chat2db.server.web.api.controller.ai.fastchat.interceptor;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.http.ContentType;
import cn.hutool.http.Header;
import com.google.common.collect.Lists;
import lombok.Getter;
import okhttp3.Interceptor;
import okhttp3.Request;
@ -28,7 +30,8 @@ public class FastChatHeaderAuthorizationInterceptor implements Interceptor {
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
Request request = original.newBuilder()
.header("apiKey", apiKey) // replace to your corresponding field and value
// replace to your corresponding field and value
.header(Header.AUTHORIZATION.getValue(), "Bearer " + apiKey)
.header(Header.CONTENT_TYPE.getValue(), ContentType.JSON.getValue())
.method(original.method(), original.body())
.build();