Web Project Overview
I set out to build an agent-based backend using LangChain and Django.
After bumping the LangChain version for the first time in a while, I descended into dependency hell — writing this up to document what happened.
LangChain Dependency Hell
flowchart TD
A[langchain 업데이트 시도] --> B{빌드 성공?}
B -->|실패| C[langchain-core 버전 조정]
C --> D{빌드 성공?}
D -->|실패| E[langchain-community 버전 조정]
E --> F{빌드 성공?}
F -->|실패| G[pydantic 버전 조정]
G --> H{빌드 성공?}
H -->|실패| I[처음부터 다시...]
B -->|성공| J[테스트]
D -->|성공| J
F -->|성공| J
H -->|성공| J
Version combinations I actually tried:
langchain==0.3.0 + langchain-core==??? → failed
langchain-community==0.3.1 → failed
langchain-community==0.3.0 → failed
langchain-text-splitters==0.2.4 → failed
langchain-text-splitters==0.3.0 → succeeded...?
langchain-openai==0.3.0 → failed
langchain-openai==0.2.8 → succeeded!
SSE Streaming Implementation
SSE (Server-Sent Events) streaming for AI content generation:
class AIContentGenerateStreamView(View):
def post(self, request):
return StreamingHttpResponse(
self._stream_response(request),
content_type='text/event-stream'
)
def _stream_response(self, request):
for chunk in llm.stream(prompt):
yield f"data: {json.dumps({'content': chunk})}\n\n"
Docker Optimizations
- Create static file / media directories
- Set environment variables to optimize Python execution
- Added conditional
git clonelogic, then removed it again
Looking Back…
- Pin LangChain versions — no exceptions: Specify every sub-package version explicitly in
requirements.txt - pydantic v1 vs v2 compatibility: Imports like
BaseCachediffer depending on the version - Configure CORS from the start: Adding it later makes debugging a nightmare
Going Forward…
Now that LangChain has hit 1.0.0+, this is all somewhat moot — but for the project as a whole, standardizing on uv with a pyproject.toml-based setup, or just packaging everything as a library, seems like the right call.