feat: Implement AI Agent Workflow Binding functionality
- Added aiAgentWorkflowBindingRepository for managing workflow bindings associated with AI agents. - Enhanced agentRevisionService to include workflow bindings in agent revisions. - Updated aIAgentService to handle workflow bindings during agent creation and updates. - Introduced ai_agent_workflow_binding_service for managing workflow binding logic. - Created new API endpoints for fetching, creating, updating, and deleting AI workflows. - Developed a new dashboard page for managing AI workflows. - Updated frontend components to support workflow binding management in agent configuration. - Added necessary tests for workflow binding functionality and updated existing tests for compatibility. - Translated relevant UI texts and messages for workflow management.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"agent-desk/internal/models"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var AIAgentWorkflowBindingRepository = newAIAgentWorkflowBindingRepository()
|
||||
|
||||
func newAIAgentWorkflowBindingRepository() *aiAgentWorkflowBindingRepository {
|
||||
return &aiAgentWorkflowBindingRepository{}
|
||||
}
|
||||
|
||||
type aiAgentWorkflowBindingRepository struct{}
|
||||
|
||||
func (r *aiAgentWorkflowBindingRepository) FindByAgentID(db *gorm.DB, agentID int64) []models.AIAgentWorkflowBinding {
|
||||
ret := make([]models.AIAgentWorkflowBinding, 0)
|
||||
if agentID > 0 {
|
||||
db.Where("ai_agent_id = ?", agentID).Order("priority ASC, id ASC").Find(&ret)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (r *aiAgentWorkflowBindingRepository) FindEnabledByAgentID(db *gorm.DB, agentID int64) []models.AIAgentWorkflowBinding {
|
||||
ret := make([]models.AIAgentWorkflowBinding, 0)
|
||||
if agentID > 0 {
|
||||
db.Where("ai_agent_id = ? AND enabled = ?", agentID, true).Order("priority ASC, id ASC").Find(&ret)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func (r *aiAgentWorkflowBindingRepository) CountByWorkflowID(db *gorm.DB, workflowID int64) int64 {
|
||||
var count int64
|
||||
if workflowID > 0 {
|
||||
db.Model(&models.AIAgentWorkflowBinding{}).Where("workflow_id = ?", workflowID).Count(&count)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func (r *aiAgentWorkflowBindingRepository) ReplaceByAgentID(db *gorm.DB, agentID int64, items []models.AIAgentWorkflowBinding) error {
|
||||
if err := db.Where("ai_agent_id = ?", agentID).Delete(&models.AIAgentWorkflowBinding{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if len(items) == 0 {
|
||||
return nil
|
||||
}
|
||||
return db.Create(&items).Error
|
||||
}
|
||||
Reference in New Issue
Block a user