| 89 | } |
| 90 | |
| 91 | func (s *Spec) SetDefaults() { |
| 92 | if s.BatchSize <= 0 { |
| 93 | s.BatchSize = defaultBatchSize |
| 94 | } |
| 95 | if s.BatchSizeBytes <= 0 { |
| 96 | s.BatchSizeBytes = defaultBatchSizeBytes |
| 97 | } |
| 98 | if s.BatchTimeout.Duration() <= 0 { |
| 99 | s.BatchTimeout = configtype.NewDuration(defaultBatchTimeout) |
| 100 | } |
| 101 | if s.PgxLogLevel == 0 { |
| 102 | s.PgxLogLevel = LogLevel(tracelog.LogLevelError) |
| 103 | } |
| 104 | if s.PgVectorConfig != nil { |
| 105 | for i := range s.PgVectorConfig.Tables { |
| 106 | // Ensure MetadataColumns is an empty slice when unset (not nil) |
| 107 | if s.PgVectorConfig.Tables[i].MetadataColumns == nil { |
| 108 | s.PgVectorConfig.Tables[i].MetadataColumns = []string{} |
| 109 | } |
| 110 | // Always ensure _cq_id is present in metadata columns |
| 111 | s.PgVectorConfig.Tables[i].MetadataColumns = ensureCQIDPresent(s.PgVectorConfig.Tables[i].MetadataColumns) |
| 112 | } |
| 113 | if s.PgVectorConfig.TextSplitter == nil { |
| 114 | s.PgVectorConfig.TextSplitter = &PgVectorTextSplitter{ |
| 115 | RecursiveText: PgVectorRecursiveText{ |
| 116 | ChunkSize: 1000, |
| 117 | ChunkOverlap: 500, |
| 118 | }, |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func ensureCQIDPresent(metadataColumns []string) []string { |
| 125 | if slices.Contains(metadataColumns, CQIDColumn) { |