Commit 2aac4fcd by 彭顺

fix: 5月22日招标智能体选项需求

parent 2b94c420
...@@ -9,6 +9,7 @@ import lombok.Data; ...@@ -9,6 +9,7 @@ import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.List; import java.util.List;
import java.util.Map;
@Schema(description = "管理后台 - AI 聊天消息发送 Request VO") @Schema(description = "管理后台 - AI 聊天消息发送 Request VO")
@Data @Data
...@@ -31,7 +32,8 @@ public class AiChatMessageSendReqVO { ...@@ -31,7 +32,8 @@ public class AiChatMessageSendReqVO {
private List<String> fileUrl; private List<String> fileUrl;
@Schema(description = "变量") @Schema(description = "变量")
private FastGPTOptions.Variables variables; private Map<String, Object> variables;
// private FastGPTOptions.Variables variables;
@Schema(description = "回复信息预设ID") @Schema(description = "回复信息预设ID")
private String responseChatItemId; private String responseChatItemId;
......
...@@ -53,10 +53,13 @@ public interface AiChatRoleMapper extends BaseMapperX<AiChatRoleDO> { ...@@ -53,10 +53,13 @@ public interface AiChatRoleMapper extends BaseMapperX<AiChatRoleDO> {
} }
default PageResult<AiChatRoleDO> selectPageByDept(AiChatRolePageReqVO reqVO, List<Long> userIds) { default PageResult<AiChatRoleDO> selectPageByDept(AiChatRolePageReqVO reqVO, List<Long> userIds) {
if (userIds == null || userIds.isEmpty()) {
return PageResult.empty(); // 返回空分页结果
}
return selectPage(reqVO, new LambdaQueryWrapperX<AiChatRoleDO>() return selectPage(reqVO, new LambdaQueryWrapperX<AiChatRoleDO>()
.likeIfPresent(AiChatRoleDO::getName, reqVO.getName()) .likeIfPresent(AiChatRoleDO::getName, reqVO.getName())
.eqIfPresent(AiChatRoleDO::getCategory, reqVO.getCategory()) .eqIfPresent(AiChatRoleDO::getCategory, reqVO.getCategory())
.in(AiChatRoleDO::getCreator, userIds) .inIfPresent(AiChatRoleDO::getCreator, userIds)
.orderByAsc(AiChatRoleDO::getSort)); .orderByAsc(AiChatRoleDO::getSort));
} }
......
...@@ -113,28 +113,28 @@ public class FastGPTApi { ...@@ -113,28 +113,28 @@ public class FastGPTApi {
} }
@JsonInclude(Include.NON_NULL) @JsonInclude(Include.NON_NULL)
public static record ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, String chatId, FastGPTOptions.Variables variables, String responseChatItemId, Float frequencyPenalty, Map<String, Integer> logitBias, Boolean logprobs, Integer topLogprobs, Integer maxTokens, Integer n, Float presencePenalty, ResponseFormat responseFormat, Integer seed, List<String> stop, Boolean stream, Float temperature, Float topP, List<FunctionTool> tools, Object toolChoice, String user) { public static record ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, String chatId, Map<String, Object> variables, String responseChatItemId, Float frequencyPenalty, Map<String, Integer> logitBias, Boolean logprobs, Integer topLogprobs, Integer maxTokens, Integer n, Float presencePenalty, ResponseFormat responseFormat, Integer seed, List<String> stop, Boolean stream, Float temperature, Float topP, List<FunctionTool> tools, Object toolChoice, String user) {
public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, Float temperature) { public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, Float temperature) {
this(messages, model, (String)null, (FastGPTOptions.Variables)null, (String)null, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, false, temperature, (Float)null, (List)null, (Object)null, (String)null); this(messages, model, (String)null, (Map<String, Object>)null, (String)null, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, false, temperature, (Float)null, (List)null, (Object)null, (String)null);
} }
public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, Float temperature, boolean stream) { public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, Float temperature, boolean stream) {
this(messages, model, (String)null, (FastGPTOptions.Variables)null, (String)null, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, stream, temperature, (Float)null, (List)null, (Object)null, (String)null); this(messages, model, (String)null, (Map<String, Object>)null, (String)null, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, stream, temperature, (Float)null, (List)null, (Object)null, (String)null);
} }
public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, List<FunctionTool> tools, Object toolChoice) { public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, List<FunctionTool> tools, Object toolChoice) {
this(messages, model, (String)null, (FastGPTOptions.Variables)null, (String)null, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, false, 0.8F, (Float)null, tools, toolChoice, (String)null); this(messages, model, (String)null, (Map<String, Object>)null, (String)null, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, false, 0.8F, (Float)null, tools, toolChoice, (String)null);
} }
public ChatCompletionRequest(List<ChatCompletionMessage> messages, Boolean stream) { public ChatCompletionRequest(List<ChatCompletionMessage> messages, Boolean stream) {
this(messages, (String)null, (String)null, (FastGPTOptions.Variables)null, (String)null, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, stream, (Float)null, (Float)null, (List)null, (Object)null, (String)null); this(messages, (String)null, (String)null, (Map<String, Object>)null, (String)null, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, stream, (Float)null, (Float)null, (List)null, (Object)null, (String)null);
} }
public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, String chatId, FastGPTOptions.Variables variables, String responseChatItemId, Boolean stream) { public ChatCompletionRequest(List<ChatCompletionMessage> messages, String model, String chatId, Map<String, Object> variables, String responseChatItemId, Boolean stream) {
this(messages, model, chatId, variables, responseChatItemId, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, stream, (Float)null, (Float)null, (List)null, (Object)null, (String)null); this(messages, model, chatId, variables, responseChatItemId, (Float)null, (Map)null, (Boolean)null, (Integer)null, (Integer)null, (Integer)null, (Float)null, (ResponseFormat)null, (Integer)null, (List)null, stream, (Float)null, (Float)null, (List)null, (Object)null, (String)null);
} }
public ChatCompletionRequest(@JsonProperty("messages") List<ChatCompletionMessage> messages, @JsonProperty("model") String model, @JsonProperty("chatId") String chatId, @JsonProperty("variables") FastGPTOptions.Variables variables, @JsonProperty("responseChatItemId") String responseChatItemId, @JsonProperty("frequency_penalty") Float frequencyPenalty, @JsonProperty("logit_bias") Map<String, Integer> logitBias, @JsonProperty("logprobs") Boolean logprobs, @JsonProperty("top_logprobs") Integer topLogprobs, @JsonProperty("max_tokens") Integer maxTokens, @JsonProperty("n") Integer n, @JsonProperty("presence_penalty") Float presencePenalty, @JsonProperty("response_format") ResponseFormat responseFormat, @JsonProperty("seed") Integer seed, @JsonProperty("stop") List<String> stop, @JsonProperty("stream") Boolean stream, @JsonProperty("temperature") Float temperature, @JsonProperty("top_p") Float topP, @JsonProperty("tools") List<FunctionTool> tools, @JsonProperty("tool_choice") Object toolChoice, @JsonProperty("user") String user) { public ChatCompletionRequest(@JsonProperty("messages") List<ChatCompletionMessage> messages, @JsonProperty("model") String model, @JsonProperty("chatId") String chatId, @JsonProperty("variables") Map<String, Object> variables, @JsonProperty("responseChatItemId") String responseChatItemId, @JsonProperty("frequency_penalty") Float frequencyPenalty, @JsonProperty("logit_bias") Map<String, Integer> logitBias, @JsonProperty("logprobs") Boolean logprobs, @JsonProperty("top_logprobs") Integer topLogprobs, @JsonProperty("max_tokens") Integer maxTokens, @JsonProperty("n") Integer n, @JsonProperty("presence_penalty") Float presencePenalty, @JsonProperty("response_format") ResponseFormat responseFormat, @JsonProperty("seed") Integer seed, @JsonProperty("stop") List<String> stop, @JsonProperty("stream") Boolean stream, @JsonProperty("temperature") Float temperature, @JsonProperty("top_p") Float topP, @JsonProperty("tools") List<FunctionTool> tools, @JsonProperty("tool_choice") Object toolChoice, @JsonProperty("user") String user) {
this.messages = messages; this.messages = messages;
this.model = model; this.model = model;
this.chatId = chatId; this.chatId = chatId;
...@@ -174,7 +174,7 @@ public class FastGPTApi { ...@@ -174,7 +174,7 @@ public class FastGPTApi {
} }
@JsonProperty("variables") @JsonProperty("variables")
public FastGPTOptions.Variables variables() { public Map<String, Object> variables() {
return this.variables; return this.variables;
} }
......
package cn.iocoder.yudao.framework.ai.core.model.fastgpt; package cn.iocoder.yudao.framework.ai.core.model.fastgpt;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.ArrayList;
import java.util.HashSet; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.ai.chat.prompt.ChatOptions; import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.ai.model.function.FunctionCallback; import org.springframework.ai.model.function.FunctionCallback;
import org.springframework.ai.model.function.FunctionCallingOptions; import org.springframework.ai.model.function.FunctionCallingOptions;
...@@ -22,7 +18,8 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions { ...@@ -22,7 +18,8 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions {
private String model; private String model;
@JsonProperty("variables") @JsonProperty("variables")
private Variables variables; private Map<String, Object> variables;
// private Variables variables;
@JsonProperty("chatId") @JsonProperty("chatId")
private String chatId; private String chatId;
...@@ -68,17 +65,30 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions { ...@@ -68,17 +65,30 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions {
@JsonProperty("responseChatItemId") @JsonProperty("responseChatItemId")
private String responseChatItemId; private String responseChatItemId;
@JsonInclude(Include.NON_NULL) // @JsonInclude(Include.NON_NULL)
public static record Variables(String scenarios) { // public static record Variables(String scenarios) {
public Variables(@JsonProperty("scenarios") String scenarios) { // public Variables(@JsonProperty("scenarios") String scenarios) {
this.scenarios = scenarios; // this.scenarios = scenarios;
} // }
//
@JsonProperty("scenarios") // @JsonProperty("scenarios")
public String scenarios() { // public String scenarios() {
return this.scenarios; // return this.scenarios;
} // }
} //
// @JsonUnwrapped
// private static Map<String, Object> extra = new HashMap<>();
//
// @JsonAnySetter
// public void setExtra(String key, Object value) {
// extra.put(key, value);
// }
//
// @JsonAnyGetter
// public Map<String, Object> getExtra() {
// return extra;
// }
// }
public FastGPTOptions() { public FastGPTOptions() {
} }
...@@ -95,11 +105,11 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions { ...@@ -95,11 +105,11 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions {
this.model = model; this.model = model;
} }
public Variables getVariables() { public Map<String, Object> getVariables() {
return this.variables; return this.variables;
} }
public void setVariables(Variables variables) { public void setVariables(Map<String, Object> variables) {
this.variables = variables; this.variables = variables;
} }
...@@ -469,7 +479,7 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions { ...@@ -469,7 +479,7 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions {
return this; return this;
} }
public Builder withVariables(Variables variables) { public Builder withVariables(Map<String, Object> variables) {
this.options.variables = variables; this.options.variables = variables;
return this; return this;
} }
......
...@@ -14,6 +14,8 @@ import org.springframework.ai.openai.OpenAiChatOptions; ...@@ -14,6 +14,8 @@ import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.ai.qianfan.QianFanChatOptions; import org.springframework.ai.qianfan.QianFanChatOptions;
import org.springframework.ai.zhipuai.ZhiPuAiChatOptions; import org.springframework.ai.zhipuai.ZhiPuAiChatOptions;
import java.util.Map;
/** /**
* Spring AI 工具类 * Spring AI 工具类
* *
...@@ -21,7 +23,7 @@ import org.springframework.ai.zhipuai.ZhiPuAiChatOptions; ...@@ -21,7 +23,7 @@ import org.springframework.ai.zhipuai.ZhiPuAiChatOptions;
*/ */
public class AiUtils { public class AiUtils {
public static ChatOptions buildChatOptions(AiPlatformEnum platform, String model, Double temperature, Integer maxTokens, String chatId, FastGPTOptions.Variables variables, String chatItemId) { public static ChatOptions buildChatOptions(AiPlatformEnum platform, String model, Double temperature, Integer maxTokens, String chatId, Map<String, Object> variables, String chatItemId) {
Float temperatureF = temperature != null ? temperature.floatValue() : null; Float temperatureF = temperature != null ? temperature.floatValue() : null;
//noinspection EnhancedSwitchMigration //noinspection EnhancedSwitchMigration
switch (platform) { switch (platform) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment