feat: add Vision LLM integration (CLIP + Qwen3-VL cascade)

- Add Qwen3-VL dynamic management (start/stop/status CLI)
- Add CLIP + Qwen3-VL cascade detection strategy
- Add Vision CLI commands (vision start/stop/status, detect)
- Add cascade_vision processor module
- Add clip processor module
- Add qwen_vl_manager module

Changes:
- scripts/start_qwen3vl.sh, stop_qwen3vl.sh: Qwen3-VL management scripts
- src/core/vision/: Qwen3-VL manager module
- src/core/processor/cascade_vision.rs: CLIP + Qwen3-VL cascade logic
- src/core/processor/clip.rs: CLIP classification and detection
- src/api/clip_api.rs: CLIP API endpoints
- src/cli/vision.rs: Vision CLI implementation
- src/cli/args.rs: Add Vision and Detect commands
- src/main.rs: Integrate Vision CLI
- src/core/mod.rs: Add vision module
- src/core/processor/mod.rs: Add cascade_vision module
This commit is contained in:
Accusys
2026-06-13 16:25:52 +08:00
parent 834b0d4865
commit 17e4e15860
37 changed files with 2185 additions and 294 deletions
+31 -13
View File
@@ -6,7 +6,9 @@ async fn main() -> Result<()> {
dotenv::from_filename("/Users/accusys/momentry_core_0.1/.env.development").ok();
tracing_subscriber::fmt::init();
let pg = PostgresDb::init().await.context("Failed to init PostgreSQL")?;
let pg = PostgresDb::init()
.await
.context("Failed to init PostgreSQL")?;
let qdrant = QdrantDb::new();
let chunk_table = momentry_core::core::db::schema::table_name("chunk");
@@ -17,8 +19,8 @@ async fn main() -> Result<()> {
];
for uuid in &uuids {
let rows = sqlx::query_as::<_, (String, String, i64, i64, f64, f64, String, String)>(
&format!(
let rows =
sqlx::query_as::<_, (String, String, i64, i64, f64, f64, String, String)>(&format!(
"SELECT chunk_id, text_content, start_frame, end_frame, \
start_time, end_time, embedding::text, content::text \
FROM {} \
@@ -28,14 +30,16 @@ async fn main() -> Result<()> {
AND (text_content IS NOT NULL AND text_content != '') \
ORDER BY id",
chunk_table
),
)
.bind(uuid)
.fetch_all(pg.pool())
.await?;
))
.bind(uuid)
.fetch_all(pg.pool())
.await?;
let total = rows.len();
println!("[{}] Found {} sentence chunks with embeddings to sync to Qdrant", uuid, total);
println!(
"[{}] Found {} sentence chunks with embeddings to sync to Qdrant",
uuid, total
);
if total == 0 {
continue;
@@ -45,7 +49,17 @@ async fn main() -> Result<()> {
let mut stored = 0usize;
let mut errors = 0usize;
for (chunk_id, text, start_frame, end_frame, start_time, end_time, vector_text, _content_str) in &rows {
for (
chunk_id,
text,
start_frame,
end_frame,
start_time,
end_time,
vector_text,
_content_str,
) in &rows
{
let vector: Vec<f32> = serde_json::from_str(vector_text)
.map_err(|e| anyhow::anyhow!("Failed to parse vector for {}: {}", chunk_id, e))?;
@@ -73,9 +87,11 @@ async fn main() -> Result<()> {
println!(
" [{}] {}/{} ({:.1}%) | {:.0} vec/s | {} errors",
uuid.get(..8).unwrap_or(uuid),
stored, total,
stored,
total,
100.0 * stored as f64 / total as f64,
rate, errors,
rate,
errors,
);
}
}
@@ -84,7 +100,9 @@ async fn main() -> Result<()> {
println!(
"[{}] Done! {}/{} vectors synced ({} errors) in {:.1}s ({:.0} vec/s avg)",
uuid.get(..8).unwrap_or(uuid),
stored, total, errors,
stored,
total,
errors,
elapsed.as_secs_f64(),
stored as f64 / elapsed.as_secs_f64(),
);
+12 -11
View File
@@ -1,7 +1,5 @@
use anyhow::{Context, Result};
use momentry_core::{
Database, Embedder, PostgresDb, QdrantDb, VectorPayload,
};
use momentry_core::{Database, Embedder, PostgresDb, QdrantDb, VectorPayload};
use std::time::{Duration, Instant};
#[tokio::main]
@@ -9,16 +7,17 @@ async fn main() -> Result<()> {
dotenv::from_filename("/Users/accusys/momentry_core_0.1/.env.development").ok();
tracing_subscriber::fmt::init();
let pg = PostgresDb::init().await.context("Failed to init PostgreSQL")?;
let pg = PostgresDb::init()
.await
.context("Failed to init PostgreSQL")?;
let qdrant = QdrantDb::new();
let embedder = Embedder::new("embeddinggemma-300m".to_string());
let uuid = "63acd3bb02b5b9dfbb9d6db499fcc864";
let chunk_table = momentry_core::core::db::schema::table_name("chunk");
let rows = sqlx::query_as::<_, (String, String, i64, i64, f64, f64, String)>(
&format!(
"SELECT chunk_id, text_content, start_frame, end_frame, \
let rows = sqlx::query_as::<_, (String, String, i64, i64, f64, f64, String)>(&format!(
"SELECT chunk_id, text_content, start_frame, end_frame, \
start_time, end_time, content::text \
FROM {} \
WHERE file_uuid = $1 \
@@ -26,15 +25,17 @@ async fn main() -> Result<()> {
AND embedding IS NULL \
AND (text_content IS NOT NULL AND text_content != '') \
ORDER BY id",
chunk_table
),
)
chunk_table
))
.bind(uuid)
.fetch_all(pg.pool())
.await?;
let total = rows.len();
println!("Found {} sentence chunks without embedding for {}", total, uuid);
println!(
"Found {} sentence chunks without embedding for {}",
total, uuid
);
if total == 0 {
println!("Nothing to vectorize. Exiting.");