commit
aef8a5fc6e
@ -0,0 +1,21 @@
|
|||||||
|
target/
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
release.properties
|
||||||
|
/.idea
|
||||||
|
*.iml
|
||||||
|
/.settings
|
||||||
|
/bin
|
||||||
|
/gen
|
||||||
|
/build
|
||||||
|
/gradle
|
||||||
|
/classes
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
*.gradle
|
||||||
|
gradlew
|
||||||
|
local.properties
|
||||||
|
node_modules/
|
||||||
|
data/
|
@ -0,0 +1,12 @@
|
|||||||
|
package xyz.wbsite.ai;
|
||||||
|
|
||||||
|
import com.agentsflex.llm.openai.OpenAILlm;
|
||||||
|
import com.agentsflex.llm.openai.OpenAILlmConfig;
|
||||||
|
|
||||||
|
public class 入门 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
OpenAILlm llm = new OpenAILlm(默认配置.openAiLlmConfig());
|
||||||
|
String response = llm.chat("请问你叫什么名字");
|
||||||
|
System.out.println(response);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package xyz.wbsite.ai;
|
||||||
|
|
||||||
|
import com.agentsflex.core.llm.ChatContext;
|
||||||
|
import com.agentsflex.core.llm.StreamResponseListener;
|
||||||
|
import com.agentsflex.core.llm.response.AiMessageResponse;
|
||||||
|
import com.agentsflex.core.message.SystemMessage;
|
||||||
|
import com.agentsflex.core.prompt.TextPrompt;
|
||||||
|
import com.agentsflex.llm.openai.OpenAILlm;
|
||||||
|
|
||||||
|
public class 流式对话 {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
OpenAILlm llm = new OpenAILlm(默认配置.openAiLlmConfig());
|
||||||
|
TextPrompt textPrompt = new TextPrompt();
|
||||||
|
textPrompt.setContent("你好用英文怎么说");
|
||||||
|
textPrompt.setSystemMessage(new SystemMessage("你是一个专业的翻译"));
|
||||||
|
llm.chatStream(textPrompt, new StreamResponseListener() {
|
||||||
|
@Override
|
||||||
|
public void onMessage(ChatContext chatContext, AiMessageResponse aiMessageResponse) {
|
||||||
|
System.out.print(aiMessageResponse.getMessage().getContent());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package xyz.wbsite.ai;
|
||||||
|
|
||||||
|
import com.agentsflex.llm.openai.OpenAILlmConfig;
|
||||||
|
|
||||||
|
public class 默认配置 {
|
||||||
|
|
||||||
|
public static OpenAILlmConfig openAiLlmConfig(){
|
||||||
|
OpenAILlmConfig config = new OpenAILlmConfig();
|
||||||
|
config.setEndpoint("http://192.168.88.105:11434");
|
||||||
|
config.setApiKey("1");
|
||||||
|
config.setModel("qwen2.5:0.5b");
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static List<Document> getDocuments() {
|
||||||
|
// return CollUtil.newArrayList(
|
||||||
|
// Document.from("人往往在做梦的时候会打呼噜"),
|
||||||
|
// Document.from("小猪在睡觉的时候会扭屁股"),
|
||||||
|
// Document.from("有一只蟑螂在床底下跳舞"),
|
||||||
|
// Document.from("小狗在睡觉的时候会磨牙"),
|
||||||
|
// Document.from("我家的小鸡喜欢吃虫子")
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
}
|
Loading…
Reference in new issue