mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-10-12 02:16:39 +00:00
@@ -552,17 +552,17 @@ func main() {
|
||||
}
|
||||
case "ingestor":
|
||||
if serverName == "" {
|
||||
uuid := utility.GenerateUUID()
|
||||
uuid := common.GenerateUUID()
|
||||
serverName = fmt.Sprintf("ingestor_server_%s", uuid)
|
||||
}
|
||||
case "syncer":
|
||||
if serverName == "" {
|
||||
uuid := utility.GenerateUUID()
|
||||
uuid := common.GenerateUUID()
|
||||
serverName = fmt.Sprintf("syncer_server_%s", uuid)
|
||||
}
|
||||
case "deepdoc":
|
||||
if serverName == "" {
|
||||
uuid := utility.GenerateUUID()
|
||||
uuid := common.GenerateUUID()
|
||||
serverName = fmt.Sprintf("deepdoc_server_%s", uuid)
|
||||
}
|
||||
case "migrate":
|
||||
@@ -1448,7 +1448,7 @@ func startServer(ctx context.Context, serverName string, arguments *serverArgs)
|
||||
// Start heartbeat reporter to admin server
|
||||
if hb := startHeartbeat(
|
||||
common.ServerTypeAPI,
|
||||
fmt.Sprintf("ragflow-server-%s", utility.GenerateUUID()[:8]),
|
||||
fmt.Sprintf("ragflow-server-%s", common.GenerateUUID()[:8]),
|
||||
apiServerConfig.HTTPPort,
|
||||
globalConfig.GetHeartbeatInterval(),
|
||||
); hb != nil {
|
||||
|
||||
@@ -119,7 +119,7 @@ func (h *Handler) Login(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
authToken, err := utility.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
authToken, err := common.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, fmt.Sprintf("Failed to generate auth token: %s", err.Error()))
|
||||
return
|
||||
@@ -1145,7 +1145,7 @@ func (h *Handler) ShutdownIngestor(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
taskID := utility.GenerateUUID()
|
||||
taskID := common.GenerateUUID()
|
||||
//ingestionManager.SubmitTask(&common.TaskAssignment{
|
||||
// TaskId: taskID,
|
||||
// TaskType: "SHUTDOWN",
|
||||
|
||||
@@ -38,7 +38,6 @@ import (
|
||||
"ragflow/internal/server"
|
||||
servicepkg "ragflow/internal/service"
|
||||
"ragflow/internal/storage"
|
||||
"ragflow/internal/utility"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
@@ -204,8 +203,8 @@ func (s *Service) CreateUser(ctx context.Context, username, password, role strin
|
||||
return nil, fmt.Errorf("failed to hash password: %w", err)
|
||||
}
|
||||
|
||||
userID := utility.GenerateToken()
|
||||
accessToken := utility.GenerateToken()
|
||||
userID := common.GenerateToken()
|
||||
accessToken := common.GenerateToken()
|
||||
status := "1"
|
||||
loginChannel := "password"
|
||||
isSuperuser := role == "admin"
|
||||
@@ -293,7 +292,7 @@ func (s *Service) CreateUser(ctx context.Context, username, password, role strin
|
||||
// 3. Create user-tenant relation
|
||||
userTenantStatus := "1"
|
||||
userTenant := &entity.UserTenant{
|
||||
ID: utility.GenerateToken(),
|
||||
ID: common.GenerateToken(),
|
||||
UserID: userID,
|
||||
TenantID: userID,
|
||||
Role: "owner",
|
||||
@@ -306,7 +305,7 @@ func (s *Service) CreateUser(ctx context.Context, username, password, role strin
|
||||
}
|
||||
|
||||
// 4. Create root file folder
|
||||
fileID := utility.GenerateToken()
|
||||
fileID := common.GenerateToken()
|
||||
fileLocation := ""
|
||||
file := &entity.File{
|
||||
ID: fileID,
|
||||
@@ -483,7 +482,7 @@ func (s *Service) UpdateUserActivateStatus(ctx context.Context, username string,
|
||||
|
||||
user.IsActive = targetStatus
|
||||
if !isActive {
|
||||
invalidToken := "INVALID_" + utility.GenerateToken()
|
||||
invalidToken := "INVALID_" + common.GenerateToken()
|
||||
user.AccessToken = &invalidToken
|
||||
}
|
||||
|
||||
@@ -618,8 +617,8 @@ func (s *Service) GenerateUserAPIToken(ctx context.Context, username string) (ma
|
||||
tenantID := userTenants[0].TenantID
|
||||
|
||||
// 3. Generate API token
|
||||
key := utility.GenerateAPIToken()
|
||||
beta := utility.GenerateBetaAPIToken()
|
||||
key := common.GenerateAPIToken()
|
||||
beta := common.GenerateBetaAPIToken()
|
||||
|
||||
apiToken := &entity.APIToken{
|
||||
TenantID: tenantID,
|
||||
@@ -1344,8 +1343,8 @@ func (s *Service) InitDefaultAdmin() error {
|
||||
}
|
||||
|
||||
if len(users) == 0 {
|
||||
userID := utility.GenerateToken()
|
||||
accessToken := utility.GenerateToken()
|
||||
userID := common.GenerateToken()
|
||||
accessToken := common.GenerateToken()
|
||||
status := "1"
|
||||
loginChannel := "password"
|
||||
isSuperuser := true
|
||||
|
||||
@@ -55,7 +55,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"ragflow/internal/utility"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -276,7 +275,7 @@ func (r *Runner) Run(
|
||||
// Reuse a persisted question's identifier for the RunFunc and SSE envelope.
|
||||
messageID, _ := root["__message_id__"].(string)
|
||||
if messageID == "" {
|
||||
messageID = utility.GenerateToken()
|
||||
messageID = common.GenerateToken()
|
||||
}
|
||||
|
||||
// Inject the output channel + metadata so the RunFunc can emit
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package utility
|
||||
package common
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -159,7 +159,7 @@ func (dao *ConnectorDAO) LinkDatasetConnectorsTx(ctx context.Context, tx *gorm.D
|
||||
}
|
||||
|
||||
if err := tx.WithContext(ctx).Create(&entity.Connector2Kb{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
ConnectorID: connector.ID,
|
||||
KbID: kbID,
|
||||
AutoParse: autoParse,
|
||||
@@ -424,7 +424,7 @@ func createRebuildSyncLog(ctx context.Context, tx *gorm.DB, connectorID, kbID, t
|
||||
fromBeginning = "1"
|
||||
}
|
||||
now := time.Now().Local()
|
||||
taskID := utility.GenerateToken()
|
||||
taskID := common.GenerateToken()
|
||||
return taskID, tx.WithContext(ctx).Create(&entity.SyncLogs{
|
||||
ID: taskID,
|
||||
ConnectorID: connectorID,
|
||||
@@ -485,7 +485,7 @@ func scheduleConnectorTask(ctx context.Context, tx *gorm.DB, connectorID, kbID,
|
||||
fromBeginning = "1"
|
||||
}
|
||||
now := time.Now().Local()
|
||||
taskID := utility.GenerateToken()
|
||||
taskID := common.GenerateToken()
|
||||
return taskID, tx.WithContext(ctx).Create(&entity.SyncLogs{
|
||||
ID: taskID,
|
||||
ConnectorID: connectorID,
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"fmt"
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/zap"
|
||||
@@ -162,7 +161,7 @@ func (dao *FileDAO) GetRootFolder(ctx context.Context, db *gorm.DB, tenantID str
|
||||
}
|
||||
|
||||
// Create root folder if not exists
|
||||
fileID := utility.GenerateToken()
|
||||
fileID := common.GenerateToken()
|
||||
file = entity.File{
|
||||
ID: fileID,
|
||||
ParentID: fileID,
|
||||
@@ -355,7 +354,7 @@ func (dao *FileDAO) GetIDListByID(ctx context.Context, db *gorm.DB, id string, n
|
||||
// CreateFolder creates a folder in the database
|
||||
func (dao *FileDAO) CreateFolder(ctx context.Context, db *gorm.DB, parentID, tenantID, name, fileType string) (*entity.File, error) {
|
||||
file := &entity.File{
|
||||
ID: utility.GenerateToken(),
|
||||
ID: common.GenerateToken(),
|
||||
ParentID: parentID,
|
||||
TenantID: tenantID,
|
||||
CreatedBy: tenantID,
|
||||
@@ -562,7 +561,7 @@ func (dao *FileDAO) newAFileFromDataset(ctx context.Context, db *gorm.DB, tenant
|
||||
return existingFiles[0], nil
|
||||
}
|
||||
|
||||
fileID := utility.GenerateToken()
|
||||
fileID := common.GenerateToken()
|
||||
file := &entity.File{
|
||||
ID: fileID,
|
||||
ParentID: parentID,
|
||||
@@ -604,7 +603,7 @@ func (dao *FileDAO) addFileFromKB(ctx context.Context, db *gorm.DB, doc *entity.
|
||||
docLocation = *doc.Location
|
||||
}
|
||||
|
||||
fileID := utility.GenerateToken()
|
||||
fileID := common.GenerateToken()
|
||||
file := &entity.File{
|
||||
ID: fileID,
|
||||
ParentID: datasetFolderID,
|
||||
@@ -621,7 +620,7 @@ func (dao *FileDAO) addFileFromKB(ctx context.Context, db *gorm.DB, doc *entity.
|
||||
return err
|
||||
}
|
||||
|
||||
f2dID := utility.GenerateToken()
|
||||
f2dID := common.GenerateToken()
|
||||
f2d := &entity.File2Document{
|
||||
ID: f2dID,
|
||||
FileID: &fileID,
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"fmt"
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
@@ -43,7 +42,7 @@ func (dao *IngestionTaskDAO) Create(ctx context.Context, db *gorm.DB, ingestionT
|
||||
return nil, fmt.Errorf("document id %s already exists, status: %s, task id: %s", ingestionTask.DocumentID, existing.Status, existing.ID)
|
||||
}
|
||||
if ingestionTask.ID == "" {
|
||||
ingestionTask.ID = utility.GenerateUUID()
|
||||
ingestionTask.ID = common.GenerateUUID()
|
||||
}
|
||||
if err = db.WithContext(ctx).Create(ingestionTask).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrDuplicatedKey) {
|
||||
|
||||
@@ -19,11 +19,11 @@ package dao
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"ragflow/internal/common"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -218,7 +218,7 @@ func (dao *PipelineOperationLogDAO) CreateOpenLog(ctx context.Context, db *gorm.
|
||||
now := time.Now().Local()
|
||||
runCount := input.RunCount
|
||||
log := &entity.PipelineOperationLog{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
DocumentID: input.DocumentID,
|
||||
RunCount: &runCount,
|
||||
TenantID: input.TenantID,
|
||||
|
||||
@@ -18,8 +18,8 @@ package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
"strings"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -131,7 +131,7 @@ func (dao *SkillSearchConfigDAO) CreateWithTenantSpace(ctx context.Context, db *
|
||||
}
|
||||
|
||||
defaultConfig := &entity.SkillSearchConfig{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
TenantID: tenantID,
|
||||
SpaceID: spaceID,
|
||||
EmbdID: embdID,
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
"time"
|
||||
@@ -512,7 +513,7 @@ func createScheduledTask(ctx context.Context, tx *gorm.DB, connectorID, kbID, ta
|
||||
Update("status", SyncStatusSchedule).Error; err != nil {
|
||||
return "", err
|
||||
}
|
||||
taskID := utility.GenerateToken()
|
||||
taskID := common.GenerateToken()
|
||||
return taskID, tx.WithContext(ctx).Create(&entity.SyncLogs{
|
||||
ID: taskID,
|
||||
ConnectorID: connectorID,
|
||||
|
||||
@@ -40,7 +40,6 @@ import (
|
||||
"ragflow/internal/ingestion/task"
|
||||
"ragflow/internal/service"
|
||||
"ragflow/internal/service/file"
|
||||
"ragflow/internal/utility"
|
||||
|
||||
dslpkg "ragflow/internal/agent/dsl"
|
||||
)
|
||||
@@ -468,7 +467,7 @@ func (h *AgentHandler) RunAgent(c *gin.Context) {
|
||||
if sessionID == "" {
|
||||
// Allocate the ordinary-Agent session identity at the HTTP boundary.
|
||||
// Persistence of the session record remains owned by AgentService.RunAgent.
|
||||
sessionID = utility.GenerateToken()
|
||||
sessionID = common.GenerateToken()
|
||||
c.Request = c.Request.WithContext(service.WithAgentSessionID(c.Request.Context(), sessionID))
|
||||
}
|
||||
userInput, err := readUserInput(c)
|
||||
@@ -1271,7 +1270,7 @@ func (h *AgentHandler) AgentChatCompletions(c *gin.Context) {
|
||||
// Keep the effective session available to the non-stream response and
|
||||
// to the task_id=session_id wire alias even when the canvas emits no
|
||||
// events (for example an empty query).
|
||||
req.SessionID = utility.GenerateToken()
|
||||
req.SessionID = common.GenerateToken()
|
||||
c.Request = c.Request.WithContext(service.WithAgentSessionID(c.Request.Context(), req.SessionID))
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/service"
|
||||
"ragflow/internal/tokenizer"
|
||||
"ragflow/internal/utility"
|
||||
)
|
||||
|
||||
// openAICompatUsage mirrors the usage object emitted by the Python
|
||||
@@ -107,7 +106,7 @@ type openAICompatCompletion struct {
|
||||
func (h *AgentHandler) handleOpenAICompat(c *gin.Context, user *entity.User, req *agentChatCompletionsRequest) {
|
||||
question := extractLastUserContent(req.Messages)
|
||||
if req.SessionID == "" {
|
||||
req.SessionID = utility.GenerateToken()
|
||||
req.SessionID = common.GenerateToken()
|
||||
c.Request = c.Request.WithContext(service.WithAgentSessionID(c.Request.Context(), req.SessionID))
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ import (
|
||||
"ragflow/internal/common"
|
||||
kvrocks "ragflow/internal/engine/kvrocks"
|
||||
"ragflow/internal/service"
|
||||
"ragflow/internal/utility"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -486,7 +485,7 @@ func renderImmediatelyResponse(cfg map[string]any) (int, string, []byte, error)
|
||||
func (h *AgentHandler) runWebhookDetached(
|
||||
parent context.Context, cv *entity.UserCanvas, payload map[string]any, isTest bool, startTs time.Time,
|
||||
) {
|
||||
sessionID := utility.GenerateToken()
|
||||
sessionID := common.GenerateToken()
|
||||
parent = service.WithAgentSessionID(parent, sessionID)
|
||||
ctx, cancel := context.WithTimeout(context.WithoutCancel(parent), 5*time.Minute)
|
||||
defer cancel()
|
||||
@@ -562,7 +561,7 @@ func (h *AgentHandler) runWebhookSync(
|
||||
isTest bool, startTs time.Time,
|
||||
) webhookSyncResult {
|
||||
status := 200
|
||||
sessionID := utility.GenerateToken()
|
||||
sessionID := common.GenerateToken()
|
||||
ctx = service.WithAgentSessionID(ctx, sessionID)
|
||||
events, err := h.loader.RunAgentWithWebhook(ctx, cv.UserID, cv.ID, payload)
|
||||
if err != nil {
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"ragflow/internal/engine/kvrocks"
|
||||
"ragflow/internal/server"
|
||||
"ragflow/internal/server/local"
|
||||
"ragflow/internal/utility"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -104,7 +103,7 @@ func (h *UserHandler) Register(c *gin.Context) {
|
||||
common.ResponseWithCodeData(c, common.CodeServerError, false, err.Error())
|
||||
return
|
||||
}
|
||||
authToken, err := utility.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
authToken, err := common.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
if err != nil {
|
||||
common.ResponseWithCodeData(c, common.CodeServerError, false, "Failed to generate auth token")
|
||||
return
|
||||
@@ -178,7 +177,7 @@ func (h *UserHandler) Login(c *gin.Context) {
|
||||
operationLog.DurationMS = time.Since(startAt).Milliseconds()
|
||||
return
|
||||
}
|
||||
authToken, err := utility.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
authToken, err := common.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
if err != nil {
|
||||
common.ResponseWithCodeData(c, common.CodeServerError, false, "Failed to generate auth token")
|
||||
operationLog.ErrorCode = uint16(common.CodeServerError)
|
||||
@@ -265,7 +264,7 @@ func (h *UserHandler) LoginByEmail(c *gin.Context) {
|
||||
operationLog.DurationMS = time.Since(startAt).Milliseconds()
|
||||
return
|
||||
}
|
||||
authToken, err := utility.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
authToken, err := common.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
if err != nil {
|
||||
common.ResponseWithCodeData(c, common.CodeServerError, false, "Failed to generate auth token")
|
||||
operationLog.ErrorCode = uint16(common.CodeServerError)
|
||||
@@ -718,7 +717,7 @@ func (h *UserHandler) ForgotResetPassword(c *gin.Context) {
|
||||
common.ResponseWithCodeData(c, common.CodeServerError, false, fmt.Sprintf("Failed to get secret key: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
authToken, err := utility.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
authToken, err := common.DumpAccessToken(*user.AccessToken, secretKey)
|
||||
if err != nil {
|
||||
common.ResponseWithCodeData(c, common.CodeServerError, false, "Failed to generate auth token")
|
||||
return
|
||||
|
||||
@@ -35,7 +35,6 @@ import (
|
||||
kccommon "ragflow/internal/ingestion/component/knowledge_compiler/common"
|
||||
"ragflow/internal/service/file"
|
||||
"ragflow/internal/tokenizer"
|
||||
"ragflow/internal/utility"
|
||||
)
|
||||
|
||||
// Writer persists dataset-level merged products and removes them on document
|
||||
@@ -227,7 +226,7 @@ func (w engineWriter) WriteMerged(ctx context.Context, tenant, kb string, produc
|
||||
// shard, so rows from the same execution share plan_kwd and reruns of the
|
||||
// same plan share input_hash_kwd.
|
||||
now := time.Now()
|
||||
runID := utility.GenerateUUID()
|
||||
runID := common.GenerateUUID()
|
||||
inputHash := mergedInputHash(products)
|
||||
// Diagnostics: before building merged rows, confirm the incoming products
|
||||
// actually carry an embedding. mergedChunkMap only writes q_<dim>_vec when
|
||||
|
||||
@@ -162,7 +162,7 @@ func NewIngestor(name string, maxConcurrency int32, supportedTypes []string) *In
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
dispatchCtx, dispatchCancel := context.WithCancel(context.Background())
|
||||
id := utility.GenerateUUID()
|
||||
id := common.GenerateUUID()
|
||||
ingestor := &Ingestor{
|
||||
id: id,
|
||||
name: name,
|
||||
@@ -694,7 +694,7 @@ func (e *Ingestor) executeMemoryTaskWithHeartbeat(ctx context.Context, taskCtx *
|
||||
settleAck = true
|
||||
return
|
||||
}
|
||||
leaseOwner := fmt.Sprintf("%s:%s", e.id, utility.GenerateUUID())
|
||||
leaseOwner := fmt.Sprintf("%s:%s", e.id, common.GenerateUUID())
|
||||
disposition, err := e.runMemoryTask(ctx, taskID, leaseOwner)
|
||||
if err != nil {
|
||||
common.Error(fmt.Sprintf("memory task %s execution failed", taskID), err)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/utility"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -95,7 +94,7 @@ func GetSecretKey(ctx context.Context, store VariableStore) (string, error) {
|
||||
return globalConfig.GetSecretKey(), nil
|
||||
}
|
||||
|
||||
generatedKey, err := utility.GenerateSecretKey()
|
||||
generatedKey, err := common.GenerateSecretKey()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to generate secret key: %w", err)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"ragflow/internal/service/file"
|
||||
"ragflow/internal/utility"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -983,7 +982,7 @@ func (s *AgentService) CreateAgent(ctx context.Context, req *CreateAgentRequest)
|
||||
// no-op when graph.nodes is already non-empty.
|
||||
req.DSL = dslpkg.NormalizeForCanvas(req.DSL)
|
||||
row := &entity.UserCanvas{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
UserID: req.UserID,
|
||||
Title: req.Title,
|
||||
Description: req.Description,
|
||||
@@ -1361,7 +1360,7 @@ func (s *AgentService) saveOrReplaceVersionOptions(ctx context.Context, userID,
|
||||
}
|
||||
versionTitle := buildVersionTitle(nickname, title, time.Now())
|
||||
return dao.SaveOrReplaceLatestVersionOptions{
|
||||
NewID: utility.GenerateUUID(),
|
||||
NewID: common.GenerateUUID(),
|
||||
UserCanvasID: canvasID,
|
||||
Title: &versionTitle,
|
||||
Description: description,
|
||||
@@ -1470,7 +1469,7 @@ func (s *AgentService) RunAgent(ctx context.Context, userID, canvasID, sessionID
|
||||
}
|
||||
newSession := sessionID == ""
|
||||
if sessionID == "" {
|
||||
sessionID = utility.GenerateToken()
|
||||
sessionID = common.GenerateToken()
|
||||
}
|
||||
trustedFirstTouch := AgentSessionIDFromContext(ctx) == sessionID
|
||||
if !newSession && s.api4ConversationDAO != nil && dao.DB != nil {
|
||||
@@ -1486,7 +1485,7 @@ func (s *AgentService) RunAgent(ctx context.Context, userID, canvasID, sessionID
|
||||
return nil, fmt.Errorf("RunAgent: session %q not found: %w", sessionID, dao.ErrUserCanvasNotFound)
|
||||
}
|
||||
}
|
||||
messageID := utility.GenerateToken()
|
||||
messageID := common.GenerateToken()
|
||||
questionSaved := false
|
||||
persistQuestion := func() error {
|
||||
if questionSaved || s.api4ConversationDAO == nil || dao.DB == nil {
|
||||
@@ -1512,7 +1511,7 @@ func (s *AgentService) RunAgent(ctx context.Context, userID, canvasID, sessionID
|
||||
return nil, err
|
||||
}
|
||||
runID := runIDFor(canvasID, map[string]any{"session_id": sessionID})
|
||||
lockToken := utility.GenerateToken()
|
||||
lockToken := common.GenerateToken()
|
||||
runCtx, cancelRun := context.WithCancel(ctx)
|
||||
// Keep workflow cancellation separate from event-consumer cancellation.
|
||||
// An explicit session cancellation should still reach an attached client,
|
||||
|
||||
@@ -773,7 +773,7 @@ func (s *AgentService) CreateAgentSession(ctx context.Context, req *CreateAgentS
|
||||
sourcePtr = &req.Source
|
||||
}
|
||||
|
||||
id := utility.GenerateUUID()
|
||||
id := common.GenerateUUID()
|
||||
|
||||
// CreateTime / UpdateTime / CreateDate / UpdateDate are filled in
|
||||
// by entity.BaseModel.BeforeCreate when the DAO Create() call runs,
|
||||
|
||||
@@ -18,9 +18,9 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/dao"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -49,7 +49,7 @@ func (s *SystemService) ListAPIKeys(ctx context.Context, tenantID string) ([]*AP
|
||||
for i, key := range keys {
|
||||
beta := key.Beta
|
||||
if beta == nil || *beta == "" {
|
||||
generatedBeta := utility.GenerateBetaAPIToken()
|
||||
generatedBeta := common.GenerateBetaAPIToken()
|
||||
if err = dao.DB.WithContext(ctx).Model(&entity.APIToken{}).
|
||||
Where("tenant_id = ? AND token = ?", tenantID, key.Token).
|
||||
Updates(map[string]interface{}{
|
||||
@@ -88,9 +88,9 @@ func (s *SystemService) CreateAPIKey(ctx context.Context, tenantID string, req *
|
||||
|
||||
// Generate key and beta values
|
||||
// key: "ragflow-" + secrets.token_urlsafe(32)
|
||||
APIToken := utility.GenerateAPIToken()
|
||||
APIToken := common.GenerateAPIToken()
|
||||
// beta: generate_confirmation_token().replace("ragflow-", "")[:32]
|
||||
betaAPIKey := utility.GenerateBetaAPIToken()
|
||||
betaAPIKey := common.GenerateBetaAPIToken()
|
||||
|
||||
APIKeyData := &entity.APIToken{
|
||||
TenantID: tenantID,
|
||||
|
||||
@@ -39,7 +39,6 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"ragflow/internal/dao"
|
||||
"ragflow/internal/utility"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -352,7 +351,7 @@ func (s *BotService) ChatbotCompletion(
|
||||
},
|
||||
})
|
||||
session := &entity.API4Conversation{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
DialogID: dialogID,
|
||||
UserID: tenantID,
|
||||
Message: seedMsg,
|
||||
@@ -410,7 +409,7 @@ func (s *BotService) ChatbotCompletion(
|
||||
// same filtered shape python builds in async_iframe_completion
|
||||
// (drop system turns, drop the leading assistant prologue,
|
||||
// append the new user turn last).
|
||||
messageID := utility.GenerateUUID()
|
||||
messageID := common.GenerateUUID()
|
||||
messages := buildChatbotPipelineMessages(session.Message, req.Question, messageID)
|
||||
|
||||
// python bot_api.py:72-73 defaults quote to False for chatbot
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/permission"
|
||||
permissionresponse "ragflow/internal/permission/response"
|
||||
"ragflow/internal/utility"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
@@ -553,7 +552,7 @@ func buildCreateChatEntity(req map[string]interface{}, tenantID string) *entity.
|
||||
}
|
||||
|
||||
chat := &entity.Chat{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
TenantID: tenantID,
|
||||
Name: &name,
|
||||
Description: &description,
|
||||
|
||||
@@ -23,8 +23,6 @@ import (
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"ragflow/internal/utility"
|
||||
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/dao"
|
||||
"ragflow/internal/entity"
|
||||
@@ -83,7 +81,7 @@ func (s *ChatChannelService) Insert(ctx context.Context, channel *entity.ChatCha
|
||||
return errors.New("channel is nil")
|
||||
}
|
||||
if channel.ID == "" {
|
||||
channel.ID = utility.GenerateUUID()
|
||||
channel.ID = common.GenerateUUID()
|
||||
}
|
||||
if channel.Status == 0 {
|
||||
channel.Status = 1
|
||||
@@ -116,7 +114,7 @@ func (s *ChatChannelService) CreateChatChannel(ctx context.Context, tenantID, na
|
||||
}
|
||||
}
|
||||
row := &entity.ChatChannel{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
TenantID: tenantID,
|
||||
Name: name,
|
||||
Channel: channelType,
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/engine"
|
||||
"ragflow/internal/storage"
|
||||
"ragflow/internal/utility"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -255,7 +254,7 @@ func (s *ChatSessionService) CreateSession(ctx context.Context, userID, chatID s
|
||||
referenceJSON, _ := json.Marshal([]interface{}{})
|
||||
|
||||
conv := &entity.ChatSession{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
DialogID: chatID,
|
||||
Name: &name,
|
||||
Message: messagesJSON,
|
||||
@@ -1659,7 +1658,7 @@ func (s *ChatSessionService) normalizeCompletionMessages(
|
||||
message := requestMsg[len(requestMsg)-1]
|
||||
messageID, _ = message["id"].(string)
|
||||
if messageID == "" {
|
||||
messageID = utility.GenerateToken()
|
||||
messageID = common.GenerateToken()
|
||||
message["id"] = messageID
|
||||
}
|
||||
return requestMsg, messageID, nil
|
||||
@@ -1717,7 +1716,7 @@ func (s *ChatSessionService) createSessionForCompletion(ctx context.Context, cha
|
||||
UserID: &userID,
|
||||
Reference: refJSON,
|
||||
}
|
||||
session.ID = utility.GenerateUUID()
|
||||
session.ID = common.GenerateUUID()
|
||||
if err := s.chatSessionDAO.Create(ctx, dao.DB, session); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/dao"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -132,7 +131,7 @@ func (s *CompilationTemplateGroupService) CreateGroup(ctx context.Context, tenan
|
||||
return nil, err
|
||||
}
|
||||
|
||||
groupID := utility.GenerateUUID()
|
||||
groupID := common.GenerateUUID()
|
||||
if err := dao.DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
group := &entity.CompilationTemplateGroup{
|
||||
ID: groupID,
|
||||
@@ -399,7 +398,7 @@ func (s *CompilationTemplateGroupService) insertChildren(ctx context.Context, db
|
||||
}
|
||||
valid := string(entity.StatusValid)
|
||||
tmpl := &entity.CompilationTemplate{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
TenantID: &tenantID,
|
||||
GroupID: &groupID,
|
||||
Name: name,
|
||||
@@ -520,7 +519,7 @@ func (s *CompilationTemplateGroupService) reconcileChildren(ctx context.Context,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newID := utility.GenerateUUID()
|
||||
newID := common.GenerateUUID()
|
||||
valid := string(entity.StatusValid)
|
||||
tmpl := &entity.CompilationTemplate{
|
||||
ID: newID,
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
"net/url"
|
||||
"ragflow/internal/engine/kvrocks"
|
||||
syncerconnector "ragflow/internal/syncer/connector"
|
||||
"ragflow/internal/utility"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -313,7 +312,7 @@ func (s *ConnectorService) CreateConnector(ctx context.Context, userID string, r
|
||||
}
|
||||
|
||||
connector := &entity.Connector{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
TenantID: userID,
|
||||
Name: req.Name,
|
||||
Source: req.Source,
|
||||
@@ -540,7 +539,7 @@ func (s *ConnectorService) StartGoogleWebOAuth(ctx context.Context, userID, sour
|
||||
return nil, common.CodeServerError, err
|
||||
}
|
||||
|
||||
flowID := utility.GenerateUUID()
|
||||
flowID := common.GenerateUUID()
|
||||
authorizationURL, err := buildGoogleAuthorizationURL(authURI, clientID, redirectURI, flowID, googleOAuthScopesForSource(source), codeChallenge)
|
||||
if err != nil {
|
||||
return nil, common.CodeServerError, fmt.Errorf("failed to initialize Google OAuth flow. Please verify the uploaded client configuration")
|
||||
@@ -1344,7 +1343,7 @@ func (s *ConnectorService) StartBoxWebOAuth(ctx context.Context, userID string,
|
||||
redirectURI = defaultBoxWebOAuthRedirectURI()
|
||||
}
|
||||
|
||||
flowID := utility.GenerateUUID()
|
||||
flowID := common.GenerateUUID()
|
||||
authorizationURL, err := buildBoxAuthorizationURL(clientID, redirectURI, flowID)
|
||||
if err != nil {
|
||||
return nil, common.CodeServerError, err
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
permissionresponse "ragflow/internal/permission/response"
|
||||
"ragflow/internal/service"
|
||||
"ragflow/internal/storage"
|
||||
"ragflow/internal/utility"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
@@ -198,7 +197,7 @@ func (d *DatasetService) CreateDataset(ctx context.Context, req *service.CreateD
|
||||
}
|
||||
}
|
||||
|
||||
kbID := utility.GenerateToken()
|
||||
kbID := common.GenerateToken()
|
||||
status := string(entity.StatusValid)
|
||||
// Fall back to a numbered name when the requested one is already taken.
|
||||
dedupedName, dedupeErr := d.dedupeDatasetName(ctx, name, tenantID)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"ragflow/internal/utility"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -464,7 +463,7 @@ func (dr *DeepResearcher) tavilyRetrieve(ctx context.Context, apiKey, query stri
|
||||
chunks := make([]map[string]interface{}, 0, len(apiResp.Results))
|
||||
aggs := make([]interface{}, 0, len(apiResp.Results))
|
||||
for _, r := range apiResp.Results {
|
||||
id := utility.GenerateToken()
|
||||
id := common.GenerateToken()
|
||||
chunks = append(chunks, map[string]interface{}{
|
||||
"chunk_id": id,
|
||||
"content_ltks": tokenizeText(r.Content),
|
||||
|
||||
@@ -172,7 +172,7 @@ func (s *DocumentService) newAFileFromKB(ctx context.Context, tenantID, name, pa
|
||||
}
|
||||
loc := ""
|
||||
folder := &entity.File{
|
||||
ID: utility.GenerateToken(),
|
||||
ID: common.GenerateToken(),
|
||||
ParentID: parentID,
|
||||
TenantID: tenantID,
|
||||
CreatedBy: tenantID,
|
||||
@@ -203,7 +203,7 @@ func (s *DocumentService) addFileFromKB(ctx context.Context, doc *entity.Documen
|
||||
if doc.Location != nil {
|
||||
loc = *doc.Location
|
||||
}
|
||||
fileID := utility.GenerateToken()
|
||||
fileID := common.GenerateToken()
|
||||
file := &entity.File{
|
||||
ID: fileID,
|
||||
ParentID: kbFolderID,
|
||||
@@ -220,7 +220,7 @@ func (s *DocumentService) addFileFromKB(ctx context.Context, doc *entity.Documen
|
||||
}
|
||||
docID := doc.ID
|
||||
if err := s.file2DocumentDAO.Create(ctx, dao.DB, &entity.File2Document{
|
||||
ID: utility.GenerateToken(),
|
||||
ID: common.GenerateToken(),
|
||||
FileID: &fileID,
|
||||
DocumentID: &docID,
|
||||
}); err != nil {
|
||||
@@ -311,7 +311,7 @@ func normalizeWebDocumentName(name, contentType string, blob []byte) string {
|
||||
// content hash. parserID/parserConfig are resolved by the caller (see
|
||||
// resolveDocumentParser); blob may be nil for the empty/virtual document.
|
||||
func (s *DocumentService) newDatasetDocument(kb *entity.Knowledgebase, tenantID, filename, location, filetype, parserID string, parserConfig entity.JSONMap, src string, size int64, blob []byte) *entity.Document {
|
||||
docID := utility.GenerateToken()
|
||||
docID := common.GenerateToken()
|
||||
parserConfig = cloneParserConfigForDocument(parserConfig)
|
||||
status := "1"
|
||||
suffix := ""
|
||||
|
||||
@@ -229,7 +229,7 @@ func (s *File2DocumentService) convertFiles(ctx context.Context, fileIDs, kbIDs
|
||||
parserID, parserConfig := resolveDocumentParser(ctx, kb, docName, utility.FileType(file.Type), cloneParserConfigForDocument(kb.ParserConfig))
|
||||
suffix := strings.TrimPrefix(filepath.Ext(docName), ".")
|
||||
doc := &entity.Document{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
KbID: kb.ID,
|
||||
ParserID: parserID,
|
||||
ParserConfig: parserConfig,
|
||||
@@ -256,7 +256,7 @@ func (s *File2DocumentService) convertFiles(ctx context.Context, fileIDs, kbIDs
|
||||
}
|
||||
|
||||
mapping := &entity.File2Document{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
FileID: &fileID,
|
||||
DocumentID: &doc.ID,
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"ragflow/internal/common"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -298,7 +299,7 @@ func syncDocumentStagedLocation(sourceType, docID, filename string) string {
|
||||
if sourceType == "" {
|
||||
sourceType = "sync"
|
||||
}
|
||||
return fmt.Sprintf("sync/%s/.staged/%s/%s%s", sourceType, utility.GenerateToken(), docID, ext)
|
||||
return fmt.Sprintf("sync/%s/.staged/%s/%s%s", sourceType, common.GenerateToken(), docID, ext)
|
||||
}
|
||||
|
||||
// errorsIsRecordNotFound reports whether an error is GORM's not-found error.
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
enginetypes "ragflow/internal/engine/types"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/storage"
|
||||
"ragflow/internal/utility"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -72,7 +71,7 @@ func (s *FileCommitService) CreateCommit(ctx context.Context, folderID, authorID
|
||||
}
|
||||
|
||||
// 3. Create commit record
|
||||
commitID := utility.GenerateUUID()
|
||||
commitID := common.GenerateUUID()
|
||||
nowMs := time.Now().UnixMilli()
|
||||
|
||||
commit := &entity.FileCommit{
|
||||
@@ -112,7 +111,7 @@ func (s *FileCommitService) CreateCommit(ctx context.Context, folderID, authorID
|
||||
|
||||
for _, change := range changes {
|
||||
item := &entity.FileCommitItem{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
CommitID: commitID,
|
||||
FileID: change.FileID,
|
||||
Operation: change.Operation,
|
||||
@@ -280,7 +279,7 @@ func (s *FileCommitService) RecordPageEdit(ctx context.Context, in PageEditCommi
|
||||
// Parent chain: previous commit that touched the same page file key.
|
||||
fileID := wikiFileID(in.DatasetID, in.PageType, in.Slug)
|
||||
|
||||
commitID := utility.GenerateUUID()
|
||||
commitID := common.GenerateUUID()
|
||||
|
||||
diffText := unifiedDiff(in.OldContent, in.NewContent)
|
||||
if diffText == "" {
|
||||
@@ -295,7 +294,7 @@ func (s *FileCommitService) RecordPageEdit(ctx context.Context, in PageEditCommi
|
||||
}
|
||||
|
||||
item := &entity.FileCommitItem{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
CommitID: commitID,
|
||||
FileID: fileID,
|
||||
Operation: operation,
|
||||
|
||||
@@ -140,7 +140,7 @@ func (s *FileService) initSkillsFolder(ctx context.Context, rootID, tenantID str
|
||||
}
|
||||
|
||||
folder := &entity.File{
|
||||
ID: utility.GenerateToken(),
|
||||
ID: common.GenerateToken(),
|
||||
ParentID: rootID,
|
||||
TenantID: tenantID,
|
||||
CreatedBy: tenantID,
|
||||
|
||||
@@ -137,7 +137,7 @@ func (s *FileService) UploadFile(ctx context.Context, tenantID, parentID string,
|
||||
}
|
||||
|
||||
fileRecord := &entity.File{
|
||||
ID: utility.GenerateToken(),
|
||||
ID: common.GenerateToken(),
|
||||
ParentID: lastFolder.ID,
|
||||
TenantID: tenantID,
|
||||
CreatedBy: tenantID,
|
||||
@@ -280,7 +280,7 @@ func (s *FileService) checkUploadInfoHealth(ctx context.Context, userID, filenam
|
||||
}
|
||||
|
||||
func (s *FileService) storeUploadInfoBlob(ctx context.Context, storageImpl storage.Storage, userID, filename, contentType string, data []byte) (map[string]interface{}, error) {
|
||||
location := utility.GenerateUUID()
|
||||
location := common.GenerateUUID()
|
||||
bucket := fmt.Sprintf("%s-downloads", userID)
|
||||
if err := storageImpl.Put(ctx, bucket, location, data); err != nil {
|
||||
return nil, fmt.Errorf("failed to store file: %w", err)
|
||||
|
||||
@@ -144,7 +144,7 @@ func (s *MCPService) CreateMCPServer(ctx context.Context, tenantID string, req C
|
||||
variables["tools"] = tools
|
||||
|
||||
server := &entity.MCPServer{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
Name: req.Name,
|
||||
TenantID: tenantID,
|
||||
URL: req.URL,
|
||||
@@ -755,7 +755,7 @@ func (s *MCPService) ImportServers(ctx context.Context, tenantID string, servers
|
||||
variables["tools"] = toolsAsMap(tools)
|
||||
|
||||
server := &entity.MCPServer{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
TenantID: tenantID,
|
||||
Name: newName,
|
||||
URL: url,
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/entity/models"
|
||||
"ragflow/internal/utility"
|
||||
|
||||
"slices"
|
||||
"sort"
|
||||
@@ -523,7 +522,7 @@ func (s *MemoryService) CreateMemory(ctx context.Context, tenantID string, req *
|
||||
memoryTypeInt := dao.CalculateMemoryType(uniqueMemoryTypes)
|
||||
systemPrompt := PromptAssembler{}.AssembleSystemPrompt(uniqueMemoryTypes)
|
||||
|
||||
newID := utility.GenerateUUID()
|
||||
newID := common.GenerateUUID()
|
||||
|
||||
memory := &entity.Memory{
|
||||
ID: newID,
|
||||
|
||||
@@ -64,7 +64,6 @@ import (
|
||||
"ragflow/internal/engine/kvrocks"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/entity/models"
|
||||
"ragflow/internal/utility"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -388,7 +387,7 @@ func (s *MemoryMessageService) insertMemoryTask(ctx context.Context, task *entit
|
||||
// generator later without changing call sites. Avoids an
|
||||
// import-cycle with internal/uuid at the package boundary.
|
||||
func newUUIDString() string {
|
||||
return utility.GenerateUUID()
|
||||
return common.GenerateUUID()
|
||||
}
|
||||
|
||||
// publishMemoryTaskWakeup publishes only the durable task identity. Workers
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"ragflow/internal/dao"
|
||||
"ragflow/internal/entity"
|
||||
modelModule "ragflow/internal/entity/models"
|
||||
"ragflow/internal/utility"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -122,7 +121,7 @@ func (m *ModelProviderService) AddModelProvider(ctx context.Context, providerNam
|
||||
return common.CodeSuccess, nil
|
||||
}
|
||||
|
||||
providerID := utility.GenerateToken()
|
||||
providerID := common.GenerateToken()
|
||||
|
||||
tenantModelProvider := &entity.TenantModelProvider{
|
||||
ID: providerID,
|
||||
@@ -374,7 +373,7 @@ func (m *ModelProviderService) CreateProviderInstance(ctx context.Context, provi
|
||||
}
|
||||
providerName := provider.ProviderName
|
||||
|
||||
instanceID := utility.GenerateToken()
|
||||
instanceID := common.GenerateToken()
|
||||
|
||||
extra := make(map[string]string)
|
||||
extra["region"] = region
|
||||
@@ -490,7 +489,7 @@ func (m *ModelProviderService) CreateNameOnlyProviderInstance(ctx context.Contex
|
||||
return common.CodeNotFound, fmt.Errorf("provider '%s' does not exist", providerIDOrName)
|
||||
}
|
||||
|
||||
instanceID := utility.GenerateToken()
|
||||
instanceID := common.GenerateToken()
|
||||
|
||||
tenantModelInstance := &entity.TenantModelInstance{
|
||||
ID: instanceID,
|
||||
@@ -549,7 +548,7 @@ func (m *ModelProviderService) addModelToInstance(ctx context.Context, tenantID,
|
||||
return fmt.Errorf("fail to marshal extra: %w", err)
|
||||
}
|
||||
|
||||
modelID := utility.GenerateToken()
|
||||
modelID := common.GenerateToken()
|
||||
tenantModel := &entity.TenantModel{
|
||||
ID: modelID,
|
||||
ModelName: model.ModelName,
|
||||
@@ -1630,7 +1629,7 @@ func (m *ModelProviderService) ensureOCRProviderFromEnv(ctx context.Context, ten
|
||||
if !dao.IsNotFoundErr(err) {
|
||||
return fmt.Errorf("failed to get provider %s: %w", providerName, err)
|
||||
}
|
||||
providerID := utility.GenerateToken()
|
||||
providerID := common.GenerateToken()
|
||||
provider = &entity.TenantModelProvider{
|
||||
ID: providerID,
|
||||
TenantID: tenantID,
|
||||
@@ -1653,7 +1652,7 @@ func (m *ModelProviderService) ensureOCRProviderFromEnv(ctx context.Context, ten
|
||||
if !dao.IsNotFoundErr(err) {
|
||||
return fmt.Errorf("failed to get instance for %s: %w", providerName, err)
|
||||
}
|
||||
instanceID := utility.GenerateToken()
|
||||
instanceID := common.GenerateToken()
|
||||
instance = &entity.TenantModelInstance{
|
||||
ID: instanceID,
|
||||
ProviderID: provider.ID,
|
||||
@@ -1684,7 +1683,7 @@ func (m *ModelProviderService) ensureOCRProviderFromEnv(ctx context.Context, ten
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal extra for %s model: %w", providerName, err)
|
||||
}
|
||||
modelID := utility.GenerateToken()
|
||||
modelID := common.GenerateToken()
|
||||
tenantModel := &entity.TenantModel{
|
||||
ID: modelID,
|
||||
ModelName: modelName,
|
||||
@@ -2560,7 +2559,7 @@ func (m *ModelProviderService) AddModel(ctx context.Context, request *AddModelRe
|
||||
return common.CodeServerError, errors.New("fail to marshal extra")
|
||||
}
|
||||
|
||||
modelID := utility.GenerateToken()
|
||||
modelID := common.GenerateToken()
|
||||
tenantModel := &entity.TenantModel{
|
||||
ID: modelID,
|
||||
ModelName: modelName,
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/permission"
|
||||
permissionresponse "ragflow/internal/permission/response"
|
||||
"ragflow/internal/utility"
|
||||
)
|
||||
|
||||
// SearchService search service
|
||||
@@ -203,7 +202,7 @@ func (s *SearchService) CreateSearch(ctx context.Context, userID string, name st
|
||||
}
|
||||
|
||||
// Generate UUID for search ID (same as Python get_uuid())
|
||||
searchID := utility.GenerateUUID()
|
||||
searchID := common.GenerateUUID()
|
||||
|
||||
// Generate unique name (same as Python duplicate_name)
|
||||
// search.name is a 128-byte column; keep generated names within it.
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"ragflow/internal/engine"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/service/file"
|
||||
"ragflow/internal/utility"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -123,7 +122,7 @@ func (s *SkillSpaceService) getSkillsFolderID(ctx context.Context, tenantID stri
|
||||
|
||||
// Skills folder not found, create it
|
||||
common.Info("Creating skills folder", zap.String("tenant_id", tenantID))
|
||||
folderID := utility.GenerateUUID()
|
||||
folderID := common.GenerateUUID()
|
||||
folder := &entity.File{
|
||||
ID: folderID,
|
||||
ParentID: rootFolder.ID,
|
||||
@@ -218,8 +217,8 @@ func (s *SkillSpaceService) CreateSpace(ctx context.Context, req *CreateSpaceReq
|
||||
}
|
||||
|
||||
// Generate space ID and folder ID
|
||||
spaceID := utility.GenerateUUID()
|
||||
folderID := utility.GenerateUUID()
|
||||
spaceID := common.GenerateUUID()
|
||||
folderID := common.GenerateUUID()
|
||||
|
||||
// Create folder for the space under skills folder
|
||||
folder := &entity.File{
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"ragflow/internal/dao"
|
||||
"ragflow/internal/engine"
|
||||
"ragflow/internal/entity"
|
||||
"ragflow/internal/utility"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -806,7 +805,7 @@ func (s *TenantService) AddMember(ctx context.Context, userID, tenantID string,
|
||||
|
||||
status := string(entity.StatusValid)
|
||||
ut := &entity.UserTenant{
|
||||
ID: utility.GenerateUUID(),
|
||||
ID: common.GenerateUUID(),
|
||||
UserID: invitee.ID,
|
||||
TenantID: tenantID,
|
||||
Role: TenantRoleInvite,
|
||||
|
||||
+12
-12
@@ -133,8 +133,8 @@ func (s *UserService) Register(ctx context.Context, req *RegisterRequest) (*enti
|
||||
return nil, common.CodeServerError, fmt.Errorf("failed to hash password: %w", err)
|
||||
}
|
||||
|
||||
userID := utility.GenerateToken()
|
||||
accessToken := utility.GenerateToken()
|
||||
userID := common.GenerateToken()
|
||||
accessToken := common.GenerateToken()
|
||||
status := "1"
|
||||
loginChannel := "password"
|
||||
isSuperuser := false
|
||||
@@ -205,7 +205,7 @@ func (s *UserService) Register(ctx context.Context, req *RegisterRequest) (*enti
|
||||
ParserIDs: "naive:General,qa:Q&A,manual:Manual,table:Table,paper:Research Paper,book:Book,laws:Laws,presentation:Presentation,picture:Picture,one:One,audio:Audio,email:Email,tag:Tag",
|
||||
Status: &status,
|
||||
}
|
||||
userTenantID := utility.GenerateToken()
|
||||
userTenantID := common.GenerateToken()
|
||||
userTenant := &entity.UserTenant{
|
||||
ID: userTenantID,
|
||||
UserID: userID,
|
||||
@@ -214,7 +214,7 @@ func (s *UserService) Register(ctx context.Context, req *RegisterRequest) (*enti
|
||||
InvitedBy: userID,
|
||||
Status: &status,
|
||||
}
|
||||
fileID := utility.GenerateToken()
|
||||
fileID := common.GenerateToken()
|
||||
file__ := ""
|
||||
rootFile := &entity.File{
|
||||
ID: fileID,
|
||||
@@ -275,7 +275,7 @@ func (s *UserService) Login(ctx context.Context, req *LoginRequest) (*entity.Use
|
||||
}
|
||||
|
||||
// Generate new access token
|
||||
token := utility.GenerateToken()
|
||||
token := common.GenerateToken()
|
||||
user.AccessToken = &token
|
||||
now := time.Now().Truncate(time.Second)
|
||||
user.LastLoginTime = &now
|
||||
@@ -312,7 +312,7 @@ func (s *UserService) LoginByEmail(ctx context.Context, req *EmailLoginRequest)
|
||||
}
|
||||
|
||||
// Generate new access token
|
||||
token := utility.GenerateToken()
|
||||
token := common.GenerateToken()
|
||||
user.AccessToken = &token
|
||||
now := time.Now().Truncate(time.Second)
|
||||
user.LastLoginTime = &now
|
||||
@@ -498,7 +498,7 @@ func (s *UserService) GetUserByToken(ctx context.Context, authorization string)
|
||||
|
||||
// Extract access token from authorization header
|
||||
// Equivalent to: access_token = str(jwt.loads(authorization)) in Python
|
||||
accessToken, err := utility.ExtractAccessToken(authorization, secretKey)
|
||||
accessToken, err := common.ExtractAccessToken(authorization, secretKey)
|
||||
if err != nil {
|
||||
return nil, common.CodeUnauthorized, fmt.Errorf("invalid authorization token: %w", err)
|
||||
}
|
||||
@@ -526,7 +526,7 @@ func (s *UserService) UpdateUserAccessToken(ctx context.Context, user *entity.Us
|
||||
func (s *UserService) Logout(ctx context.Context, user *entity.User) (common.ErrorCode, error) {
|
||||
// Invalidate token by setting it to an invalid value
|
||||
// Similar to Python implementation: "INVALID_" + secrets.token_hex(16)
|
||||
invalidToken := "INVALID_" + utility.GenerateToken()
|
||||
invalidToken := "INVALID_" + common.GenerateToken()
|
||||
err := s.UpdateUserAccessToken(ctx, user, invalidToken)
|
||||
if err != nil {
|
||||
return common.CodeServerError, err
|
||||
@@ -666,7 +666,7 @@ func (s *UserService) UpdateUserSettings(ctx context.Context, user *entity.User,
|
||||
return common.CodeExceptionError, err
|
||||
}
|
||||
user.Password = &hashedPassword
|
||||
invalidToken := "INVALID_" + utility.GenerateToken()
|
||||
invalidToken := "INVALID_" + common.GenerateToken()
|
||||
user.AccessToken = &invalidToken
|
||||
}
|
||||
}
|
||||
@@ -714,7 +714,7 @@ func (s *UserService) ChangePassword(ctx context.Context, user *entity.User, req
|
||||
return common.CodeServerError, fmt.Errorf("failed to hash new password: %w", err)
|
||||
}
|
||||
user.Password = &hashedPassword
|
||||
invalidToken := "INVALID_" + utility.GenerateToken()
|
||||
invalidToken := "INVALID_" + common.GenerateToken()
|
||||
user.AccessToken = &invalidToken
|
||||
}
|
||||
|
||||
@@ -966,7 +966,7 @@ func (s *UserService) ForgotIssueCaptcha(ctx context.Context, email string) (cap
|
||||
if err != nil {
|
||||
return "", "", common.CodeServerError, err
|
||||
}
|
||||
captchaID = utility.GenerateToken()
|
||||
captchaID = common.GenerateToken()
|
||||
if ok := kvrocks.Get().Set(ctx, utility.CaptchaIDRedisKey(captchaID), text, 60*time.Second); !ok {
|
||||
return "", "", common.CodeServerError, fmt.Errorf("failed to store captcha")
|
||||
}
|
||||
@@ -1187,7 +1187,7 @@ func (s *UserService) ForgotResetPassword(ctx context.Context, req *ForgotResetP
|
||||
|
||||
// Auto-login: rotate the access token like LoginByEmail does so the
|
||||
// handler can immediately mint an Authorization header.
|
||||
token := utility.GenerateToken()
|
||||
token := common.GenerateToken()
|
||||
user.AccessToken = &token
|
||||
now := time.Now().Truncate(time.Second)
|
||||
user.LastLoginTime = &now
|
||||
|
||||
@@ -19,8 +19,8 @@ package syncer
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/engine/kvrocks"
|
||||
"ragflow/internal/utility"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
@@ -48,7 +48,7 @@ type ConnectorLock struct {
|
||||
|
||||
// NewConnectorLock creates an empty connector/KB lock.
|
||||
func NewConnectorLock() *ConnectorLock {
|
||||
return &ConnectorLock{holder: utility.GenerateUUID(), local: map[string]struct{}{}, redis: map[string]*kvrocks.DistributedLock{}}
|
||||
return &ConnectorLock{holder: common.GenerateUUID(), local: map[string]struct{}{}, redis: map[string]*kvrocks.DistributedLock{}}
|
||||
}
|
||||
|
||||
// TryLock attempts to acquire the connector/KB lock without blocking.
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"ragflow/internal/service"
|
||||
documentservice "ragflow/internal/service/document"
|
||||
syncerconnector "ragflow/internal/syncer/connector"
|
||||
"ragflow/internal/utility"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -94,7 +93,7 @@ func New(config Config, taskDAO *dao.SyncTaskDAO, registry ConnectorRegistry, si
|
||||
}
|
||||
|
||||
return &Syncer{
|
||||
id: utility.GenerateUUID(),
|
||||
id: common.GenerateUUID(),
|
||||
config: config,
|
||||
queue: queue,
|
||||
scheduler: scheduler,
|
||||
|
||||
Reference in New Issue
Block a user