fix(embed): add debug tracing to all embed methods
Added tracing::debug/info calls to embed_issue, embed_repo, embed_issues, embed_skill to track embedding API calls and upsert completion.
This commit is contained in:
parent
6a60d02263
commit
009ccee72b
@ -118,7 +118,9 @@ impl EmbedService {
|
|||||||
_ => title.to_string(),
|
_ => title.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tracing::debug!(issue_id = %id, text_len = text.len(), "embed_issue: calling embedding API");
|
||||||
let vector = self.client.embed_text(&text, &self.model_name).await?;
|
let vector = self.client.embed_text(&text, &self.model_name).await?;
|
||||||
|
tracing::debug!(issue_id = %id, vec_dim = vector.len(), "embed_issue: embedding done");
|
||||||
|
|
||||||
let point = EmbedVector {
|
let point = EmbedVector {
|
||||||
id: id.to_string(),
|
id: id.to_string(),
|
||||||
@ -131,7 +133,9 @@ impl EmbedService {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
self.client.upsert(vec![point]).await
|
self.client.upsert(vec![point]).await?;
|
||||||
|
tracing::info!(issue_id = %id, "embed_issue: upsert complete");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn embed_repo(
|
pub async fn embed_repo(
|
||||||
@ -145,7 +149,9 @@ impl EmbedService {
|
|||||||
_ => name.to_string(),
|
_ => name.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tracing::debug!(repo_id = %id, text_len = text.len(), "embed_repo: calling embedding API");
|
||||||
let vector = self.client.embed_text(&text, &self.model_name).await?;
|
let vector = self.client.embed_text(&text, &self.model_name).await?;
|
||||||
|
tracing::debug!(repo_id = %id, vec_dim = vector.len(), "embed_repo: embedding done");
|
||||||
|
|
||||||
let point = EmbedVector {
|
let point = EmbedVector {
|
||||||
id: id.to_string(),
|
id: id.to_string(),
|
||||||
@ -158,7 +164,9 @@ impl EmbedService {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
self.client.upsert(vec![point]).await
|
self.client.upsert(vec![point]).await?;
|
||||||
|
tracing::info!(repo_id = %id, "embed_repo: upsert complete");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn embed_issues<T: Embeddable + Send + Sync>(
|
pub async fn embed_issues<T: Embeddable + Send + Sync>(
|
||||||
@ -170,7 +178,9 @@ impl EmbedService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let texts: Vec<String> = items.iter().map(|i| i.to_text()).collect();
|
let texts: Vec<String> = items.iter().map(|i| i.to_text()).collect();
|
||||||
|
tracing::debug!(count = texts.len(), "embed_issues: calling embed_batch");
|
||||||
let embeddings = self.client.embed_batch(&texts, &self.model_name).await?;
|
let embeddings = self.client.embed_batch(&texts, &self.model_name).await?;
|
||||||
|
tracing::debug!(count = embeddings.len(), "embed_issues: batch done");
|
||||||
|
|
||||||
let points: Vec<EmbedVector> = items
|
let points: Vec<EmbedVector> = items
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -187,7 +197,10 @@ impl EmbedService {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
self.client.upsert(points).await
|
let count = points.len();
|
||||||
|
self.client.upsert(points).await?;
|
||||||
|
tracing::info!(count = count, "embed_issues: upsert complete");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn search_issues(
|
pub async fn search_issues(
|
||||||
@ -264,15 +277,20 @@ impl EmbedService {
|
|||||||
let desc = description.unwrap_or_default();
|
let desc = description.unwrap_or_default();
|
||||||
let id = skill_id.to_string();
|
let id = skill_id.to_string();
|
||||||
|
|
||||||
|
tracing::debug!(skill_id = %skill_id, name = %name, content_len = content.len(), "embed_skill: starting");
|
||||||
|
|
||||||
// Auto-chunk long content
|
// Auto-chunk long content
|
||||||
let texts = chunk_text(content);
|
let texts = chunk_text(content);
|
||||||
|
tracing::debug!(skill_id = %skill_id, chunks = texts.len(), "embed_skill: chunked");
|
||||||
|
|
||||||
if texts.len() == 1 {
|
if texts.len() == 1 {
|
||||||
self.client
|
self.client
|
||||||
.embed_skill(&id, name, desc, content, project_uuid, &self.model_name)
|
.embed_skill(&id, name, desc, content, project_uuid, &self.model_name)
|
||||||
.await
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
// Multi-chunk: embed each chunk with chunk_index metadata
|
// Multi-chunk: embed each chunk with chunk_index metadata
|
||||||
let full_texts: Vec<String> = texts.iter().map(|t| format!("{}: {} {}", name, desc, t)).collect();
|
let full_texts: Vec<String> = texts.iter().map(|t| format!("{}: {} {}", name, desc, t)).collect();
|
||||||
|
tracing::debug!(skill_id = %skill_id, "embed_skill: calling embed_batch");
|
||||||
let embeddings = self.client.embed_batch(&full_texts, &self.model_name).await?;
|
let embeddings = self.client.embed_batch(&full_texts, &self.model_name).await?;
|
||||||
|
|
||||||
let points: Vec<EmbedVector> = embeddings.into_iter().enumerate().map(|(i, vector)| {
|
let points: Vec<EmbedVector> = embeddings.into_iter().enumerate().map(|(i, vector)| {
|
||||||
@ -293,8 +311,10 @@ impl EmbedService {
|
|||||||
}
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
self.client.upsert(points).await
|
self.client.upsert(points).await?;
|
||||||
}
|
}
|
||||||
|
tracing::info!(skill_id = %skill_id, chunks = texts.len(), "embed_skill: complete");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Embed an issue with auto-chunking for long content.
|
/// Embed an issue with auto-chunking for long content.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user