diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/config/AiChatClientFactory.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/config/AiChatClientFactory.java
index e15eff5904..f93cdc9c7c 100644
--- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/config/AiChatClientFactory.java
+++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/config/AiChatClientFactory.java
@@ -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!");
}
diff --git a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatServiceImpl.java b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatServiceImpl.java
index 1ab160bfc1..6a6febfba1 100644
--- a/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatServiceImpl.java
+++ b/yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/impl/AiChatServiceImpl.java
@@ -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());
diff --git a/yudao-module-ai/yudao-spring-boot-starter-ai/pom.xml b/yudao-module-ai/yudao-spring-boot-starter-ai/pom.xml
index 2188ad9085..5efa911263 100644
--- a/yudao-module-ai/yudao-spring-boot-starter-ai/pom.xml
+++ b/yudao-module-ai/yudao-spring-boot-starter-ai/pom.xml
@@ -24,6 +24,12 @@
1.0.3
+
+ io.springboot.ai
+ spring-ai-ollama-spring-boot-starter
+ 1.0.3
+
+
cn.iocoder.boot
yudao-common
diff --git a/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/enums/AiPlatformEnum.java b/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/enums/AiPlatformEnum.java
index 590797d175..e9e1f418e2 100644
--- a/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/enums/AiPlatformEnum.java
+++ b/yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/core/enums/AiPlatformEnum.java
@@ -1,11 +1,8 @@
package cn.iocoder.yudao.framework.ai.core.enums;
-import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;
-import java.util.List;
-
// TODO 芋艿:这块,看看要不要调整下;
/**
* ai 模型平台
@@ -17,29 +14,31 @@ import java.util.List;
@AllArgsConstructor
public enum AiPlatformEnum {
+ OPENAI("OpenAI", "OpenAI"),
+ OLLAMA("dall", "dall"),
+
YI_YAN("yiyan", "一言"),
QIAN_WEN("qianwen", "千问"),
XING_HUO("xinghuo", "星火"),
- OPENAI("OpenAI", "OpenAI"),
OPEN_AI_DALL("dall", "dall"),
- MIDJOURNEY("midjourney", "midjourney"),
+ MIDJOURNEY("Ollama", "Ollama"),
;
- private String platform;
- private String name;
+ private final String platform;
+ private final String name;
- public static List CHAT_PLATFORM_LIST = Lists.newArrayList(
- AiPlatformEnum.YI_YAN,
- AiPlatformEnum.QIAN_WEN,
- AiPlatformEnum.XING_HUO,
- AiPlatformEnum.OPENAI
- );
-
- public static List IMAGE_PLATFORM_LIST = Lists.newArrayList(
- AiPlatformEnum.OPEN_AI_DALL,
- AiPlatformEnum.MIDJOURNEY
- );
+// public static List CHAT_PLATFORM_LIST = Lists.newArrayList(
+// AiPlatformEnum.YI_YAN,
+// AiPlatformEnum.QIAN_WEN,
+// AiPlatformEnum.XING_HUO,
+// AiPlatformEnum.OPENAI
+// );
+//
+// public static List IMAGE_PLATFORM_LIST = Lists.newArrayList(
+// AiPlatformEnum.OPEN_AI_DALL,
+// AiPlatformEnum.MIDJOURNEY
+// );
public static AiPlatformEnum validatePlatform(String platform) {
for (AiPlatformEnum platformEnum : AiPlatformEnum.values()) {
diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml
index 6cb5386e3d..886644e74c 100644
--- a/yudao-server/src/main/resources/application.yaml
+++ b/yudao-server/src/main/resources/application.yaml
@@ -142,6 +142,14 @@ spring:
listener:
missing-topics-fatal: false # 消费监听接口监听的主题不存在时,默认会报错。所以通过设置为 false ,解决报错
+--- #################### AI 相关配置 ####################
+
+spring.ai:
+ ollama:
+ base-url: http://127.0.0.1:11434
+ chat:
+ model: llama3
+
--- #################### 芋道相关配置 ####################
yudao: