3ad6f8740a
Phase 0: TKG builder populate face_detections from face.json - Fix face.json parser for pose_angle format - Call store_traced_faces.py to set trace_id - Skip if trace_id already populated Phase 1: Qdrant face embeddings integration - Add FaceEmbeddingDb module (src/core/db/face_embedding_db.rs) - Create dev_face_embeddings collection (dim=512) - Store 1122 face embeddings with pose metadata - API: init_collection, batch_upsert, search_similar Rule2: TKG edges → relationship chunks - Design: RULE2_TKG_RELATIONSHIP_V1.0.md - Implementation: rule2_ingest.rs - ChunkType::Relationship added - Edge types: SPEAKS_AS, MUTUAL_GAZE, CO_OCCURS_WITH, HAS_APPEARANCE, WEARS - Auto-trigger on TKG rebuild API: - POST /api/v1/file/:file_uuid/rule2 (vectorization) - POST /api/v1/file/:file_uuid/tkg/rebuild (auto Rule2) Test: 75 relationship chunks created + vectorized
68 lines
2.2 KiB
Rust
68 lines
2.2 KiB
Rust
use anyhow::Result;
|
|
use async_trait::async_trait;
|
|
|
|
pub mod schema;
|
|
|
|
use crate::core::chunk::Chunk;
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct SearchResult {
|
|
pub uuid: String,
|
|
pub chunk_id: String,
|
|
pub score: f32,
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait Database: Send + Sync {
|
|
async fn init() -> Result<Self>
|
|
where
|
|
Self: Sized;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait ChunkStore: Send + Sync {
|
|
async fn store_chunk(&self, chunk: &Chunk) -> Result<()>;
|
|
async fn get_chunks_by_uuid(&self, uuid: &str) -> Result<Vec<Chunk>>;
|
|
async fn get_all_chunks(&self) -> Result<Vec<Chunk>>;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait VectorStore: Send + Sync {
|
|
async fn store_vector(&self, chunk_id: &str, vector: &[f32]) -> Result<()>;
|
|
async fn search(&self, query_vector: &[f32], limit: usize) -> Result<Vec<SearchResult>>;
|
|
}
|
|
|
|
pub mod face_embedding_db;
|
|
pub mod identity_merge_history;
|
|
pub mod mongodb_db;
|
|
pub mod postgres_db;
|
|
pub mod qdrant_db;
|
|
pub mod redis_client;
|
|
pub mod redis_db;
|
|
pub use face_embedding_db::{FaceEmbeddingDb, FaceEmbeddingPayload, FaceEmbeddingPoint};
|
|
pub use identity_merge_history::{
|
|
AliasEntry, FacesTransferred, IdentityMergeHistory, IdentityMergeHistoryStore,
|
|
IdentitySnapshot, MergeHistoryEntry, MergeHistoryQuery, MergeParams, TargetIdentitySnapshot,
|
|
UndoneSnapshot,
|
|
};
|
|
pub use mongodb_db::MongoDb;
|
|
pub use postgres_db::{
|
|
Bm25Result, CandidateRecord, CreateApiKeyConfig, FileFaceRecord, FileIdentityRecord,
|
|
FileRecord, HybridSearchResult, IdentityChunkRecord, IdentityDetailRecord, IdentityFaceRecord,
|
|
IdentityFileRecord, MonitorJob, MonitorJobStats, MonitorJobStatus, PipelineType, PostgresDb,
|
|
ProcessorJobStatus, ProcessorResult, ProcessorType, ResourceRecord, VideoRecord, VideoStatus,
|
|
};
|
|
pub use qdrant_db::{QdrantDb, VectorPayload};
|
|
pub use redis_client::{
|
|
JobErrorMessage, MonitorJobRedis, ProcessorStatus as RedisProcessorStatus, ProgressData,
|
|
ProgressMessage, RedisClient,
|
|
};
|
|
pub use redis_db::RedisDb;
|
|
pub mod qdrant_workspace;
|
|
pub mod workspace_sqlite;
|
|
pub use qdrant_workspace::{QdrantWorkspace, ScrolledPoint, WorkspaceScrollResult};
|
|
pub use workspace_sqlite::{
|
|
workspace_path, ChunkRow, FaceDetectionBatchItem, FaceDetectionRow, PreChunkRow,
|
|
ProcessorResultRow, SpeakerDetectionBatchItem, SpeakerDetectionRow, WorkspaceDb,
|
|
};
|