feat(knowledge): add channel support to knowledge entries and related components
- Introduced a new `channel` field in the Knowledge struct and associated request types to track the source channel (e.g., "web", "api", "browser_extension"). - Updated various frontend components to display channel information and enhance user experience with channel labels. - Enhanced localization files to support channel labels in English and Chinese. - Modified backend services and database migrations to accommodate the new channel feature, ensuring consistent tracking across knowledge entries. - Refactored related functions to integrate channel handling, improving overall knowledge management and context.
This commit is contained in:
+19
-1
@@ -1919,7 +1919,7 @@ func (s *Service) processFileToKnowledgeBase(ctx context.Context, msg *IncomingM
|
||||
fh := newInMemoryFileHeader(fileName, content)
|
||||
|
||||
// Create knowledge entry via the knowledge service
|
||||
knowledge, err := s.knowledgeService.CreateKnowledgeFromFile(kbCtx, kbID, fh, nil, nil, "", "")
|
||||
knowledge, err := s.knowledgeService.CreateKnowledgeFromFile(kbCtx, kbID, fh, nil, nil, "", "", imPlatformToChannel(channel.Platform))
|
||||
if err != nil {
|
||||
errMsg := err.Error()
|
||||
// Check for duplicate file
|
||||
@@ -2269,6 +2269,24 @@ func fileExtension(filename string) string {
|
||||
return strings.ToLower(parts[len(parts)-1])
|
||||
}
|
||||
|
||||
// imPlatformToChannel maps an IM platform identifier to a Knowledge.Channel constant.
|
||||
func imPlatformToChannel(platform string) string {
|
||||
switch strings.ToLower(platform) {
|
||||
case "wechat":
|
||||
return types.ChannelWechat
|
||||
case "wecom", "wxwork":
|
||||
return types.ChannelWecom
|
||||
case "feishu", "lark":
|
||||
return types.ChannelFeishu
|
||||
case "dingtalk":
|
||||
return types.ChannelDingtalk
|
||||
case "slack":
|
||||
return types.ChannelSlack
|
||||
default:
|
||||
return types.ChannelIM
|
||||
}
|
||||
}
|
||||
|
||||
// newInMemoryFileHeader wraps in-memory file content as a *multipart.FileHeader
|
||||
// so it can be passed to CreateKnowledgeFromFile which expects a multipart upload.
|
||||
func newInMemoryFileHeader(filename string, data []byte) *multipart.FileHeader {
|
||||
|
||||
Reference in New Issue
Block a user