chore: fix formatting and clippy lints
This commit is contained in:
1 parent
8952bd5399
commit
9d9e959744
35 files changed
+1091
-582
No files matched your search
@@ -6,14 +6,6 @@ use async_trait::async_trait;
|
||||
use serde_json::Value;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pub struct SnippetsHandler;
|
||||
|
||||
#[async_trait]
|
||||
@@ -57,7 +49,7 @@ impl McpTool for SnippetsHandler {
|
||||
embedding,
|
||||
namespace: req
|
||||
.namespace
|
||||
.unwrap_or_else(|| crate::models::default_namespace()),
|
||||
.unwrap_or_else(crate::models::default_namespace),
|
||||
repo_name: req.repo_name,
|
||||
origin_file: req.origin_file,
|
||||
line_range: req.line_range,
|
||||
@@ -89,8 +81,9 @@ impl McpTool for SnippetsHandler {
|
||||
let mut scored: Vec<_> = snippets
|
||||
.into_iter()
|
||||
.filter_map(|s| {
|
||||
let text = format!("{} {} {} {}", s.name, s.description, s.language, s.code)
|
||||
.to_lowercase();
|
||||
let text =
|
||||
format!("{} {} {} {}", s.name, s.description, s.language, s.code)
|
||||
.to_lowercase();
|
||||
let mut score = 0.0;
|
||||
for tok in &q_tokens {
|
||||
if text.contains(tok) {
|
||||
@@ -143,9 +136,9 @@ impl McpTool for SnippetsHandler {
|
||||
|| s.tags.iter().any(|t| contains_ignore_ascii_case(t, &query));
|
||||
|
||||
let matches_tags = tags_filter.is_empty()
|
||||
|| tags_filter
|
||||
.iter()
|
||||
.any(|tf| s.tags.iter().any(|st| contains_ignore_ascii_case(st, tf)));
|
||||
|| tags_filter.iter().any(|tf| {
|
||||
s.tags.iter().any(|st| contains_ignore_ascii_case(st, tf))
|
||||
});
|
||||
|
||||
matches_text && matches_tags
|
||||
})
|
||||
@@ -352,13 +345,28 @@ impl McpTool for SemanticCodeSearchHandler {
|
||||
}
|
||||
|
||||
let mut out = format!("Semantic Search Results for '{}':\n", tool_args.query);
|
||||
for res in results {
|
||||
for res in &results {
|
||||
out.push_str(&format!(
|
||||
"- [{:.2}] {}: {}\n",
|
||||
res.score, res.title, res.body
|
||||
));
|
||||
}
|
||||
|
||||
if state.ollama.is_available().await {
|
||||
let prompt = format!(
|
||||
"You are an expert software architect. Synthesize a concise GraphRAG summary of the following graph nodes relevant to the query: '{}'.\n\nData:\n{}",
|
||||
tool_args.query, out
|
||||
);
|
||||
if let Ok(summary) = state
|
||||
.ollama
|
||||
.generate(&prompt, None, Some("Respond clearly and concisely."))
|
||||
.await
|
||||
{
|
||||
out.push_str("\n\n--- Local GraphRAG Summary ---\n");
|
||||
out.push_str(&summary);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user