feat(embedding,vision): candle embeddings with offline fallback, on-demand clipboard vision capture, and concurrency audit
This commit is contained in:
1 parent
5bd8b1587a
commit
e4a0fe72df
47 files changed
+6292
-3503
No files matched your search
+13
-5
@@ -73,7 +73,10 @@ pub async fn start_background_indexer(state: Arc<MemoryState>) {
|
||||
|
||||
// Gold Standard: Batch generate embeddings in chunks of 16 to eliminate sequential HTTP overhead
|
||||
for chunk_batch in chunks.chunks(16) {
|
||||
let texts: Vec<String> = chunk_batch.iter().map(|(_, code, _)| code.clone()).collect();
|
||||
let texts: Vec<String> = chunk_batch
|
||||
.iter()
|
||||
.map(|(_, code, _)| code.clone())
|
||||
.collect();
|
||||
let embeddings = generate_embeddings_async(texts).await.unwrap_or_default();
|
||||
|
||||
let mut new_snippets = Vec::with_capacity(chunk_batch.len());
|
||||
@@ -84,7 +87,8 @@ pub async fn start_background_indexer(state: Arc<MemoryState>) {
|
||||
|
||||
for (i, (name, code, desc)) in chunk_batch.iter().enumerate() {
|
||||
let embedding = embeddings.get(i).cloned();
|
||||
let file_name = file_path.file_name().unwrap_or_default().to_string_lossy();
|
||||
let file_name =
|
||||
file_path.file_name().unwrap_or_default().to_string_lossy();
|
||||
let snippet_name = format!("{}:{}", file_name, name);
|
||||
|
||||
let snippet = Snippet {
|
||||
@@ -95,6 +99,7 @@ pub async fn start_background_indexer(state: Arc<MemoryState>) {
|
||||
updated_at: now,
|
||||
tags: vec![],
|
||||
embedding,
|
||||
..Default::default()
|
||||
};
|
||||
new_snippets.push(snippet);
|
||||
}
|
||||
@@ -162,7 +167,10 @@ fn extract_chunks_with_parent(
|
||||
let mut cursor = node.walk();
|
||||
let mut type_name = None;
|
||||
for child in node.children(&mut cursor) {
|
||||
if child.kind() == "type_identifier" || child.kind() == "name" || child.kind() == "identifier" {
|
||||
if child.kind() == "type_identifier"
|
||||
|| child.kind() == "name"
|
||||
|| child.kind() == "identifier"
|
||||
{
|
||||
type_name = child.utf8_text(code.as_bytes()).ok();
|
||||
break;
|
||||
}
|
||||
@@ -189,7 +197,8 @@ fn extract_chunks_with_parent(
|
||||
let mut cursor = node.walk();
|
||||
for child in node.children(&mut cursor) {
|
||||
let child_kind = child.kind();
|
||||
if child_kind == "identifier" || child_kind == "name" || child_kind == "type_identifier" {
|
||||
if child_kind == "identifier" || child_kind == "name" || child_kind == "type_identifier"
|
||||
{
|
||||
if let Ok(text) = child.utf8_text(code.as_bytes()) {
|
||||
name = text;
|
||||
}
|
||||
@@ -284,4 +293,3 @@ mod tests {
|
||||
start_background_indexer(state).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user