This commit is contained in:
2025-08-27 19:58:34 +08:00
parent cd1f0b4ea0
commit 244b27e0f5

View File

@@ -0,0 +1,71 @@
package com.agentsflex.core.prompt;
import com.agentsflex.core.llm.functions.Function;
import com.agentsflex.core.message.HumanMessage;
import com.agentsflex.core.message.Message;
import com.agentsflex.core.message.SystemMessage;
import java.util.ArrayList;
import java.util.List;
public class FunctionPrompt extends Prompt {
private SystemMessage systemMessage;
private HumanMessage humanMessage;
private boolean autoCall = true;
public FunctionPrompt(String message, Class<?> functionsClass) {
this.humanMessage = new HumanMessage(message);
this.humanMessage.addFunctions(functionsClass);
}
public FunctionPrompt(String message, List<Function> functions) {
this.humanMessage = new HumanMessage(message);
this.humanMessage.addFunctions(functions);
}
public SystemMessage getSystemMessage() {
return systemMessage;
}
public void setSystemMessage(SystemMessage systemMessage) {
this.systemMessage = systemMessage;
}
public HumanMessage getHumanMessage() {
return humanMessage;
}
public void setHumanMessage(HumanMessage humanMessage) {
this.humanMessage = humanMessage;
}
public boolean isAutoCall() {
return autoCall;
}
public void setAutoCall(boolean autoCall) {
this.autoCall = autoCall;
}
@Override
public List<Message> toMessages() {
List<Message> messages = new ArrayList<>();
if (systemMessage != null) {
messages.add(0, systemMessage);
}
messages.add(humanMessage);
return messages;
}
@Override
public String toString() {
return "FunctionPrompt{" +
"systemMessage=" + systemMessage +
", humanMessage=" + humanMessage +
", autoCall=" + autoCall +
", metadataMap=" + metadataMap +
'}';
}
}