How epistasislab/escargot works
Project Type and Purpose
• ESCARGOT is an open-source Python library (pip package) that orchestrates Large Language Models (LLMs) with a dynamic Graph of Thoughts (GoT) and knowledge graphs.
• Its goal is to improve accuracy and reduce hallucinations by combining:
• Strategic planning and code execution (Python-executable GoT)
• Structured Cypher queries against graph databases (Memgraph, Neo4j)
• Vector similarity backups (Weaviate, embeddings)
• Self-debugging capabilities
High-Level Architecture – Main Components
a. Client / Application Layer
– Your code or CLI that calls Escargot.ask(...)
b. Escargot Core API
– Entry point (escargot/escargot.py)
– Configuration loader (agents/config.py, escargot/language_models/config_template.json)
c. Controller & Workflow Manager
– escargot/controller/controller.py: orchestrates strategy generation, assessment, execution loop
– Multi-agent support (escargot/multiagent/multiagent_manager.py)
d. Graph of Thoughts Engine
– escargot/operations/graph_of_operations.py & operations.py: builds and traverses the dynamic GoT
– escargot/parser/parser.py: converts LLM output into structured GoT steps, code, XML
e. Language Model Interface
– Abstract interface (escargot/language_models/abstract_language_model.py)
– Concrete adapters: AzureGPT, ChatGPT, Ollama
f. Knowledge Retrieval Layer
– Cypher clients: Memgraph (escargot/cypher/memgraph.py), Neo4j
– Vector DB clients: Weaviate (escargot/vector_db/weaviate.py), Azure Embeddings
g. Execution & Self-Debugging
– Direct Python execution of generated code
– Self-debugging / error-handling in escargot/operations/utils.py
h. Memory & Caching
– escargot/memory/memory.py: caches intermediate results, prevents redundant calls
i. Benchmarking Harness (optional external component)
– benchmarking/benchmarking.py, datasets & notebooks: evaluates performance
Component Interactions and Data Flows
1. Client → Escargot Core: ask(question, params)
2. Core loads config → Controller
3. Controller issues planning prompt to LLM adapter → receives initial strategy
4. Parser converts strategy text → GoT graph nodes & edges
5. Controller traverses GoT: for each thought node
• If “query graph DB”: call Cypher client → return structured data
• Else if “vector search fallback”: call vector DB client → return similarities
• Else if “compute”: generate Python snippet via LLM → execute locally → gather output
• On error: self-debug loop (generate patch, re-execute)
6. Memory module caches each step’s results
7. Final answer assembled by Prompter (prompter/prompter.py) → returned to client
Architectural Patterns & Design Principles
• Modular Adapters: abstract interfaces for LLMs, graph DBs, vector DBs → easy to add new providers
• Pipeline / Workflow Orchestration: clear separation between planning, parsing, execution
• Graph-of-Thoughts: dynamic graph structure for reasoning, not linear prompt chain
• Self-healing Execution: automatic error detection & correction loop
• Dependency Injection / Config-Driven: all endpoints & credentials in a single config