mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-01 08:52:11 +08:00
ai deserialization update
This commit is contained in:
@ -9,6 +9,7 @@ import ai.chat2db.server.web.api.controller.ai.azure.interceptor.AzureHeaderAuth
|
||||
import ai.chat2db.server.web.api.controller.ai.azure.model.AzureChatCompletionsOptions;
|
||||
import ai.chat2db.server.web.api.controller.ai.azure.model.AzureChatMessage;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -166,6 +167,7 @@ public class AzureOpenAiStreamClient {
|
||||
|
||||
EventSource.Factory factory = EventSources.createFactory(this.okHttpClient);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(chatCompletionsOptions);
|
||||
if (!endpoint.endsWith("/")) {
|
||||
endpoint = endpoint + "/";
|
||||
|
@ -5,6 +5,7 @@ import ai.chat2db.server.web.api.controller.ai.baichuan.interceptor.BaichuanHead
|
||||
import ai.chat2db.server.web.api.controller.ai.baichuan.model.BaichuanChatCompletionsOptions;
|
||||
import ai.chat2db.server.web.api.controller.ai.fastchat.model.FastChatMessage;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -191,6 +192,7 @@ public class BaichuanAIStreamClient {
|
||||
chatCompletionsOptions.setMessages(chatMessages);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(chatCompletionsOptions);
|
||||
Request request = new Request.Builder()
|
||||
.url(apiHost)
|
||||
|
@ -11,6 +11,7 @@ import ai.chat2db.server.web.api.controller.ai.fastchat.embeddings.FastChatEmbed
|
||||
import ai.chat2db.server.web.api.controller.ai.fastchat.embeddings.FastChatEmbeddingResponse;
|
||||
import ai.chat2db.server.web.api.util.ApplicationContextUtil;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.unfbx.chatgpt.entity.chat.ChatCompletion;
|
||||
import com.unfbx.chatgpt.entity.chat.Message;
|
||||
@ -204,6 +205,7 @@ public class Chat2DBAIStreamClient {
|
||||
|
||||
EventSource.Factory factory = EventSources.createFactory(this.okHttpClient);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(chatCompletion);
|
||||
Request request = new Request.Builder()
|
||||
.url(this.apiHost + "v1/chat/completions")
|
||||
@ -242,6 +244,7 @@ public class Chat2DBAIStreamClient {
|
||||
public FastChatEmbeddingResponse embeddings(FastChatEmbedding embedding) {
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(embedding);
|
||||
Request request = new Request.Builder()
|
||||
.url(this.apiHost + "v1/embeddings")
|
||||
|
@ -4,6 +4,7 @@ import ai.chat2db.server.tools.common.exception.ParamBusinessException;
|
||||
import ai.chat2db.server.web.api.controller.ai.claude.interceptor.ClaudeHeaderAuthorizationInterceptor;
|
||||
import ai.chat2db.server.web.api.controller.ai.claude.model.ClaudeChatMessage;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -167,6 +168,7 @@ public class ClaudeAiStreamClient {
|
||||
claudeChatMessage.setConversation_uuid(this.userId);
|
||||
EventSource.Factory factory = EventSources.createFactory(this.okHttpClient);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(claudeChatMessage);
|
||||
|
||||
Request request = new Request.Builder()
|
||||
|
@ -7,6 +7,7 @@ import ai.chat2db.server.web.api.controller.ai.fastchat.interceptor.FastChatHead
|
||||
import ai.chat2db.server.web.api.controller.ai.fastchat.model.FastChatCompletionsOptions;
|
||||
import ai.chat2db.server.web.api.controller.ai.fastchat.model.FastChatMessage;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.reactivex.Single;
|
||||
import lombok.Getter;
|
||||
@ -199,6 +200,7 @@ public class FastChatAIStreamClient {
|
||||
|
||||
EventSource.Factory factory = EventSources.createFactory(this.okHttpClient);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(chatCompletionsOptions);
|
||||
Request request = new Request.Builder()
|
||||
.url(apiHost)
|
||||
|
@ -4,6 +4,7 @@ import java.util.Objects;
|
||||
|
||||
import ai.chat2db.server.web.api.controller.ai.response.ChatCompletionResponse;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.unfbx.chatgpt.entity.chat.Message;
|
||||
import lombok.SneakyThrows;
|
||||
@ -54,6 +55,7 @@ public class OpenAIEventSourceListener extends EventSourceListener {
|
||||
return;
|
||||
}
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
// 读取Json
|
||||
ChatCompletionResponse completionResponse = mapper.readValue(data, ChatCompletionResponse.class);
|
||||
String text = completionResponse.getChoices().get(0).getDelta() == null
|
||||
|
@ -7,6 +7,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import ai.chat2db.server.tools.common.exception.ParamBusinessException;
|
||||
import ai.chat2db.server.web.api.controller.ai.rest.model.RestAiCompletion;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.unfbx.chatgpt.sse.ConsoleEventSourceListener;
|
||||
import lombok.Getter;
|
||||
@ -102,6 +103,7 @@ public class RestAiStreamClient {
|
||||
try {
|
||||
EventSource.Factory factory = EventSources.createFactory(this.okHttpClient);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(completion);
|
||||
Request request = new Request.Builder()
|
||||
.url(this.apiUrl)
|
||||
@ -128,6 +130,7 @@ public class RestAiStreamClient {
|
||||
}
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(completion);
|
||||
Request request = new Request.Builder()
|
||||
.url(this.apiUrl)
|
||||
|
@ -6,6 +6,7 @@ import ai.chat2db.server.web.api.controller.ai.fastchat.model.FastChatMessage;
|
||||
import ai.chat2db.server.web.api.controller.ai.tongyi.model.TongyiChatCompletionsOptions;
|
||||
import ai.chat2db.server.web.api.controller.ai.tongyi.model.TongyiChatMessage;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -192,6 +193,7 @@ public class TongyiChatAIStreamClient {
|
||||
|
||||
EventSource.Factory factory = EventSources.createFactory(this.okHttpClient);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(chatCompletionsOptions);
|
||||
Request request = new Request.Builder()
|
||||
.url(apiHost)
|
||||
|
@ -5,6 +5,7 @@ import ai.chat2db.server.web.api.controller.ai.fastchat.model.FastChatCompletion
|
||||
import ai.chat2db.server.web.api.controller.ai.fastchat.model.FastChatMessage;
|
||||
import ai.chat2db.server.web.api.controller.ai.wenxin.interceptor.AccessTokenInterceptor;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -179,6 +180,7 @@ public class WenxinAIStreamClient {
|
||||
|
||||
EventSource.Factory factory = EventSources.createFactory(this.okHttpClient);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(chatCompletionsOptions);
|
||||
Request request = new Request.Builder()
|
||||
.url(apiHost)
|
||||
|
@ -5,6 +5,7 @@ import ai.chat2db.server.web.api.controller.ai.fastchat.model.FastChatMessage;
|
||||
import ai.chat2db.server.web.api.controller.ai.zhipu.interceptor.ZhipuChatHeaderAuthorizationInterceptor;
|
||||
import ai.chat2db.server.web.api.controller.ai.zhipu.model.ZhipuChatCompletionsOptions;
|
||||
import cn.hutool.http.ContentType;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -201,6 +202,7 @@ public class ZhipuChatAIStreamClient {
|
||||
String requestId = String.valueOf(System.currentTimeMillis());
|
||||
completionsOptions.setRequestId(requestId);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
String requestBody = mapper.writeValueAsString(completionsOptions);
|
||||
|
||||
String url = this.apiHost + "/" + this.model + "/" + "sse-invoke";
|
||||
|
Reference in New Issue
Block a user