17e4e15860
- 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
131 lines
4.0 KiB
Rust
131 lines
4.0 KiB
Rust
use axum::extract::Path;
|
|
use axum::routing::post;
|
|
use axum::{Json, Router};
|
|
use serde_json::{json, Value};
|
|
|
|
use crate::core::config;
|
|
use crate::core::db::postgres_db::PostgresDb;
|
|
use crate::core::pipeline as pipeline_core;
|
|
|
|
async fn handle_store_asrx(
|
|
Path(uuid): Path<String>,
|
|
) -> Result<Json<Value>, (axum::http::StatusCode, Json<Value>)> {
|
|
let db = PostgresDb::new(&config::DATABASE_URL).await.map_err(|e| {
|
|
tracing::error!("DB error: {}", e);
|
|
(
|
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
Json(json!({"error": "DB connection failed"})),
|
|
)
|
|
})?;
|
|
|
|
pipeline_core::store_asrx_chunks(&db, &uuid)
|
|
.await
|
|
.map_err(|e| {
|
|
tracing::error!("store_asrx error: {}", e);
|
|
(
|
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
Json(json!({"error": e.to_string()})),
|
|
)
|
|
})?;
|
|
|
|
Ok(Json(
|
|
json!({"success": true, "message": "ASRX chunks stored", "file_uuid": uuid}),
|
|
))
|
|
}
|
|
|
|
async fn handle_rule1(
|
|
Path(uuid): Path<String>,
|
|
) -> Result<Json<Value>, (axum::http::StatusCode, Json<Value>)> {
|
|
let db = PostgresDb::new(&config::DATABASE_URL).await.map_err(|e| {
|
|
tracing::error!("DB error: {}", e);
|
|
(
|
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
Json(json!({"error": "DB connection failed"})),
|
|
)
|
|
})?;
|
|
|
|
let count = pipeline_core::execute_rule1(&db, &uuid)
|
|
.await
|
|
.map_err(|e| {
|
|
tracing::error!("rule1 error: {}", e);
|
|
(
|
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
Json(json!({"error": e.to_string()})),
|
|
)
|
|
})?;
|
|
|
|
Ok(Json(
|
|
json!({"success": true, "message": format!("Rule 1 complete: {} chunks", count), "file_uuid": uuid, "chunks": count}),
|
|
))
|
|
}
|
|
|
|
async fn handle_vectorize(
|
|
Path(uuid): Path<String>,
|
|
) -> Result<Json<Value>, (axum::http::StatusCode, Json<Value>)> {
|
|
pipeline_core::vectorize_chunks(&uuid).await.map_err(|e| {
|
|
tracing::error!("vectorize error: {}", e);
|
|
(
|
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
Json(json!({"error": e.to_string()})),
|
|
)
|
|
})?;
|
|
|
|
Ok(Json(
|
|
json!({"success": true, "message": "Vectorization complete", "file_uuid": uuid}),
|
|
))
|
|
}
|
|
|
|
async fn handle_phase1(
|
|
Path(uuid): Path<String>,
|
|
) -> Result<Json<Value>, (axum::http::StatusCode, Json<Value>)> {
|
|
pipeline_core::run_phase1(&uuid).await.map_err(|e| {
|
|
tracing::error!("phase1 error: {}", e);
|
|
(
|
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
Json(json!({"error": e.to_string()})),
|
|
)
|
|
})?;
|
|
|
|
Ok(Json(
|
|
json!({"success": true, "message": "Phase 1 complete", "file_uuid": uuid}),
|
|
))
|
|
}
|
|
|
|
async fn handle_complete(
|
|
Path(uuid): Path<String>,
|
|
) -> Result<Json<Value>, (axum::http::StatusCode, Json<Value>)> {
|
|
let db = PostgresDb::new(&config::DATABASE_URL).await.map_err(|e| {
|
|
tracing::error!("DB error: {}", e);
|
|
(
|
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
Json(json!({"error": "DB connection failed"})),
|
|
)
|
|
})?;
|
|
|
|
pipeline_core::mark_complete(&db, &uuid)
|
|
.await
|
|
.map_err(|e| {
|
|
tracing::error!("complete error: {}", e);
|
|
(
|
|
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
|
Json(json!({"error": e.to_string()})),
|
|
)
|
|
})?;
|
|
|
|
Ok(Json(
|
|
json!({"success": true, "message": "Video marked as completed", "file_uuid": uuid}),
|
|
))
|
|
}
|
|
|
|
pub fn pipeline_routes() -> Router<crate::api::types::AppState> {
|
|
Router::new()
|
|
.route(
|
|
"/api/v1/file/:file_uuid/store-asrx",
|
|
post(handle_store_asrx),
|
|
)
|
|
.route("/api/v1/file/:file_uuid/rule1", post(handle_rule1))
|
|
.route("/api/v1/file/:file_uuid/vectorize", post(handle_vectorize))
|
|
.route("/api/v1/file/:file_uuid/phase1", post(handle_phase1))
|
|
.route("/api/v1/file/:file_uuid/complete", post(handle_complete))
|
|
}
|