mirror of
https://github.com/YFGaia/dify-plus.git
synced 2026-06-04 10:14:00 +08:00
17832f2424
本次提交整合了多个功能改进和问题修复: 主要功能: - 批量工作流处理功能完善,支持 Excel 上传和进度跟踪 - 管理中心反向代理和转发配置优化 - 用户同步添加互斥锁,防止并发问题 - 计费系统和额度显示优化 - AI 绘图功能扩展 前端改进: - 文本生成应用显示修复 - 批量任务进度展示优化 - 按钮样式和 CSS 优化,禁止换行 - 多语言支持完善(新增印尼语等) - 构建镜像逻辑优化 - 批量处理进度管理器实现 后端改进: - Docker Compose 配置升级 - 队列任务和 Worker Pool 优化 - Admin API 初始化和验证逻辑改进 - 数据库迁移和初始化完善 - 静态变量处理优化 - URL 签名助手实现 - Celery 扩展优化 - 代码和导入包问题修复(idea 自动调整代码位置) 技术改进: - 兼容性修复 (flask-restx, jschardet) - 钉钉 Web API 版本更新 - 代码格式化和导入包问题修复 - 日志处理优化 - 工作流循环管理优化 Docker 相关: - Nginx 配置更新 - 容器启动脚本优化 - 镜像构建流程改进 - docker-compose.dify-plus.yaml 大幅更新 管理后台: - 工作流批量处理 API 实现 - 工作池初始化 - 批量工作流服务实现 - 转发扩展配置 - 用户服务扩展
72 lines
3.6 KiB
Go
72 lines
3.6 KiB
Go
package gaia
|
|
|
|
import "time"
|
|
|
|
// 批量工作流状态常量
|
|
const (
|
|
BatchWorkflowStatusPending = "pending" // 待处理
|
|
BatchWorkflowStatusProcessing = "processing" // 处理中
|
|
BatchWorkflowStatusCompleted = "completed" // 已完成
|
|
BatchWorkflowStatusFailed = "failed" // 失败
|
|
BatchWorkflowStatusStopped = "stopped" // 已停止
|
|
)
|
|
|
|
// 批量工作流任务状态常量
|
|
const (
|
|
BatchTaskStatusPending = "pending" // 待处理
|
|
BatchTaskStatusQueued = "queued" // 队列中
|
|
BatchTaskStatusRunning = "running" // 运行中
|
|
BatchTaskStatusCompleted = "completed" // 已完成
|
|
BatchTaskStatusFailed = "failed" // 失败
|
|
BatchTaskStatusCancelled = "cancelled" // 已取消
|
|
)
|
|
|
|
// 批量工作流错误消息常量
|
|
const (
|
|
ErrorInsufficientBalance = "余额不足,调用失败!"
|
|
ErrorMaxRetryExceeded = "重试超过3次"
|
|
ErrorWorkflowFailed = "工作流执行失败"
|
|
ErrorCallAPIFailed = "调用Dify API失败"
|
|
ErrorParseResultFailed = "解析API返回结果失败"
|
|
)
|
|
|
|
// 批量工作流配置常量
|
|
const (
|
|
MaxTaskRetryCount = 3 // 最大任务重试次数
|
|
ErrorPenaltyThreshold = 50 // 错误惩罚阈值(每50个错误减少1个并发位)
|
|
)
|
|
|
|
// BatchWorkflow 批量工作流处理
|
|
type BatchWorkflow struct {
|
|
ID string `json:"id" gorm:"primaryKey;comment:批量处理ID"`
|
|
UserID uint `json:"user_id" gorm:"index;comment:用户id"`
|
|
InstalledID string `json:"installed_id" gorm:"not null;comment:安装的应用ID"`
|
|
FileName string `json:"file_name" gorm:"not null;comment:上传的文件名"`
|
|
TotalRows int `json:"total_rows" gorm:"not null;default:0;comment:总行数"`
|
|
ProcessedRows int `json:"processed_rows" gorm:"not null;default:0;comment:已处理行数"`
|
|
Status string `json:"status" gorm:"not null;default:'pending';comment:状态: pending, processing, completed, failed, stopped"`
|
|
Results string `json:"results" gorm:"type:text;comment:处理结果"`
|
|
KeyName string `json:"key_name" gorm:"type:text;comment:键名"`
|
|
Error string `json:"error" gorm:"comment:错误信息"`
|
|
ErrorCount int `json:"error_count" gorm:"not null;default:0;comment:累计错误次数"`
|
|
CreatedAt time.Time `json:"created_at" gorm:"not null;default:CURRENT_TIMESTAMP(0);comment:创建时间"`
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"not null;default:CURRENT_TIMESTAMP(0);comment:更新时间"`
|
|
}
|
|
|
|
// BatchWorkflowTask 批量工作流任务
|
|
type BatchWorkflowTask struct {
|
|
ID string `json:"id" gorm:"primaryKey;comment:任务ID"`
|
|
BatchWorkflowID string `json:"batch_workflow_id" gorm:"not null;comment:批量处理ID"`
|
|
RowIndex int `json:"row_index" gorm:"not null;comment:行索引"`
|
|
Inputs string `json:"inputs" gorm:"type:text;comment:输入参数"`
|
|
Status string `json:"status" gorm:"not null;default:'pending';comment:状态: pending, running, completed, failed, cancelled"`
|
|
Result string `json:"result" gorm:"type:text;comment:处理结果"`
|
|
Error string `json:"error" gorm:"comment:错误信息"`
|
|
ErrorCount int `json:"error_count" gorm:"not null;default:0;comment:错误次数"`
|
|
CreatedAt time.Time `json:"created_at" gorm:"not null;default:CURRENT_TIMESTAMP(0);comment:创建时间"`
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"not null;default:CURRENT_TIMESTAMP(0);comment:更新时间"`
|
|
}
|
|
|
|
func (BatchWorkflow) TableName() string { return "batch_workflows_extend" }
|
|
func (BatchWorkflowTask) TableName() string { return "batch_workflow_tasks_extend" }
|