Migrate backend jobs to Redis Streams

This commit is contained in:
“ydy0615”
2026-06-06 15:44:00 +08:00
parent 2c7a02f587
commit 81f711ef0b
69 changed files with 2709 additions and 6291 deletions
+24 -1
View File
@@ -17,6 +17,8 @@ function clipDocContext(content = '', limit = 0) {
return `${content.slice(0, limit)}...`
}
const AUDIO_EXT_RE = /\.(wav|mp3|m4a|ogg|flac)$/i
export function normalizeDocType(value = '') {
const lower = String(value || '').trim().toLowerCase()
if (lower === 'txt' || lower === 'text' || lower === 'plain') return 'txt'
@@ -26,6 +28,12 @@ export function normalizeDocType(value = '') {
if (lower === 'doc' || lower === 'docx' || lower === 'word') return 'docx'
if (lower === 'ppt' || lower === 'pptx' || lower === 'powerpoint') return 'pptx'
if (lower === 'pdf') return 'pdf'
// Audio types - map to their extensions for doc block display
if (lower === 'wav' || lower === 'wave') return 'wav'
if (lower === 'mp3' || lower === 'mpeg') return 'mp3'
if (lower === 'm4a' || lower === 'aac') return 'm4a'
if (lower === 'ogg' || lower === 'opus') return 'ogg'
if (lower === 'flac') return 'flac'
return 'txt'
}
@@ -37,9 +45,22 @@ export function getDocTypeFromFilename(name = '') {
if (lower.endsWith('.json')) return 'json'
if (lower.endsWith('.toml')) return 'toml'
if (lower.endsWith('.yaml') || lower.endsWith('.yml')) return 'yaml'
// Audio types - preserve the actual extension for display
if (lower.endsWith('.wav')) return 'wav'
if (lower.endsWith('.mp3') || lower.endsWith('.mpeg')) return 'mp3'
if (lower.endsWith('.m4a') || lower.endsWith('.aac')) return 'm4a'
if (lower.endsWith('.ogg') || lower.endsWith('.opus')) return 'ogg'
if (lower.endsWith('.flac')) return 'flac'
return 'txt'
}
export function isAudioFile(file) {
if (!file) return false
const name = String(file.name || '').toLowerCase()
const type = String(file.type || '').toLowerCase()
return AUDIO_EXT_RE.test(name) || type.startsWith('audio/')
}
export function isSupportedDocFile(file) {
if (!file) return false
const name = String(file.name || '').toLowerCase()
@@ -53,6 +74,7 @@ export function isSupportedDocFile(file) {
name.endsWith('.docx') ||
name.endsWith('.pptx') ||
name.endsWith('.pdf') ||
AUDIO_EXT_RE.test(name) ||
type === 'text/plain' ||
type === 'application/json' ||
type === 'text/yaml' ||
@@ -60,7 +82,8 @@ export function isSupportedDocFile(file) {
type === 'application/x-yaml' ||
type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
type === 'application/vnd.openxmlformats-officedocument.presentationml.presentation' ||
type === 'application/pdf'
type === 'application/pdf' ||
type.startsWith('audio/')
)
}