初始化

This commit is contained in:
2026-02-22 18:55:40 +08:00
commit 8392cdd861
496 changed files with 45020 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.easyagents</groupId>
<artifactId>easy-agents-parent</artifactId>
<version>${revision}</version>
</parent>
<name>easy-agents-support</name>
<artifactId>easy-agents-support</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.easyagents</groupId>
<artifactId>easy-agents-flow</artifactId>
</dependency>
<dependency>
<groupId>com.easyagents</groupId>
<artifactId>easy-agents-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,69 @@
package com.easyagents.flow.support.provider;
import com.easyagents.core.message.AiMessage;
import com.easyagents.core.message.SystemMessage;
import com.easyagents.core.model.chat.ChatModel;
import com.easyagents.core.model.chat.response.AiMessageResponse;
import com.easyagents.core.prompt.SimplePrompt;
import com.easyagents.flow.core.chain.Chain;
import com.easyagents.flow.core.llm.Llm;
import com.easyagents.flow.core.node.LlmNode;
import com.easyagents.flow.core.util.StringUtil;
import java.util.List;
public class EasyAgentsLlm implements Llm {
private ChatModel chatModel;
public ChatModel getChatModel() {
return chatModel;
}
public void setChatModel(ChatModel chatModel) {
this.chatModel = chatModel;
}
@Override
public String chat(MessageInfo messageInfo, ChatOptions options, LlmNode llmNode, Chain chain) {
SimplePrompt prompt = new SimplePrompt(messageInfo.getMessage());
// 系统提示词
if (StringUtil.hasText(messageInfo.getSystemMessage())) {
prompt.setSystemMessage(SystemMessage.of(messageInfo.getSystemMessage()));
}
// 图片
List<String> images = messageInfo.getImages();
if (images != null && !images.isEmpty()) {
for (String image : images) {
prompt.addImageUrl(image);
}
}
com.easyagents.core.model.chat.ChatOptions chatOptions = new com.easyagents.core.model.chat.ChatOptions();
chatOptions.setSeed(options.getSeed());
chatOptions.setTemperature(options.getTemperature());
chatOptions.setTopP(options.getTopP());
chatOptions.setTopK(options.getTopK());
chatOptions.setMaxTokens(options.getMaxTokens());
chatOptions.setStop(options.getStop());
AiMessageResponse response = chatModel.chat(prompt, chatOptions);
if (response == null) {
throw new RuntimeException("EasyAgentsLlm can not get response!");
}
if (response.isError()) {
throw new RuntimeException("EasyAgentsLlm error: " + response.getErrorMessage());
}
AiMessage aiMessage = response.getMessage();
if (aiMessage != null) {
return aiMessage.getContent();
}
throw new RuntimeException("EasyAgentsLlm can not get aiMessage!");
}
}