Architecture

Architecture

Every component in EduChain inherits from a single base class, Runnable, and implements the same three methods: invoke() for synchronous calls, stream() for chunked output, and ainvoke() for async. Because every component behaves consistently, they compose into flexible pipelines — from a simple 3-step chain to a full agent that searches its own knowledge base.

Component hierarchy

Runnable
PromptTemplate
ChatModel
OutputParser
RunnablePassthrough
RunnableLambda
Agent

ChatModel when tools are bound

ChatModel
tools bound →
ChatModel + Tools + Callbacks
RunnableSequence
RAGChain
InMemoryVectorStore
RunnableParallel
Memory & Chat History

Basic Chain Flow

A three-step chain moves data left to right, each step returning input for the next.

Dictionary
PromptTemplate
Formatted Prompt
ChatModel
AIMessage
OutputParser
Final Response

Agent Loop Flow

The agent keeps calling the model until it stops requesting tools, or until max_iterations is reached.

Question
ChatModel (with tools)
Tool call requested?

yes

Run the tool
Feed result back
Repeat (up to max_iterations)

no

Final answer