Skip to content

Commit 99d72a2

Browse files
committed
feat: normalize connectivity defaults for group_by_class and weight parameters in executeFunctionTool
1 parent faedffb commit 99d72a2

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

app/api/chat/route.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ function getToolConfig() {
679679
properties: {
680680
upstream_type: { type: 'string', description: 'Upstream (presynaptic) neuron class label or FBbt ID' },
681681
downstream_type: { type: 'string', description: 'Downstream (postsynaptic) neuron class label or FBbt ID' },
682-
weight: { type: 'number', description: 'Minimum synapse count threshold (recommended default 5)' },
683-
group_by_class: { type: 'boolean', description: 'Aggregate by class instead of per-neuron pairs' },
682+
weight: { type: 'number', description: 'Minimum synapse count threshold (default 5)' },
683+
group_by_class: { type: 'boolean', description: 'Aggregate by class instead of per-neuron pairs (default true)' },
684684
exclude_dbs: { type: 'array', items: { type: 'string' }, description: 'Dataset symbols to exclude, e.g. [\"hb\", \"fafb\"]' }
685685
}
686686
}
@@ -1510,6 +1510,29 @@ async function executeFunctionTool(name, args) {
15101510
if (value !== undefined && value !== null) cleanArgs[key] = value
15111511
}
15121512

1513+
// Normalize connectivity defaults so class-level summaries are used unless explicitly overridden.
1514+
if (name === 'vfb_query_connectivity') {
1515+
if (typeof cleanArgs.group_by_class === 'string') {
1516+
const normalized = cleanArgs.group_by_class.trim().toLowerCase()
1517+
if (normalized === 'true') cleanArgs.group_by_class = true
1518+
else if (normalized === 'false') cleanArgs.group_by_class = false
1519+
else cleanArgs.group_by_class = true
1520+
} else if (typeof cleanArgs.group_by_class !== 'boolean') {
1521+
cleanArgs.group_by_class = true
1522+
}
1523+
1524+
const parsedWeight = Number(cleanArgs.weight)
1525+
if (!Number.isFinite(parsedWeight)) {
1526+
cleanArgs.weight = 5
1527+
} else {
1528+
cleanArgs.weight = parsedWeight
1529+
}
1530+
1531+
if (!Array.isArray(cleanArgs.exclude_dbs)) {
1532+
cleanArgs.exclude_dbs = []
1533+
}
1534+
}
1535+
15131536
try {
15141537
const result = await client.callTool({ name: routing.mcpName, arguments: cleanArgs })
15151538
if (result?.content) {

0 commit comments

Comments
 (0)