Graph Layer
Foundation of the system. TigerGraph stores entities, relationships, and their properties as a native graph. GSQL queries enable multi-hop traversal that would be prohibitively expensive with traditional databases.
# GSQL Multi-Hop Query
CREATE QUERY find_connections(VERTEX<Entity> start, INT hops) {
Start = {start};
FOREACH i IN RANGE[1, hops] DO
Start = SELECT t
FROM Start:s -(HAS_RELATION:e)-> Entity:t
ACCUM @@paths += (s, e.relation, t);
END;
PRINT @@paths;
}Orchestration Layer
The brain of the system. Analyzes incoming queries, classifies their complexity, and routes them through the appropriate pipeline โ Baseline RAG for simple queries, GraphRAG for complex multi-hop questions.
# Adaptive Query Router
class AdaptiveRouter:
def classify(self, query: str) -> RouteDecision:
complexity = self.score_complexity(query)
query_type = self.detect_type(query) # bridge/comparison/factoid
if complexity > 0.6 or query_type == "bridge":
return Route.GRAPHRAG
return Route.BASELINELLM Layer
Universal LLM abstraction that supports 12 providers through a single API. Swap between Claude, GPT-4, Gemini, Llama, and more with one parameter change โ no code modifications needed.
# Universal LLM โ one interface, 12 providers llm = UniversalLLM(provider="anthropic", model="claude-sonnet-4") response = llm.generate( context=graph_evidence, query=user_question, max_tokens=500 ) # Switch provider with one line: llm = UniversalLLM(provider="groq", model="llama-3.3-70b")
Evaluation Layer
Automated evaluation that measures every query. Computes F1 score, Exact Match, RAGAS metrics, token usage, latency, and USD cost for both pipelines. Powers the benchmark dashboard and cost projections.
# Evaluation Layer
evaluator = RAGASEvaluator()
metrics = evaluator.evaluate(
query=question,
answer=llm_response,
ground_truth=reference_answer,
context=retrieved_context
)
# Returns: { f1: 0.89, em: 1.0, tokens: 2400,
# cost_usd: 0.0096, latency_ms: 1800 }