Class IntentionDetectionServiceImpl
java.lang.Object
com.bytedesk.kbase.settings_intention.intention.impl.IntentionDetectionServiceImpl
- All Implemented Interfaces:
IntentionDetectionService
@Service
public class IntentionDetectionServiceImpl
extends Object
implements IntentionDetectionService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IntentionSettingsEntity
内存缓存当前设置private Map<String,
List<IntentionTransition>> private com.fasterxml.jackson.databind.ObjectMapper
private ThreadRepository
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate double
calculateSimilarityScore
(String text, String intention) 计算文本与意图的匹配度 这是一个简化实现,实际应使用更复杂的NLP算法detectIntention
(String messageContent, List<String> contextMessages) 检测单条消息的意图detectThreadIntention
(String threadId) 检测会话的整体意图获取所有可用的意图类别private IntentionSettingsEntity
获取默认设置getIntentionHistory
(String threadId) 获取意图转换历史获取意图关键词映射 实际应从数据库或配置文件中加载getRecommendedResponse
(String intention) 获取指定意图的推荐回复获取子意图映射boolean
setThreadIntention
(String threadId, String intention, double confidence) 手动设置会话意图private IntentionResult
simulateIntentionDetection
(String messageContent, List<String> contextMessages, IntentionSettingsEntity settings) 模拟意图检测 注意:这只是演示实现,实际应使用NLP或LLM模型boolean
updateIntentionModel
(List<IntentionTrainingData> trainingData) 更新意图模型
-
Field Details
-
threadRepository
-
objectMapper
@Autowired private com.fasterxml.jackson.databind.ObjectMapper objectMapper -
intentionTransitionHistory
-
currentSettings
内存缓存当前设置
-
-
Constructor Details
-
IntentionDetectionServiceImpl
public IntentionDetectionServiceImpl()
-
-
Method Details
-
detectIntention
Description copied from interface:IntentionDetectionService
检测单条消息的意图- Specified by:
detectIntention
in interfaceIntentionDetectionService
- Parameters:
messageContent
- 消息内容contextMessages
- 上下文消息列表(可选)- Returns:
- 意图检测结果
-
detectThreadIntention
Description copied from interface:IntentionDetectionService
检测会话的整体意图- Specified by:
detectThreadIntention
in interfaceIntentionDetectionService
- Parameters:
threadId
- 会话ID- Returns:
- 意图检测结果
-
getAvailableIntentions
Description copied from interface:IntentionDetectionService
获取所有可用的意图类别- Specified by:
getAvailableIntentions
in interfaceIntentionDetectionService
- Returns:
- 意图类别列表
-
updateIntentionModel
Description copied from interface:IntentionDetectionService
更新意图模型- Specified by:
updateIntentionModel
in interfaceIntentionDetectionService
- Parameters:
trainingData
- 训练数据- Returns:
- 是否更新成功
-
getRecommendedResponse
Description copied from interface:IntentionDetectionService
获取指定意图的推荐回复- Specified by:
getRecommendedResponse
in interfaceIntentionDetectionService
- Parameters:
intention
- 意图名称- Returns:
- 推荐回复
-
getIntentionHistory
Description copied from interface:IntentionDetectionService
获取意图转换历史- Specified by:
getIntentionHistory
in interfaceIntentionDetectionService
- Parameters:
threadId
- 会话ID- Returns:
- 意图转换历史记录
-
setThreadIntention
Description copied from interface:IntentionDetectionService
手动设置会话意图- Specified by:
setThreadIntention
in interfaceIntentionDetectionService
- Parameters:
threadId
- 会话IDintention
- 意图名称confidence
- 置信度- Returns:
- 是否设置成功
-
getDefaultSettings
获取默认设置 -
getSubIntentionMapping
获取子意图映射 -
simulateIntentionDetection
private IntentionResult simulateIntentionDetection(String messageContent, List<String> contextMessages, IntentionSettingsEntity settings) 模拟意图检测 注意:这只是演示实现,实际应使用NLP或LLM模型 -
calculateSimilarityScore
计算文本与意图的匹配度 这是一个简化实现,实际应使用更复杂的NLP算法 -
getIntentionKeywordMapping
获取意图关键词映射 实际应从数据库或配置文件中加载
-