Comprehensive strategies for migrating to LangChain from legacy LLM implementations or other frameworks (OpenAI SDK, LlamaIndex, custom agents).
Scan for migration items using pattern matching (OpenAI SDK calls, LlamaIndex imports, legacy LLMChain usage). Classify each by complexity.
Replace direct OpenAI/Anthropic SDK calls with LangChain equivalents using ChatPromptTemplate, MessagesPlaceholder, and chain composition (prompt | llm | StrOutputParser()).
Replace LlamaIndex VectorStoreIndex with LangChain DirectoryLoader + RecursiveCharacterTextSplitter + FAISS/Pinecone retriever chains.
Replace manual function-calling loops with create_tool_calling_agent and AgentExecutor.
Use a DualRunner class to execute both legacy and new implementations side-by-side, comparing outputs for discrepancies.
Control rollout percentage per user with consistent hashing, then validate and clean up legacy code.
See detailed implementation for before/after code examples and migration scripts.
| Issue | Solution |
|---|---|
| Different response format | Add output parser adapter |
| Missing streaming support | Implement streaming callbacks |
| Memory format mismatch | Convert message history format |
| Tool schema differences | Update tool definitions |
Basic usage: Apply langchain migration deep dive to a standard project setup with default configuration options.
Advanced scenario: Customize langchain migration deep dive for production environments with multiple constraints and team-specific requirements.
Use langchain-upgrade-migration for LangChain version upgrades.