AI & MCP Stack¶
Everything under ai/ powers the LLM workflows, few-shot data, terminology normalization, and Model Context Protocol integrations.
Text-to-Cypher Pipeline¶
- Entry point:
ai/text_to_cypher.py - Inputs: user question, optional flags (
EXECUTE_CYPHER,OUTPUT_MODE,DEBUG_PROMPT) - Steps:
- Load schema context from
ai/schema/. - Render prompt templates from
ai/prompts/*.yaml. - Inject few-shot examples from
ai/fewshots/. - Send request to OpenAI (or override via env var).
- Optionally execute the generated query via Neo4j driver and summarize results.
Terminology Management¶
ai/terminology/loader.pyingests YAML definitions (e.g.,v1.yaml) to enrich prompts with domain language and synonyms.- Future work: automate exports into
docs/reference/glossary.md.
MCP Client Integration¶
ai/mcp_client.pyprovides async helpers to connect to MCP servers (notably the Neo4j GDS Agent).- Supports interactive mode (
--interactive) for manual tool testing. - Shares credentials with the backend through common environment variables.
- See MCP Architecture for the full stdio/JSON-RPC handshake sequence.
Analytics Agent (Optional)¶
- Implemented in
ai/agent/graph_analytics_agent.py. - Routes qualifying questions to graph algorithms (
leiden,article_rank,bridges,count_nodes). - Controlled via
ENABLE_ANALYTICS_AGENT. When disabled, all traffic goes through text-to-Cypher. - See Graph Analytics Guide for configuration tips.
Observability¶
ai/llmops/langfuse_client.pyencapsulates Langfuse tracing.- Prompts are versioned/labeled in Langfuse; the backend selects a label via the
PROMPT_LABELenv var.
Roadmap¶
- Document prompt schemas and response contracts directly from YAML files.
- Add mkdocstrings support to auto-publish function/class docs.
- Provide scripts that regenerate documentation artifacts (schema visualizations, glossary).