You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: integrate react-force-graph-2d for enhanced graph visualization
- Added dynamic import for ForceGraph2D to enable client-side rendering.
- Refactored BasicGraphView to utilize ForceGraph2D for rendering graphs.
- Implemented responsive dimensions for the graph container using ResizeObserver.
- Enhanced graph data structure to include color mapping and node properties.
- Added a legend to display group colors for better visualization context.
- Updated package.json and package-lock.json to include react-force-graph-2d dependency.
Copy file name to clipboardExpand all lines: app/api/chat/route.js
+15-12Lines changed: 15 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -745,13 +745,12 @@ function getToolConfig() {
745
745
tools.push({
746
746
type: 'function',
747
747
name: 'create_basic_graph',
748
-
description: 'Create a lightweight graph specification for UI rendering. Use this to visualise connectivity as nodes and edges.',
748
+
description: 'Create a lightweight graph specification for UI rendering. Use this to visualise connectivity as nodes and edges. IMPORTANT: Always set the "group" field on every node to a shared biological category (e.g. neurotransmitter type like "cholinergic", "GABAergic", "glutamatergic"; or system/region like "visual system", "central complex"; or cell class like "sensory neuron", "interneuron") so that nodes are colour-coded meaningfully. Choose the most informative grouping for the specific query context.',
color: {type: 'string',description: 'Optional color in #RRGGBB format'},
762
+
group: {type: 'string',description: 'REQUIRED: Shared biological category for colour-coding. Use neurotransmitter type (cholinergic, GABAergic, glutamatergic), system/region (visual system, central complex), cell class (sensory neuron, interneuron, projection neuron), or other contextually meaningful grouping.'},
- Questions about FlyBase genes/alleles/insertions/stocks: use vfb_resolve_entity first (if unresolved), then vfb_find_stocks
2518
2516
- Questions about split-GAL4 combination names/synonyms (for example MB002B, SS04495): use vfb_resolve_combination first, then vfb_find_combo_publications (and optionally vfb_find_stocks if the user asks for lines)
2519
2517
- Questions about comparative connectivity between neuron classes across datasets: use vfb_query_connectivity (optionally vfb_list_connectome_datasets first to pick valid dataset symbols)
2520
-
- For connectivity questions, call vfb_query_connectivity directly with the neuron class labels or FBbt IDs the user mentions — do NOT manually run NeuronsPartHere or vfb_search_terms first. The server handles term resolution and will return requires_user_selection if disambiguation is needed.
2518
+
- For connectivity questions, call vfb_query_connectivity directly with the FULL neuron class labels or FBbt IDs the user mentions — do NOT manually run NeuronsPartHere or vfb_search_terms first. The server handles term resolution and will return requires_user_selection if disambiguation is needed.
2519
+
- IMPORTANT: When the user gives a multi-word neuron name like "adult ellipsoid body ring neuron", pass the ENTIRE phrase as the label. Do NOT break it into sub-terms (e.g. do NOT search for "ellipsoid body" separately). Always use the longest, most specific term the user provides.
2521
2520
- For directional requests like "connections from X to Y" or "between X and Y", treat X as upstream (presynaptic) and Y as downstream (postsynaptic), and prefer vfb_query_connectivity over a single-term run_query.
2522
2521
- Do not infer identity from examples in this prompt. Only map IDs to labels (or labels to IDs) using tool outputs from this turn.
2523
2522
- Never claim "TERM_A (ID) is TERM_B" unless vfb_get_term_info confirms that exact mapping.
@@ -2543,7 +2542,7 @@ TOOL ERRORS AND TIMEOUTS:
2543
2542
- VFB MCP queries (especially non-cached ones like vfb_query_connectivity and live vfb_run_query) can take considerable time. Do NOT treat slow responses as failures.
2544
2543
- If a tool returns a timeout error, try an alternative approach (e.g. narrower query, different tool) rather than giving up. Always present whatever partial results you have gathered so far.
2545
2544
- Never tell the user a query "failed" or "timed out" without first attempting at least one alternative path.
2546
-
- CRITICAL: When vfb_query_connectivity returns connectivity data successfully, present those results immediately. Do NOT make additional tool calls (vfb_run_query, vfb_get_term_info) to "enrich" the connectivity answer — this wastes time and risks timeouts that obscure the successful results.
2545
+
- CRITICAL: When vfb_query_connectivity returns connectivity data successfully, present those results immediately AND call create_basic_graph with the top connections. Do NOT make additional tool calls (vfb_run_query, vfb_get_term_info) to "enrich" the connectivity answer — this wastes time and risks timeouts that obscure the successful results.
2547
2546
- If supplementary tool calls fail but the primary query succeeded, present the successful results and ignore the supplementary failures. Never lead your response with error messages when you have valid data to show.
2548
2547
2549
2548
TOOL ECONOMY:
@@ -2566,10 +2565,14 @@ FORMATTING VFB REFERENCES (response text only — NOT for tool parameters):
2566
2565
- Only use thumbnail URLs that actually appear in tool results
2567
2566
2568
2567
GRAPH VISUALS:
2569
-
- Graph rendering is optional and should be used only when it improves clarity for this specific answer.
2570
-
- For connectivity answers, use at most one concise graph (typically 4-20 nodes) when a visual summary is clearer than text alone.
2571
-
- Keep graph specs focused on the strongest relationships and avoid very dense or exhaustive graphs.
2572
-
- Skip graph output when a short table or plain-language summary is clearer.
2568
+
- ALWAYS call create_basic_graph when vfb_query_connectivity returns connectivity data. Do not wait for the user to ask for a graph — include it automatically alongside the text summary.
2569
+
- For connectivity answers, create one concise graph (typically 4-20 nodes) highlighting the strongest relationships.
2570
+
- Keep graph specs focused and avoid very dense or exhaustive graphs — pick the top connections by weight.
2571
+
- Every node MUST have a meaningful "group" field for colour-coding. Choose the most informative biological grouping for the context:
2572
+
* Neurotransmitter type (cholinergic, GABAergic, glutamatergic, etc.) when NT data is available
2573
+
* Brain region/system (visual system, central complex, mushroom body, etc.) when comparing across regions
2574
+
* Cell class (sensory neuron, interneuron, projection neuron, motor neuron, etc.) as a general fallback
2575
+
* The LLM should use its knowledge of Drosophila neurobiology to assign the most useful grouping
2573
2576
2574
2577
TOOL RELAY:
2575
2578
- You can request server-side tool execution using the tool relay protocol.
@@ -3009,7 +3012,7 @@ function buildToolPolicyCorrectionMessage({
3009
3012
'- Choose the smallest set of tools that best answers the user request.',
3010
3013
'- For VFB query-type questions, prefer vfb_get_term_info + vfb_run_query as the first pass because vfb_run_query is typically cached and fast.',
3011
3014
'- Use more specialized tools (for example vfb_query_connectivity, vfb_resolve_entity, vfb_find_stocks, vfb_resolve_combination, vfb_find_combo_publications) when deeper refinement is needed.',
3012
-
'- If the result is connectivity-heavy and a graph would help, consider create_basic_graph for a compact node/edge view.',
3015
+
'- When connectivity data is returned, ALWAYS call create_basic_graph to visualise the connections as a node/edge graph with meaningful group labels for colour-coding.',
3013
3016
'- Prefer direct data tools over documentation search when the question asks for concrete VFB data.',
3014
3017
'- If existing tool outputs already answer the question, provide the final answer instead of requesting more tools.'
0 commit comments