mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
refactor(context): add PartnerRunningFlowContext factories for user/self source and update adapter creation
This commit is contained in:
@@ -32,11 +32,9 @@ public class PartnerInteractionAdapter extends AgentInteractionAdapter<PartnerIn
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected PartnerRunningFlowContext parseInputData(PartnerInputData inputData) {
|
protected PartnerRunningFlowContext parseInputData(PartnerInputData inputData) {
|
||||||
return new PartnerRunningFlowContext(
|
return PartnerRunningFlowContext.Companion.fromUser(inputData.getUserInfo(),
|
||||||
inputData.getUserInfo(),
|
|
||||||
inputData.getContent(),
|
inputData.getContent(),
|
||||||
inputData.getPlatform(),
|
inputData.getPlatform(),
|
||||||
inputData.getUserNickName()
|
inputData.getUserNickName());
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,16 +6,45 @@ import work.slhaf.partner.module.common.entity.AppendPromptData
|
|||||||
import work.slhaf.partner.runtime.interaction.data.context.subcontext.CoreContext
|
import work.slhaf.partner.runtime.interaction.data.context.subcontext.CoreContext
|
||||||
import work.slhaf.partner.runtime.interaction.data.context.subcontext.ModuleContext
|
import work.slhaf.partner.runtime.interaction.data.context.subcontext.ModuleContext
|
||||||
|
|
||||||
class PartnerRunningFlowContext(
|
class PartnerRunningFlowContext private constructor(
|
||||||
override val source: String,
|
override val source: String,
|
||||||
override val input: String,
|
override val input: String,
|
||||||
platform: String,
|
|
||||||
nickName: String
|
|
||||||
) : RunningFlowContext() {
|
) : RunningFlowContext() {
|
||||||
|
|
||||||
init {
|
companion object {
|
||||||
putUserInfo("platform", platform)
|
|
||||||
putUserInfo("nickname", nickName)
|
private const val SOURCE_SELF = "self"
|
||||||
|
private const val SOURCE_SELF_PLATFORM = "AGENT_INTERNAL"
|
||||||
|
private const val SOURCE_SELF_NICKNAME = "PARTNER"
|
||||||
|
|
||||||
|
private object InfoKeys {
|
||||||
|
const val PLATFORM = "platform"
|
||||||
|
const val NICKNAME = "nickname"
|
||||||
|
}
|
||||||
|
|
||||||
|
private object SourceTag {
|
||||||
|
private const val AGENT = "[AGENT]"
|
||||||
|
private const val USER = "[USER]"
|
||||||
|
|
||||||
|
fun buildUserSource(userId: String): String = "$USER: $userId"
|
||||||
|
fun buildAgentSource(): String = "$AGENT: $SOURCE_SELF"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fromUser(
|
||||||
|
userId: String,
|
||||||
|
input: String,
|
||||||
|
platform: String,
|
||||||
|
nickName: String
|
||||||
|
) = PartnerRunningFlowContext(SourceTag.buildUserSource(userId), input).apply {
|
||||||
|
putUserInfo(InfoKeys.PLATFORM, platform)
|
||||||
|
putUserInfo(InfoKeys.NICKNAME, nickName)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fromSelf(input: String) =
|
||||||
|
PartnerRunningFlowContext(SourceTag.buildAgentSource(), input).apply {
|
||||||
|
putUserInfo(InfoKeys.PLATFORM, SOURCE_SELF_PLATFORM)
|
||||||
|
putUserInfo(InfoKeys.NICKNAME, SOURCE_SELF_NICKNAME)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val moduleContext = ModuleContext()
|
val moduleContext = ModuleContext()
|
||||||
|
|||||||
Reference in New Issue
Block a user