6 小时以前 9bad721754fe8bbe2e5f459d0706e0fefac569f3
yudao-module-ai/src/main/java/cn/iocoder/yudao/module/ai/framework/ai/config/AiAutoConfiguration.java
@@ -20,6 +20,8 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import java.time.Duration;
/**
 * 超级管理员 AI 自动配置
 *
@@ -58,13 +60,25 @@
    // ========== 通义千问 Chat(通过 OpenAI 兼容接口)==========
    public static OpenAiChatModel buildTongYiChatModel(String apiKey, String model) {
    /**
     * 构建通义千问 Chat 模型
     *
     * @param temperature 采样温度,为 null 时用 0.7(与历史行为一致)
     * @param maxTokens   单次回复的最大 token 数,为 null 时沿用模型默认值。
     *                    不传会让长文档的输出被静默截断,表现为「JSON 尾部缺失、解析失败」
     * @param timeout     单次调用超时。不设超时的话,模型排队时请求会一直挂到 TCP 层超时
     */
    public static OpenAiChatModel buildTongYiChatModel(String apiKey, String model,
                                                       Double temperature, Integer maxTokens,
                                                       Duration timeout) {
        return OpenAiChatModel.builder()
                .options(OpenAiChatOptions.builder()
                        .baseUrl(DASHSCOPE_BASE_URL)
                        .apiKey(apiKey)
                        .model(StrUtil.blankToDefault(model, "qwen-plus"))
                        .temperature(0.7)
                        .temperature(temperature != null ? temperature : 0.7)
                        .maxTokens(maxTokens)
                        .timeout(timeout)
                        .build())
                .toolCallingManager(ToolCallingManager.builder().build())
                .build();