mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-08 08:28:02 +08:00
@@ -463,11 +463,11 @@ func (s *Service) getInitTenantLLM(ctx context.Context, userID string) ([]*entit
|
||||
// Remove duplicates based on (tenant_id, llm_factory, llm_name)
|
||||
seen := make(map[string]bool)
|
||||
var uniqueLLMs []*entity.TenantLLM
|
||||
for _, tllm := range tenantLLMs {
|
||||
key := fmt.Sprintf("%s|%s|%s", tllm.TenantID, tllm.LLMFactory, *tllm.LLMName)
|
||||
for _, tenantLLM := range tenantLLMs {
|
||||
key := fmt.Sprintf("%s|%s|%s", tenantLLM.TenantID, tenantLLM.LLMFactory, *tenantLLM.LLMName)
|
||||
if !seen[key] {
|
||||
seen[key] = true
|
||||
uniqueLLMs = append(uniqueLLMs, tllm)
|
||||
uniqueLLMs = append(uniqueLLMs, tenantLLM)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ func (dao *ChatSessionDAO) DeleteByID(ctx context.Context, db *gorm.DB, id strin
|
||||
|
||||
// ListByChatID lists chat sessions by chat ID
|
||||
func (dao *ChatSessionDAO) ListByChatID(ctx context.Context, db *gorm.DB, chatID, sessionID, name, orderby string, desc bool, page, pageSize int) ([]*entity.ChatSession, error) {
|
||||
var convs []*entity.ChatSession
|
||||
var chatSessions []*entity.ChatSession
|
||||
query := db.WithContext(ctx).Where("dialog_id = ?", chatID)
|
||||
if sessionID != "" {
|
||||
query = query.Where("id = ?", sessionID)
|
||||
@@ -132,8 +132,8 @@ func (dao *ChatSessionDAO) ListByChatID(ctx context.Context, db *gorm.DB, chatID
|
||||
}
|
||||
query = query.Offset((page - 1) * pageSize).Limit(pageSize)
|
||||
}
|
||||
err := query.Find(&convs).Error
|
||||
return convs, err
|
||||
err := query.Find(&chatSessions).Error
|
||||
return chatSessions, err
|
||||
}
|
||||
|
||||
// CheckDialogExists checks if a dialog exists with given tenant_id and dialog_id
|
||||
|
||||
@@ -189,8 +189,7 @@ func (dao *CompilationTemplateDAO) UpdateFields(ctx context.Context, db *gorm.DB
|
||||
Where("id = ?", id).Updates(m).Error
|
||||
}
|
||||
|
||||
// UpdateStatusByGroup flips the status of every valid template in a group,
|
||||
// mirroring Python group delete's child cascade.
|
||||
// UpdateStatusByGroup flips the status of every valid template in a group
|
||||
func (dao *CompilationTemplateDAO) UpdateStatusByGroup(ctx context.Context, db *gorm.DB, groupID, status string) error {
|
||||
return db.WithContext(ctx).Model(&entity.CompilationTemplate{}).
|
||||
Where("group_id = ? AND status = ?", groupID, string(entity.StatusValid)).
|
||||
@@ -206,7 +205,7 @@ func (dao *CompilationTemplateDAO) UpdateStatusByID(ctx context.Context, db *gor
|
||||
|
||||
// HardDeleteOrphansByName physically removes stale, invalid, non-built-in
|
||||
// templates of the given name within the group, mirroring Python
|
||||
// _purge_stale_invalid_children (which DELETEs orphaned duplicate names after a
|
||||
// _purge_stale_invalid_children (which Deletes orphaned duplicate names after a
|
||||
// group child is soft-deleted). The deletion is scoped to the group so a
|
||||
// same-named template in another group is never affected. These rows were
|
||||
// soft-deleted in a prior operation but must be permanently purged to keep the
|
||||
|
||||
@@ -49,7 +49,7 @@ var builtinCompilationTemplateKinds = []struct {
|
||||
{Kind: "timeline", Name: "Timeline"},
|
||||
}
|
||||
|
||||
func strptr(s string) *string { return &s }
|
||||
func strPTR(s string) *string { return &s }
|
||||
|
||||
// builtinTemplateID derives a deterministic, <=32-byte id for a built-in
|
||||
// compilation template from "<builtin-group-id>-<kind>". A plain concatenation
|
||||
@@ -92,7 +92,7 @@ func SeedBuiltinCompilationTemplatesForTenant(ctx context.Context, db *gorm.DB,
|
||||
ID: BuiltinCompilationTemplateGroupID,
|
||||
TenantID: "", // global built-in catalogue
|
||||
Name: "Built-in templates",
|
||||
Status: strptr(valid),
|
||||
Status: &valid,
|
||||
}
|
||||
if err := tx.WithContext(ctx).Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "id"}},
|
||||
@@ -105,11 +105,11 @@ func SeedBuiltinCompilationTemplatesForTenant(ctx context.Context, db *gorm.DB,
|
||||
tmpl := &entity.CompilationTemplate{
|
||||
ID: builtinTemplateID(t.Kind),
|
||||
TenantID: nil, // global built-in catalogue
|
||||
GroupID: strptr(BuiltinCompilationTemplateGroupID),
|
||||
GroupID: strPTR(BuiltinCompilationTemplateGroupID),
|
||||
Name: t.Name,
|
||||
Kind: t.Kind,
|
||||
Config: entity.JSONMap{"kind": t.Kind},
|
||||
Status: strptr(valid),
|
||||
Status: &valid,
|
||||
}
|
||||
if err := tx.WithContext(ctx).Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "id"}},
|
||||
|
||||
@@ -130,7 +130,7 @@ func TestDocumentGetByKBIDOrdersByCreateTime(t *testing.T) {
|
||||
dao := NewDocumentDAO()
|
||||
docs, total, err := dao.GetByKBID(ctx, db, "kb1")
|
||||
if err != nil {
|
||||
t.Fatalf("GetByKBID failed: %v", err)
|
||||
t.Fatalf("fail to get document by dataset id: %v", err)
|
||||
}
|
||||
if total != 2 {
|
||||
t.Fatalf("expected total=2, got %d", total)
|
||||
|
||||
Reference in New Issue
Block a user