mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
【新增】AI:增加 ollama 模型的接入
This commit is contained in:
@ -6,6 +6,7 @@ import org.springframework.ai.chat.StreamingChatClient;
|
||||
import org.springframework.ai.models.tongyi.QianWenChatClient;
|
||||
import org.springframework.ai.models.xinghuo.XingHuoChatClient;
|
||||
import org.springframework.ai.models.yiyan.YiYanChatClient;
|
||||
import org.springframework.ai.ollama.OllamaChatClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -36,12 +37,17 @@ public class AiChatClientFactory {
|
||||
|
||||
// TODO yunai 要不再加一个接口,让他们拥有 ChatClient、StreamingChatClient 功能
|
||||
public StreamingChatClient getStreamingChatClient(AiPlatformEnum platformEnum) {
|
||||
// if (true) {
|
||||
// return applicationContext.getBean(OllamaChatClient.class);
|
||||
// }
|
||||
if (AiPlatformEnum.QIAN_WEN == platformEnum) {
|
||||
return applicationContext.getBean(QianWenChatClient.class);
|
||||
} else if (AiPlatformEnum.YI_YAN == platformEnum) {
|
||||
return applicationContext.getBean(YiYanChatClient.class);
|
||||
} else if (AiPlatformEnum.XING_HUO == platformEnum) {
|
||||
return applicationContext.getBean(XingHuoChatClient.class);
|
||||
} else if (AiPlatformEnum.OLLAMA == platformEnum) {
|
||||
return applicationContext.getBean(OllamaChatClient.class);
|
||||
}
|
||||
throw new IllegalArgumentException("不支持的 chat client!");
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class AiChatServiceImpl implements AiChatService {
|
||||
// 1.1 校验对话存在
|
||||
AiChatConversationDO conversation = chatConversationService.validateExists(sendReqVO.getConversationId());
|
||||
if (ObjUtil.notEqual(conversation.getUserId(), userId)) {
|
||||
throw exception(CHAT_CONVERSATION_NOT_EXISTS);
|
||||
throw exception(CHAT_CONVERSATION_NOT_EXISTS); // TODO 芋艿:异常情况的对接;
|
||||
}
|
||||
// 1.2 校验模型
|
||||
AiChatModelDO model = chatModalService.validateChatModel(conversation.getModelId());
|
||||
|
Reference in New Issue
Block a user