fix(graph): improve LLM tool UX for GetSubgraphTool and ReadGraphTool
This commit is contained in:
1 parent
eed9a9165c
commit
39528411f4
2 files changed
+5
-2
No files matched your search
@@ -625,6 +625,7 @@ impl McpTool for ReadGraphHandler {
|
|||||||
.entities
|
.entities
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, v)| req.namespace.as_ref().is_none_or(|ns| &v.namespace == ns))
|
.filter(|(_, v)| req.namespace.as_ref().is_none_or(|ns| &v.namespace == ns))
|
||||||
|
.filter(|(_, v)| req.entity_type.as_ref().is_none_or(|et| &v.entity_type == et))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let total_count = filtered_entities.len();
|
let total_count = filtered_entities.len();
|
||||||
@@ -1120,7 +1121,7 @@ impl McpTool for GetSubgraphHandler {
|
|||||||
crate::error::AppError::Internal("root_entity is required".to_string())
|
crate::error::AppError::Internal("root_entity is required".to_string())
|
||||||
})?;
|
})?;
|
||||||
let depth = req.depth.unwrap_or(2);
|
let depth = req.depth.unwrap_or(2);
|
||||||
let format = req.format.unwrap_or(SubgraphFormat::Json);
|
let format = req.format.unwrap_or(SubgraphFormat::MarkdownTree);
|
||||||
|
|
||||||
let (matched_entities, matched_relations) = state.read_graph(|full| {
|
let (matched_entities, matched_relations) = state.read_graph(|full| {
|
||||||
let mut adj: std::collections::HashMap<&str, Vec<&str>> =
|
let mut adj: std::collections::HashMap<&str, Vec<&str>> =
|
||||||
|
|||||||
+3
-1
@@ -100,6 +100,8 @@ pub struct DeleteRelationsTool {
|
|||||||
pub struct ReadGraphTool {
|
pub struct ReadGraphTool {
|
||||||
/// Optional namespace to restrict the read to.
|
/// Optional namespace to restrict the read to.
|
||||||
pub namespace: Option<String>,
|
pub namespace: Option<String>,
|
||||||
|
/// Optional entity_type to filter entities by (e.g. 'DatabaseTable').
|
||||||
|
pub entity_type: Option<String>,
|
||||||
/// Optional token budget cap. Truncates graph outputs to fit within the specified token budget.
|
/// Optional token budget cap. Truncates graph outputs to fit within the specified token budget.
|
||||||
pub max_tokens: Option<usize>,
|
pub max_tokens: Option<usize>,
|
||||||
/// Optional maximum number of entities to return (pagination).
|
/// Optional maximum number of entities to return (pagination).
|
||||||
@@ -213,7 +215,7 @@ pub struct GetSubgraphTool {
|
|||||||
pub root_entity: Option<String>,
|
pub root_entity: Option<String>,
|
||||||
/// Maximum search depth (hops). Defaults to 2.
|
/// Maximum search depth (hops). Defaults to 2.
|
||||||
pub depth: Option<u32>,
|
pub depth: Option<u32>,
|
||||||
/// Output format: 'json' (raw entities and relations) or 'markdown_tree' (compact topology tree). Defaults to 'json'.
|
/// Output format: 'json' (raw entities and relations) or 'markdown_tree' (compact topology tree). Defaults to 'markdown_tree'.
|
||||||
pub format: Option<SubgraphFormat>,
|
pub format: Option<SubgraphFormat>,
|
||||||
/// Optional namespace filter.
|
/// Optional namespace filter.
|
||||||
pub namespace: Option<String>,
|
pub namespace: Option<String>,
|
||||||
|
|||||||
Reference in new issue
Block a user