addon-langchain-llm
Original:🇺🇸 English
Translated
Use when adding LangChain-based LLM routes or services in Python or Next.js stacks; pair with architect-stack-selector.
8installs
Sourceajrlewis/ai-skills
Added on
NPX Install
npx skill4agent add ajrlewis/ai-skills addon-langchain-llmTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Add-on: LangChain LLM
Use this skill when an existing project needs LangChain primitives for chat, retrieval, or summarization.
Compatibility
- Works with ,
architect-python-uv-fastapi-sqlalchemy, andarchitect-python-uv-batch.architect-nextjs-bun-app - Can be combined with .
addon-rag-ingestion-pipeline - Can be combined with when graph orchestration is required.
addon-langgraph-agent - Can be combined with ; when used together, declare
addon-llm-judge-evalsinlangchainso the judge runner can resolve the backend without guessing.config/skill_manifest.json
Inputs
Collect:
- :
LLM_PROVIDER|openai|anthropic.ollama - : provider model id.
DEFAULT_MODEL - :
ENABLE_STREAMING|yes(defaultno).yes - :
USE_RAG|yes.no - : default
MAX_INPUT_TOKENS.8000
Integration Workflow
- Add dependencies:
- Python:
bash
uv add langchain langchain-core langchain-community pydantic-settings tiktoken- Next.js:
bash
bun add langchain zod- Provider packages (as needed):
bash
uv add langchain-openai langchain-anthropic langchain-ollama
bun add @langchain/openai @langchain/anthropic @langchain/ollama- Add files by architecture:
- Python API:
text
src/{{MODULE_NAME}}/llm/provider.py
src/{{MODULE_NAME}}/llm/chains.py
src/{{MODULE_NAME}}/api/routes/llm.py- Next.js:
text
src/lib/llm/langchain.ts
src/lib/llm/chains.ts
src/app/api/llm/chat/route.ts- Enforce typed request/response contracts:
- Validate input lengths before chain invocation.
- Return stable schema for streaming and non-streaming modes.
- If , compose retriever + prompt + model chain:
USE_RAG=yes
- Keep retrieval source metadata in outputs.
- Bound document count and token budget.
- If is also selected:
addon-llm-judge-evals
- emit with
config/skill_manifest.jsoninaddon-langchain-llmaddons - declare in
"judge_backends": ["langchain"]capabilities - allow the judge runner to reuse when
DEFAULT_MODELis unsetJUDGE_MODEL
Required Template
Chat response shape
json
{
"outputText": "string",
"model": "string",
"provider": "string"
}Guardrails
-
Documentation contract for generated code:
- Python: write module docstrings and docstrings for public classes, methods, and functions.
- Next.js/TypeScript: write JSDoc for exported components, hooks, utilities, and route handlers.
- Add concise rationale comments only for non-obvious logic, invariants, or safety constraints.
- Apply this contract even when using template snippets below; expand templates as needed.
-
Enforce provider/model allow-lists.
-
Add timeout and retry limits around provider calls.
-
Never log secrets or raw auth headers.
-
On streaming disconnect, stop upstream generation promptly.
-
If judge evals are enabled, keep the judge path on the same provider abstraction instead of bypassing it with ad hoc SDK calls.
Validation Checklist
- Confirm generated code includes required docstrings/JSDoc and rationale comments for non-obvious logic.
bash
uv run ruff check . || true
uv run mypy src || true
bun run lint || true
rg -n "langchain|outputText|provider" src- Manual checks:
- Typed chat route returns valid response.
- Invalid payloads fail with controlled validation errors.
Decision Justification Rule
- Every non-trivial decision must include a concrete justification.
- Capture the alternatives considered and why they were rejected.
- State tradeoffs and residual risks for the chosen option.
- If justification is missing, treat the task as incomplete and surface it as a blocker.