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:
+21
-10
@@ -1,12 +1,12 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use anyhow::Result;
|
||||
use reqwest::Client;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::time::Duration;
|
||||
use tracing::{debug, warn};
|
||||
|
||||
use crate::core::config;
|
||||
use crate::core::llm::function_calling::LLM_CLIENT;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct ChatRequest {
|
||||
@@ -38,7 +38,10 @@ struct RerankResponse {
|
||||
ranked: Vec<usize>,
|
||||
}
|
||||
|
||||
pub async fn rerank_search_results(query: &str, candidates: &[(usize, &str)]) -> Result<Vec<usize>> {
|
||||
pub async fn rerank_search_results(
|
||||
query: &str,
|
||||
candidates: &[(usize, &str)],
|
||||
) -> Result<Vec<usize>> {
|
||||
if candidates.is_empty() {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
@@ -67,10 +70,6 @@ Include every chunk number exactly once. Only respond with the JSON."#,
|
||||
query, chunks_text
|
||||
);
|
||||
|
||||
let client = Client::builder()
|
||||
.timeout(Duration::from_secs(15))
|
||||
.build()?;
|
||||
|
||||
let req = ChatRequest {
|
||||
model: config::llm::CHAT_MODEL.clone(),
|
||||
messages: vec![
|
||||
@@ -88,11 +87,16 @@ Include every chunk number exactly once. Only respond with the JSON."#,
|
||||
stream: false,
|
||||
};
|
||||
|
||||
debug!("LLM rerank: {} candidates for query '{}'", candidates.len(), query);
|
||||
debug!(
|
||||
"LLM rerank: {} candidates for query '{}'",
|
||||
candidates.len(),
|
||||
query
|
||||
);
|
||||
|
||||
let res = client
|
||||
let res = LLM_CLIENT
|
||||
.post(&*config::llm::CHAT_URL)
|
||||
.json(&req)
|
||||
.timeout(Duration::from_secs(15))
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
@@ -116,7 +120,11 @@ Include every chunk number exactly once. Only respond with the JSON."#,
|
||||
// Strip markdown code fences if present
|
||||
let content = if content.starts_with("```") {
|
||||
let lines: Vec<&str> = content.lines().collect();
|
||||
let start = if lines.first().map(|l| l.contains("```")).unwrap_or(false) { 1 } else { 0 };
|
||||
let start = if lines.first().map(|l| l.contains("```")).unwrap_or(false) {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let end = if lines.last().map(|l| l.contains("```")).unwrap_or(false) {
|
||||
lines.len().saturating_sub(1)
|
||||
} else {
|
||||
@@ -163,6 +171,9 @@ Include every chunk number exactly once. Only respond with the JSON."#,
|
||||
}
|
||||
}
|
||||
|
||||
warn!("LLM rerank: could not parse response — content: {}", &content[..content.len().min(200)]);
|
||||
warn!(
|
||||
"LLM rerank: could not parse response — content: {}",
|
||||
&content[..content.len().min(200)]
|
||||
);
|
||||
Ok(candidates.iter().map(|(idx, _)| *idx).collect())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user