mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
feat(ActionCorrector): complete corrector's executing logic
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package work.slhaf.partner.module.modules.action.dispatcher.executor;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import lombok.val;
|
||||
import work.slhaf.partner.api.agent.factory.module.annotation.AgentSubModule;
|
||||
import work.slhaf.partner.api.agent.runtime.interaction.flow.abstracts.ActivateModel;
|
||||
import work.slhaf.partner.api.agent.runtime.interaction.flow.abstracts.AgentRunningSubModule;
|
||||
@@ -13,13 +15,33 @@ import work.slhaf.partner.module.modules.action.dispatcher.executor.entity.Corre
|
||||
public class ActionCorrector extends AgentRunningSubModule<CorrectorInput, CorrectorResult> implements ActivateModel {
|
||||
|
||||
@Override
|
||||
public CorrectorResult execute(CorrectorInput data) {
|
||||
return null;
|
||||
public CorrectorResult execute(CorrectorInput input) {
|
||||
val prompt = buildPrompt(input);
|
||||
val chatResponse = singleChat(prompt);
|
||||
return JSONObject.parseObject(chatResponse.getMessage(), CorrectorResult.class);
|
||||
}
|
||||
|
||||
private String buildPrompt(CorrectorInput input) {
|
||||
val prompt = new JSONObject();
|
||||
prompt.put("[行动来源]", input.getSource());
|
||||
prompt.put("[行动倾向]", input.getTendency());
|
||||
prompt.put("[行动描述]", input.getDescription());
|
||||
prompt.put("[行动原因]", input.getReason());
|
||||
|
||||
val messages = prompt.putArray("[近期对话]");
|
||||
messages.addAll(input.getRecentMessages());
|
||||
|
||||
val memory = prompt.putArray("[已激活记忆]");
|
||||
memory.addAll(input.getActivatedSlices());
|
||||
|
||||
val history = prompt.putArray("[已执行情况]");
|
||||
history.addAll(input.getHistory());
|
||||
return prompt.toJSONString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelKey() {
|
||||
return "";
|
||||
return "action_corrector";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,7 +93,8 @@ public class ActionExecutor extends AgentRunningSubModule<ActionExecutorInput, V
|
||||
|
||||
// 针对行动链进行修正,修正需要传入执行历史、行动目标等内容
|
||||
val correctorInput = assemblyHelper.buildCorrectorInput(actionData, userId);
|
||||
actionCorrector.execute(correctorInput);
|
||||
val correctorResult = actionCorrector.execute(correctorInput);
|
||||
// TODO 修正内容如何生效?以何种形式生效?
|
||||
} while (actionChain.size() > ++stageCount);
|
||||
|
||||
// 结束
|
||||
|
||||
Reference in New Issue
Block a user