Commit 2aac4fcd by 彭顺

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

parent 2b94c420
......@@ -9,6 +9,7 @@ import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
@Schema(description = "管理后台 - AI 聊天消息发送 Request VO")
@Data
......@@ -31,7 +32,8 @@ public class AiChatMessageSendReqVO {
private List<String> fileUrl;
@Schema(description = "变量")
private FastGPTOptions.Variables variables;
private Map<String, Object> variables;
// private FastGPTOptions.Variables variables;
@Schema(description = "回复信息预设ID")
private String responseChatItemId;
......
......@@ -53,10 +53,13 @@ public interface AiChatRoleMapper extends BaseMapperX<AiChatRoleDO> {
}
default PageResult<AiChatRoleDO> selectPageByDept(AiChatRolePageReqVO reqVO, List<Long> userIds) {
if (userIds == null || userIds.isEmpty()) {
return PageResult.empty(); // 返回空分页结果
}
return selectPage(reqVO, new LambdaQueryWrapperX<AiChatRoleDO>()
.likeIfPresent(AiChatRoleDO::getName, reqVO.getName())
.eqIfPresent(AiChatRoleDO::getCategory, reqVO.getCategory())
.in(AiChatRoleDO::getCreator, userIds)
.inIfPresent(AiChatRoleDO::getCreator, userIds)
.orderByAsc(AiChatRoleDO::getSort));
}
......
......@@ -113,28 +113,28 @@ public class FastGPTApi {
}
@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) {
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) {
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) {
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) {
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);
}
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.model = model;
this.chatId = chatId;
......@@ -174,7 +174,7 @@ public class FastGPTApi {
}
@JsonProperty("variables")
public FastGPTOptions.Variables variables() {
public Map<String, Object> variables() {
return this.variables;
}
......
package cn.iocoder.yudao.framework.ai.core.model.fastgpt;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.ai.model.function.FunctionCallback;
import org.springframework.ai.model.function.FunctionCallingOptions;
......@@ -22,7 +18,8 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions {
private String model;
@JsonProperty("variables")
private Variables variables;
private Map<String, Object> variables;
// private Variables variables;
@JsonProperty("chatId")
private String chatId;
......@@ -68,17 +65,30 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions {
@JsonProperty("responseChatItemId")
private String responseChatItemId;
@JsonInclude(Include.NON_NULL)
public static record Variables(String scenarios) {
public Variables(@JsonProperty("scenarios") String scenarios) {
this.scenarios = scenarios;
}
@JsonProperty("scenarios")
public String scenarios() {
return this.scenarios;
}
}
// @JsonInclude(Include.NON_NULL)
// public static record Variables(String scenarios) {
// public Variables(@JsonProperty("scenarios") String scenarios) {
// this.scenarios = scenarios;
// }
//
// @JsonProperty("scenarios")
// public String 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() {
}
......@@ -95,11 +105,11 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions {
this.model = model;
}
public Variables getVariables() {
public Map<String, Object> getVariables() {
return this.variables;
}
public void setVariables(Variables variables) {
public void setVariables(Map<String, Object> variables) {
this.variables = variables;
}
......@@ -469,7 +479,7 @@ public class FastGPTOptions implements FunctionCallingOptions, ChatOptions {
return this;
}
public Builder withVariables(Variables variables) {
public Builder withVariables(Map<String, Object> variables) {
this.options.variables = variables;
return this;
}
......
......@@ -14,6 +14,8 @@ import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.ai.qianfan.QianFanChatOptions;
import org.springframework.ai.zhipuai.ZhiPuAiChatOptions;
import java.util.Map;
/**
* Spring AI 工具类
*
......@@ -21,7 +23,7 @@ import org.springframework.ai.zhipuai.ZhiPuAiChatOptions;
*/
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;
//noinspection EnhancedSwitchMigration
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