🚀 PIG AI 新版来袭:AI能力全面升级! 点击了解一下?
qwen-turbo
<dependency> <groupId>dev.langchain4j</groupId> <artifactId>langchain4j-open-ai-spring-boot-starter</artifactId> </dependency> <!-- 加载bom 后,所有langchain4j引用不需要加版本号 --> <dependencyManagement> <dependencies> <dependency> <groupId>dev.langchain4j</groupId> <artifactId>langchain4j-bom</artifactId> <version>1.0.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
application.yml
langchain4j: open-ai: chat-model: # 课程测试 KEY,需要更换为实际可用 KEY api-key: sk-xx model-name: qwen-turbo # 百炼兼容OpenAI接口规范,base_url为https://dashscope.aliyuncs.com/compatible-mode/v1 base-url: https://dashscope.aliyuncs.com/compatible-mode/v1
package com.pig4cloud.ai.langchain4j01simple; import dev.langchain4j.model.chat.ChatModel; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class Langchain4j01simpleApplicationTests { @Autowired private ChatModel chatModel; /** * 测试ChatModel基本功能 * 验证ChatModel是否能正确响应简单的问候语"你好" */ @Test void testBasicChatModelResponse() { String chatted = chatModel.chat("你好"); System.out.println(chatted); } }