mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 16:35:06 +08:00
【新增】AI:openai 接入的配置调整
This commit is contained in:
@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.ai.core.model.tongyi.QianWenChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatClient;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.yiyan.YiYanChatClient;
|
||||
import org.springframework.ai.ollama.OllamaChatClient;
|
||||
import org.springframework.ai.openai.OpenAiChatClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -48,6 +49,8 @@ public class AiChatClientFactory {
|
||||
return applicationContext.getBean(XingHuoChatClient.class);
|
||||
} else if (AiPlatformEnum.OLLAMA == platformEnum) {
|
||||
return applicationContext.getBean(OllamaChatClient.class);
|
||||
} else if (AiPlatformEnum.OPENAI == platformEnum) {
|
||||
return applicationContext.getBean(OpenAiChatClient.class);
|
||||
}
|
||||
throw new IllegalArgumentException("不支持的 chat client!");
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.ai.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.ai.controller.admin.chat.vo.message.AiChatMessageSendRespVO;
|
||||
@ -123,7 +124,8 @@ public class AiChatServiceImpl implements AiChatService {
|
||||
// 3.3 流式返回
|
||||
StringBuffer contentBuffer = new StringBuffer();
|
||||
return streamResponse.map(response -> {
|
||||
String newContent = response.getResult().getOutput().getContent();
|
||||
String newContent = response.getResult() != null ? response.getResult().getOutput().getContent() : null;
|
||||
newContent = StrUtil.nullToDefault(newContent, ""); // 避免 null 的 情况
|
||||
contentBuffer.append(newContent);
|
||||
// 响应结果
|
||||
return new AiChatMessageSendRespVO().setSend(BeanUtils.toBean(userMessage, AiChatMessageSendRespVO.Message.class))
|
||||
@ -152,7 +154,8 @@ public class AiChatServiceImpl implements AiChatService {
|
||||
|
||||
// 2. 构建 ChatOptions 对象 TODO 芋艿:临时注释掉;等文心一言兼容了;
|
||||
// ChatOptions chatOptions = ChatOptionsBuilder.builder().withTemperature(conversation.getTemperature().floatValue()).build();
|
||||
return new Prompt(chatMessages, null);
|
||||
// return new Prompt(chatMessages, null);
|
||||
return new Prompt(chatMessages);
|
||||
}
|
||||
|
||||
private AiChatMessageDO createChatMessage(Long conversationId, AiChatModelDO model,
|
||||
|
@ -1,11 +0,0 @@
|
||||
# open ai TODO @fansili??????????????
|
||||
|
||||
# openAI https://openai.com/
|
||||
spring.ai.openai.api-key=${OPEN_AI_KEY}
|
||||
spring.ai.openai.chat.options.model=gpt-3.5-turbo
|
||||
spring.ai.openai.chat.options.temperature=0.7
|
||||
#spring.ai.vectorstore.milvus.client.connect-timeout-ms=50000
|
||||
#spring.ai.vectorstore.milvus.client.keep-alive-timeout-ms=50000
|
||||
#spring.ai.vectorstore.milvus.client.keep-alive-time-ms=80000
|
||||
#spring.ai.vectorstore.pinecone.server-side-timeout=100s
|
||||
|
Reference in New Issue
Block a user