2026-06-25 13:36:49 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/hex"
|
|
|
|
|
|
2026-07-18 11:00:08 +08:00
|
|
|
pipelinepkg "ragflow/internal/ingestion/pipeline"
|
2026-06-25 13:36:49 +08:00
|
|
|
"ragflow/internal/utility"
|
|
|
|
|
|
|
|
|
|
"github.com/zeebo/xxh3"
|
|
|
|
|
)
|
|
|
|
|
|
2026-07-18 11:00:08 +08:00
|
|
|
// selectUploadParser resolves the parser_id for a document by delegating to
|
|
|
|
|
// the builtin pipeline registry, which owns the file-type-to-parser mapping.
|
2026-06-25 13:36:49 +08:00
|
|
|
func selectUploadParser(docType utility.FileType, filename, defaultParser string) string {
|
2026-07-18 11:00:08 +08:00
|
|
|
registry, err := pipelinepkg.DefaultRegistry()
|
|
|
|
|
if err != nil || registry == nil {
|
2026-06-25 13:36:49 +08:00
|
|
|
return defaultParser
|
|
|
|
|
}
|
2026-07-18 11:00:08 +08:00
|
|
|
return registry.DefaultParserID(string(docType), filename, defaultParser)
|
2026-06-25 13:36:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// contentHashHex mirrors Python xxhash.xxh128(blob).hexdigest().
|
|
|
|
|
func contentHashHex(blob []byte) string {
|
|
|
|
|
sum := xxh3.Hash128(blob).Bytes()
|
|
|
|
|
return hex.EncodeToString(sum[:])
|
|
|
|
|
}
|