How the Knowledge Graph works
mainThe knowledge graph system uses Neo4j to store the structural components of GitHub repositories. This allows for AI hallucination detection and repository analysis.
Schema
The database maps code structure using the following nodes and relationships:
Nodes:
Repository: GitHub repositoriesFile: Python filesClass: Python classesMethod: Class methods (includes parameter info)Function: Standalone functionsAttribute: Class attributes
Relationships:
Repository-[:CONTAINS]->FileFile-[:DEFINES]->ClassorFunctionClass-[:HAS_METHOD]->MethodClass-[:HAS_ATTRIBUTE]->Attribute
Workflow
- Parsing: Use the
parse_github_repositorytool to index a codebase (ensure the URL ends with.git). - Validation: Use
check_ai_script_hallucinationsto validate generated Python scripts against the graph. - Exploration: Use
query_knowledge_graphto explore classes and methods.
Manual Hallucination Detection
You can manually run the detector on a script using:
python knowledge_graphs/ai_hallucination_detector.py [full path to your script to analyze]