Commit a44628e436b0bb3d9df60587617da81ec204aad0
1 parent
29dc77fc
AI:code review chat 部分的代码(qianwen)
Showing
8 changed files
with
18 additions
and
2 deletions
yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/ErrorCodeConstants.java
| @@ -11,6 +11,7 @@ public interface ErrorCodeConstants { | @@ -11,6 +11,7 @@ public interface ErrorCodeConstants { | ||
| 11 | 11 | ||
| 12 | // ========== 模块 ai 错误码区间 [1-022-000-000 ~ 1-023-000-000) ========== | 12 | // ========== 模块 ai 错误码区间 [1-022-000-000 ~ 1-023-000-000) ========== |
| 13 | 13 | ||
| 14 | + // TODO @fansili:1)类注释不太对;2)中英文之间,有个空格;例如说 AI 模型 | ||
| 14 | ErrorCode AI_MODULE_NOT_SUPPORTED = new ErrorCode(1_022_000_000, "AI模型暂不支持!"); | 15 | ErrorCode AI_MODULE_NOT_SUPPORTED = new ErrorCode(1_022_000_000, "AI模型暂不支持!"); |
| 15 | 16 | ||
| 16 | } | 17 | } |
yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/AiModelEnum.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.ai.enums; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.ai.enums; | ||
| 2 | 2 | ||
| 3 | import lombok.Getter; | 3 | import lombok.Getter; |
| 4 | 4 | ||
| 5 | +// TODO @fansili:1)类注释要加下;2)author 和 time 用 javadoc,@author 和 @since;3)@AllArgsConstructor 使用这个注解,去掉构造方法;4)value 改成 model 字段,然后注释都写下哈;5)message 改成 name,然后注释都写下哈 | ||
| 5 | /** | 6 | /** |
| 6 | * author: fansili | 7 | * author: fansili |
| 7 | * time: 2024/3/4 12:36 | 8 | * time: 2024/3/4 12:36 |
| @@ -19,7 +20,9 @@ public enum AiModelEnum { | @@ -19,7 +20,9 @@ public enum AiModelEnum { | ||
| 19 | this.message = message; | 20 | this.message = message; |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 23 | + // TODO @fan | ||
| 22 | private String value; | 24 | private String value; |
| 23 | 25 | ||
| 24 | private String message; | 26 | private String message; |
| 27 | + | ||
| 25 | } | 28 | } |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/ChatController.java
| @@ -26,6 +26,7 @@ import reactor.core.publisher.Flux; | @@ -26,6 +26,7 @@ import reactor.core.publisher.Flux; | ||
| 26 | import java.util.Scanner; | 26 | import java.util.Scanner; |
| 27 | import java.util.function.Consumer; | 27 | import java.util.function.Consumer; |
| 28 | 28 | ||
| 29 | +// TODO @fansili:有了 swagger 注释,就不用类注释了 | ||
| 29 | /** | 30 | /** |
| 30 | * AI模块 | 31 | * AI模块 |
| 31 | * | 32 | * |
yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/controller/admin/vo/AiChatReqVO.java
| @@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema; | @@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | import jakarta.validation.constraints.NotNull; | 5 | import jakarta.validation.constraints.NotNull; |
| 6 | import lombok.Data; | 6 | import lombok.Data; |
| 7 | 7 | ||
| 8 | +// TODO @fansili 1)swagger 注释不太对;2)有了 swagger 注释,就不用类注释了 | ||
| 8 | /** | 9 | /** |
| 9 | * ai 聊天 req | 10 | * ai 聊天 req |
| 10 | * | 11 | * |
yudao-module-ai/yudao-module-ai-biz/src/main/resources/application.properties
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatqianwen/QianWenApi.java
| @@ -9,6 +9,7 @@ import org.springframework.http.HttpStatusCode; | @@ -9,6 +9,7 @@ import org.springframework.http.HttpStatusCode; | ||
| 9 | import org.springframework.http.ResponseEntity; | 9 | import org.springframework.http.ResponseEntity; |
| 10 | import reactor.core.publisher.Flux; | 10 | import reactor.core.publisher.Flux; |
| 11 | 11 | ||
| 12 | +// TODO @fansili:是不是挪到 api 包里?按照 spring ai 的结构;根目录只放 client 和 options | ||
| 12 | /** | 13 | /** |
| 13 | * 阿里 通义千问 | 14 | * 阿里 通义千问 |
| 14 | * | 15 | * |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/chatqianwen/QianWenChatClient.java
| @@ -29,7 +29,7 @@ import java.util.stream.Collectors; | @@ -29,7 +29,7 @@ import java.util.stream.Collectors; | ||
| 29 | * time: 2024/3/13 21:06 | 29 | * time: 2024/3/13 21:06 |
| 30 | */ | 30 | */ |
| 31 | @Slf4j | 31 | @Slf4j |
| 32 | -public class QianWenChatClient implements ChatClient, StreamingChatClient { | 32 | +public class QianWenChatClient implements ChatClient, StreamingChatClient { |
| 33 | 33 | ||
| 34 | private QianWenApi qianWenApi; | 34 | private QianWenApi qianWenApi; |
| 35 | 35 | ||
| @@ -44,6 +44,7 @@ public class QianWenChatClient implements ChatClient, StreamingChatClient { | @@ -44,6 +44,7 @@ public class QianWenChatClient implements ChatClient, StreamingChatClient { | ||
| 44 | this.qianWenOptions = qianWenOptions; | 44 | this.qianWenOptions = qianWenOptions; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | + // TODO @fansili:看看咋公用出来,允许传入类似异常之类的参数; | ||
| 47 | public final RetryTemplate retryTemplate = RetryTemplate.builder() | 48 | public final RetryTemplate retryTemplate = RetryTemplate.builder() |
| 48 | // 最大重试次数 10 | 49 | // 最大重试次数 10 |
| 49 | .maxAttempts(10) | 50 | .maxAttempts(10) |
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/package-info.java
| 1 | /** | 1 | /** |
| 2 | * author: fansili | 2 | * author: fansili |
| 3 | * time: 2024/3/12 20:29 | 3 | * time: 2024/3/12 20:29 |
| 4 | + * | ||
| 5 | + * 1. org.springframework.ai:包括 chat、image、model、parser、util 部分 | ||
| 6 | + * | ||
| 7 | + * 2. yudao.framework.models | ||
| 8 | + * \qianwen 通义千问 | ||
| 9 | + * \yiyan 文心一言 | ||
| 10 | + * \xinghuo 星火 | ||
| 11 | + * \midjourney | ||
| 4 | */ | 12 | */ |
| 5 | package cn.iocoder.yudao.framework.ai; | 13 | package cn.iocoder.yudao.framework.ai; |
| 6 | \ No newline at end of file | 14 | \ No newline at end of file |