feat(integrations): polish embed/IM channel editors and agent rebind
Align embed channel setup with a step wizard, simplify deploy layout, and allow changing bound agents on update for embed and IM channels.
This commit is contained in:
@@ -67,6 +67,7 @@ type embedChannelRequest struct {
|
||||
DefaultLocale *string `json:"default_locale"`
|
||||
WebhookURL *string `json:"webhook_url"`
|
||||
WebhookSecret *string `json:"webhook_secret"`
|
||||
AgentID *string `json:"agent_id"`
|
||||
}
|
||||
|
||||
// isProductionMode reports whether the server runs in a hardened (release) mode.
|
||||
@@ -242,6 +243,9 @@ func (h *EmbedChannelHandler) UpdateEmbedChannel(c *gin.Context) {
|
||||
HeaderTitleMode: req.HeaderTitleMode,
|
||||
WidgetPosition: req.WidgetPosition,
|
||||
}
|
||||
if req.AgentID != nil {
|
||||
update.AgentID = strings.TrimSpace(*req.AgentID)
|
||||
}
|
||||
ch, err := h.embedSvc.Update(c.Request.Context(), tenantID, channelID, update, req.Enabled, req.ShowSuggestedQuestions, req.AllowWebSearch, req.AllowMemory, req.AllowFileUpload, req.DefaultLocale, req.WebhookURL, req.WebhookSecret)
|
||||
if err != nil {
|
||||
writeEmbedMgmtError(c, err)
|
||||
|
||||
@@ -196,6 +196,7 @@ func (h *IMHandler) UpdateIMChannel(c *gin.Context) {
|
||||
KnowledgeBaseID *string `json:"knowledge_base_id"`
|
||||
Credentials types.JSON `json:"credentials"`
|
||||
Enabled *bool `json:"enabled"`
|
||||
AgentID *string `json:"agent_id"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
@@ -220,6 +221,16 @@ func (h *IMHandler) UpdateIMChannel(c *gin.Context) {
|
||||
if req.Enabled != nil {
|
||||
channel.Enabled = *req.Enabled
|
||||
}
|
||||
if req.AgentID != nil {
|
||||
newAgentID := strings.TrimSpace(*req.AgentID)
|
||||
if newAgentID != "" && newAgentID != channel.AgentID {
|
||||
if err := h.imService.SetChannelAgentID(c.Request.Context(), channel, newAgentID); err != nil {
|
||||
logger.Errorf(c.Request.Context(), "[IM] Update channel agent failed: %v", err)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "agent not found"})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := h.imService.UpdateChannel(channel); err != nil {
|
||||
logger.Errorf(c.Request.Context(), "[IM] Update channel failed: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user