mirror of
https://github.com/jie65535/JChatGPT.git
synced 2026-09-15 02:56:10 +08:00
profile: use support history in analysis
This commit is contained in:
@@ -152,6 +152,23 @@ class UserProfileAnalysisServiceTest {
|
||||
assertEquals(1, model.calls)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun passesPersistedSupportStatsToTheNextConversationAnalysis() = withProfileStore {
|
||||
val firstBatch = singleUserBatch(USER_A, 10, "support-first")
|
||||
val firstModel = FakeConversationProfileModel {
|
||||
result(responseFor("U1", "长期关注 Kotlin", evidenceRef = 1))
|
||||
}
|
||||
assertNotNull(analyze(firstBatch, firstModel))
|
||||
val itemId = assertNotNull(UserProfileStore.load(USER_A)).items.single().id
|
||||
|
||||
val secondModel = SupportInspectingConversationProfileModel { supportStatsByUserId ->
|
||||
val support = assertNotNull(supportStatsByUserId[USER_A]?.get(itemId))
|
||||
assertEquals(1, support.count)
|
||||
result()
|
||||
}
|
||||
assertNotNull(analyze(singleUserBatch(USER_A, 20, "support-second"), secondModel))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun skipsModelWhenNoParticipantMeetsTheTextThreshold() = withProfileStore {
|
||||
val model = FakeConversationProfileModel {
|
||||
@@ -356,6 +373,27 @@ class UserProfileAnalysisServiceTest {
|
||||
): ConversationProfileModelResult = behavior(profiles)
|
||||
}
|
||||
|
||||
private class SupportInspectingConversationProfileModel(
|
||||
private val behavior: suspend (
|
||||
Map<Long, Map<String, ProfileItemSupportStats>>,
|
||||
) -> ConversationProfileModelResult,
|
||||
) : ConversationProfileModel {
|
||||
override val modelName: String = "support-inspecting-profile-model"
|
||||
|
||||
override suspend fun analyzeConversation(
|
||||
profiles: Map<Long, UserProfileSnapshot>,
|
||||
batch: ConversationProfileBatch,
|
||||
eligibleUserIds: Set<Long>,
|
||||
): ConversationProfileModelResult = error("画像服务未调用支持统计重载")
|
||||
|
||||
override suspend fun analyzeConversation(
|
||||
profiles: Map<Long, UserProfileSnapshot>,
|
||||
batch: ConversationProfileBatch,
|
||||
eligibleUserIds: Set<Long>,
|
||||
supportStatsByUserId: Map<Long, Map<String, ProfileItemSupportStats>>,
|
||||
): ConversationProfileModelResult = behavior(supportStatsByUserId)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val BOT = 1L
|
||||
private const val GROUP = 10L
|
||||
|
||||
Reference in New Issue
Block a user