参考黑马的Langchain4j
This commit is contained in:
31
src/test/java/com/cst/langchain4jheima/AppTest.java
Normal file
31
src/test/java/com/cst/langchain4jheima/AppTest.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.cst.langchain4jheima;
|
||||
|
||||
import dev.langchain4j.model.openai.OpenAiChatModel;
|
||||
|
||||
/**
|
||||
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
|
||||
* Date: 2025/8/4 9:55
|
||||
**/
|
||||
public class AppTest {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
|
||||
public AppTest( String testName )
|
||||
{
|
||||
System.out.println( "chatModel Hello World!" );
|
||||
// 构建chatmodel对象
|
||||
OpenAiChatModel chatModel = OpenAiChatModel.builder()
|
||||
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
|
||||
.baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
|
||||
.modelName("qwen-plus")
|
||||
.logRequests(true) // 输出请求大模型的日志
|
||||
.logResponses(true)
|
||||
.build();
|
||||
String chat = chatModel.chat("2008年奥运会,哪个国际金牌最多?");
|
||||
System.out.println(chat);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.cst.langchain4jheima;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class Langchain4jHeima20250803ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user