|
|
|
@ -29,11 +29,11 @@ public class Main {
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
// testSimpleChat(args);
|
|
|
|
|
// testStreamChat(args);
|
|
|
|
|
testTool(args);
|
|
|
|
|
// testTool(args);
|
|
|
|
|
testRagChat(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void testSimpleChat(String[] args) {
|
|
|
|
|
|
|
|
|
|
ChatLanguageModel model = OllamaChatModel.builder()
|
|
|
|
|
.baseUrl("http://36.138.207.178:11434")
|
|
|
|
|
.modelName("deepseek-r1:32B")
|
|
|
|
@ -51,7 +51,24 @@ public class Main {
|
|
|
|
|
.build();
|
|
|
|
|
ChatResponse chatResponse = model.chat(build);
|
|
|
|
|
System.out.println(chatResponse.aiMessage().text());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void testRagChat(String[] args) {
|
|
|
|
|
ChatLanguageModel model = OllamaChatModel.builder()
|
|
|
|
|
.baseUrl("http://36.138.207.178:11434")
|
|
|
|
|
.modelName("deepseek-r1:32B")
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
ChatRequest build = ChatRequest.builder()
|
|
|
|
|
.messages(new ChatMessage[]{
|
|
|
|
|
SystemMessage.from("你需要使用文档内容对用户提出的问题进行回复,这点非常重要。\n" +
|
|
|
|
|
"当用户提出的问题无法根据文档内容进行回复时,回复不知道即可。请明确说明,你的答案是否是从文档中获取的。\n" +
|
|
|
|
|
"文档内容如下:小王和小吴是情侣关系,他们两个年龄一样都是20岁,小王有一辆大众牌小轿车,小吴有一辆雅迪电动车。"),
|
|
|
|
|
UserMessage.from("小王的车是什么牌子")
|
|
|
|
|
})
|
|
|
|
|
.build();
|
|
|
|
|
ChatResponse chatResponse = model.chat(build);
|
|
|
|
|
System.out.println(chatResponse.aiMessage().text());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void testStreamChat(String[] args) {
|
|
|
|
|