feat: face fix deployment + trace_* regeneration + executor stderr filter fix
- swift_face.swift: frame rounding (.rounded()), conf 0.75, min_size 64 - trace_* directories regenerated for KOBA (37 traces, start_frame 5307) - executor.rs: stderr filter now logs all non-empty stderr (was discarding) - VAD not skippable in ASRX (main_fixed.py Step 2 always runs) - Step 2.5 sentence boundary refinement added - Cluster agent async endpoints + similarity transparency - Keyword search: relationship text extraction, priority ordering - Face fix handoff doc for Studio team
This commit is contained in:
+80
-17
@@ -891,6 +891,34 @@ pub struct ChildChunkResult {
|
||||
pub speaker_ids: Vec<String>,
|
||||
}
|
||||
|
||||
/// Extract actual text content from a relationship chunk's content JSON.
|
||||
/// Returns the related sentence text if found, otherwise falls back to empty string.
|
||||
fn extract_relationship_text(content_json: &str) -> String {
|
||||
if let Ok(json) = serde_json::from_str::<serde_json::Value>(content_json) {
|
||||
if let Some(target) = json.get("target_node") {
|
||||
if let Some(label) = target.get("label").and_then(|v| v.as_str()) {
|
||||
if let Some(pos) = label.find(':') {
|
||||
let text_part = label[pos + 1..].trim();
|
||||
if !text_part.is_empty() {
|
||||
return text_part.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(source) = json.get("source_node") {
|
||||
if let Some(label) = source.get("label").and_then(|v| v.as_str()) {
|
||||
if let Some(pos) = label.find(':') {
|
||||
let text_part = label[pos + 1..].trim();
|
||||
if !text_part.is_empty() {
|
||||
return text_part.to_string();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String::new()
|
||||
}
|
||||
|
||||
impl PostgresDb {
|
||||
pub fn from_pool(pool: PgPool) -> Self {
|
||||
Self {
|
||||
@@ -1240,8 +1268,14 @@ impl PostgresDb {
|
||||
|
||||
// ── Trace Profiles (VLM metadata for face traces) ──
|
||||
sqlx::query("CREATE TABLE IF NOT EXISTS trace_profiles (id SERIAL PRIMARY KEY, file_uuid VARCHAR(32) NOT NULL, trace_id INTEGER NOT NULL, name VARCHAR(255), start_frame BIGINT, end_frame BIGINT, frame_count INTEGER, key_frame VARCHAR(255), key_face VARCHAR(255), status VARCHAR(50) DEFAULT 'pending', avg_confidence DOUBLE PRECISION, vlm_description TEXT, vlm_clothing TEXT, vlm_tags TEXT[], vlm_location VARCHAR(255), vlm_setting VARCHAR(255), vlm_lighting VARCHAR(100), vlm_weather VARCHAR(100), vlm_hand_objects TEXT, vlm_has_plants BOOLEAN, vlm_has_animals BOOLEAN, vlm_background TEXT, vlm_bg_tags TEXT[], vlm_model VARCHAR(64), metadata JSONB DEFAULT '{}', created_at TIMESTAMPTZ DEFAULT NOW(), updated_at TIMESTAMPTZ DEFAULT NOW(), UNIQUE(file_uuid, trace_id))").execute(pool).await?;
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS idx_trace_profiles_file_uuid ON trace_profiles(file_uuid)").execute(pool).await?;
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS idx_trace_profiles_name ON trace_profiles(name)").execute(pool).await?;
|
||||
sqlx::query(
|
||||
"CREATE INDEX IF NOT EXISTS idx_trace_profiles_file_uuid ON trace_profiles(file_uuid)",
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS idx_trace_profiles_name ON trace_profiles(name)")
|
||||
.execute(pool)
|
||||
.await?;
|
||||
sqlx::query("CREATE INDEX IF NOT EXISTS idx_trace_profiles_tags ON trace_profiles USING GIN(vlm_tags)").execute(pool).await?;
|
||||
|
||||
// ── Cuts ──
|
||||
@@ -3508,7 +3542,10 @@ impl PostgresDb {
|
||||
use sqlx::Row;
|
||||
|
||||
// Build WHERE clauses dynamically to handle optional params
|
||||
let mut clauses = vec!["text_content ILIKE $2".to_string(), "text_content != ''".to_string()];
|
||||
let mut clauses = vec![
|
||||
"(text_content ILIKE $2 OR content::text ILIKE $2)".to_string(),
|
||||
"COALESCE(text_content, content::text, '') != ''".to_string(),
|
||||
];
|
||||
let mut next_idx = 3;
|
||||
if file_uuid.is_some() {
|
||||
next_idx += 1;
|
||||
@@ -3522,11 +3559,22 @@ impl PostgresDb {
|
||||
let where_sql = clauses.join(" AND ");
|
||||
|
||||
let sql = format!(
|
||||
"SELECT chunk_id, file_uuid, chunk_type, text_content, start_time, end_time, \
|
||||
(1.0 - (POSITION(LOWER($1) IN LOWER(text_content))::float8 / NULLIF(LENGTH(text_content), 0)::float8))::float8 as score \
|
||||
"SELECT chunk_id, file_uuid, chunk_type, text_content, content::text as content_text, start_time, end_time, \
|
||||
CASE \
|
||||
WHEN text_content ILIKE $2 THEN \
|
||||
(1.0 - (POSITION(LOWER($1) IN LOWER(text_content))::float8 / NULLIF(LENGTH(text_content), 0)::float8)) \
|
||||
ELSE \
|
||||
(1.0 - (POSITION(LOWER($1) IN LOWER(content::text))::float8 / NULLIF(LENGTH(content::text), 0)::float8)) \
|
||||
END::float8 as score, \
|
||||
CASE chunk_type \
|
||||
WHEN 'sentence' THEN 1 \
|
||||
WHEN 'ocr' THEN 2 \
|
||||
WHEN 'cut' THEN 3 \
|
||||
ELSE 4 \
|
||||
END as priority \
|
||||
FROM {} \
|
||||
WHERE {} \
|
||||
ORDER BY score DESC \
|
||||
ORDER BY priority ASC, score DESC \
|
||||
LIMIT $3",
|
||||
table, where_sql
|
||||
);
|
||||
@@ -3542,17 +3590,32 @@ impl PostgresDb {
|
||||
|
||||
Ok(rows
|
||||
.into_iter()
|
||||
.map(|r| Bm25Result {
|
||||
file_uuid: r.get("file_uuid"),
|
||||
chunk_id: r.get("chunk_id"),
|
||||
chunk_type: r.get("chunk_type"),
|
||||
uuid: r.get("file_uuid"),
|
||||
text: r.get("text_content"),
|
||||
start_time: r.get("start_time"),
|
||||
end_time: r.get("end_time"),
|
||||
bm25_score: r.get("score"),
|
||||
vector_score: 0.0,
|
||||
combined_score: r.get("score"),
|
||||
.map(|r| {
|
||||
let chunk_type: String = r.get("chunk_type");
|
||||
let text: Option<String> = if chunk_type == "relationship" {
|
||||
let content_text: String = r.get("content_text");
|
||||
let extracted = extract_relationship_text(&content_text);
|
||||
if extracted.is_empty() {
|
||||
r.get("text_content")
|
||||
} else {
|
||||
Some(extracted)
|
||||
}
|
||||
} else {
|
||||
r.get("text_content")
|
||||
};
|
||||
|
||||
Bm25Result {
|
||||
file_uuid: r.get("file_uuid"),
|
||||
chunk_id: r.get("chunk_id"),
|
||||
chunk_type: r.get("chunk_type"),
|
||||
uuid: r.get("file_uuid"),
|
||||
text,
|
||||
start_time: r.get("start_time"),
|
||||
end_time: r.get("end_time"),
|
||||
bm25_score: r.get("score"),
|
||||
vector_score: 0.0,
|
||||
combined_score: r.get("score"),
|
||||
}
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user