Skip to content

fix #24: [15] Deprecated LLMChain API will break on LangChain upgrade - #49

Merged
CuriosityQuantified merged 1 commit into
mainfrom
feat/24-llmchain-lcel-migration
Aug 10, 2026
Merged

CuriosityQuantified merged 1 commit into
mainfrom
feat/24-llmchain-lcel-migration

Conversation

@CuriosityQuantified

Copy link
Copy Markdown
Owner

Closes #24.

Summary

LLMChain is deprecated in LangChain 0.2.x and removed in 0.3.x. This migrates the two LLMChain usages to the recommended LCEL pipe syntax and bumps the langchain dependency stack so a future/resolver-driven upgrade can no longer break the import.

Changes

  • services/llm_service.pycreate_idea and create_video_prompt now build prompt | llm | StrOutputParser() and call await chain.ainvoke({...}). StrOutputParser() is load-bearing: LCEL prompt | llm yields an AIMessage, so the parser restores the plain-string return that LLMChain.arun(...) produced — downstream JSON parsing, the retry loop, error handling, timing, and logging are unchanged. PromptTemplate now imported from langchain_core.prompts.
  • services/simulation_service.py — removed dead LLMChain/PromptTemplate imports (unused; would break on the 0.3 bump).
  • requirements.txt / requirements-prod.txt — pin langchain==0.3.30, langchain-core==0.3.86, langchain-groq==0.2.5, langchain-text-splitters==0.3.11. Empirically resolved in the repo venv; kept identical across both files (enforced by test_requirements_alignment). Per OSV, this is a net reduction in known-CVE exposure vs the old 0.2.x pins, and no residual advisory code paths (load_prompt, HTMLHeaderTextSplitter.split_text_from_url, ChatOpenAI token counting) are reachable in this app.
  • Tests — offline mocks in test_llm_service.py / test_theme.py re-pointed from LLMChain.arun to a RunnableLambda via _get_llm_instance (no network). New tests/unit/test_llmchain_lcel_migration_regression.py (8 tests) locks in every acceptance criterion.
  • CI — added a named Run LLMChain LCEL migration regression step to the unit-tests job.

Verification (local)

  • Unit suite (CI deselect list): 245 passed, 1 skipped, 6 deselected (was 237 before this change; +8 new regression tests).
  • Named CI regression steps (final-turn parsing + new migration file): 10 passed.
  • Next.js production build (npm run build): succeeded.
  • Playwright e2e: unaffected — this is a Python-only change (zero frontend files touched).

Pipeline

Implemented test-first, then reviewed through four sequential subagents (implementation+CI, code-review, code-simplifier, security-review). Code review: APPROVE, no blockers. Security: no findings introduced; dependency bump is a net CVE reduction. Graphify: N/A (repo has no graphify-out/ and no code-graph job).

Do not merge — Hermes owns CI verification and merge.

Migrate the two deprecated LangChain LLMChain usages to LCEL pipe syntax
and bump the langchain dependency stack so the removed-in-0.3 API can no
longer break the import.

- services/llm_service.py: replace `LLMChain(...).arun(...)` in create_idea
  and create_video_prompt with `prompt | llm | StrOutputParser()` +
  `await chain.ainvoke({...})`. StrOutputParser preserves the string return
  of the old LLMChain.arun so downstream JSON parsing is unchanged.
  PromptTemplate now imported from langchain_core.prompts. Retry loop,
  error handling, timing, and logging are untouched.
- services/simulation_service.py: remove dead LLMChain/PromptTemplate imports
  (never used; would break on a 0.3 bump).
- requirements.txt / requirements-prod.txt: pin langchain==0.3.30,
  langchain-core==0.3.86, langchain-groq==0.2.5,
  langchain-text-splitters==0.3.11 (verified to resolve; a net reduction in
  known-CVE exposure vs the 0.2.x pins). Files kept aligned.
- tests: re-point offline mocks (test_llm_service.py, test_theme.py) from
  LLMChain.arun to a RunnableLambda via _get_llm_instance; add
  tests/unit/test_llmchain_lcel_migration_regression.py covering all
  acceptance criteria.
- CI: add named "Run LLMChain LCEL migration regression" step.

Closes #24.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
save-the-world Ready Ready Preview Aug 10, 2026 4:17am
sim-local Ready Ready Preview Aug 10, 2026 4:17am

@CuriosityQuantified
CuriosityQuantified merged commit 0316ef1 into main Aug 10, 2026
6 checks passed
@CuriosityQuantified
CuriosityQuantified deleted the feat/24-llmchain-lcel-migration branch August 10, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[15] Deprecated LLMChain API will break on LangChain upgrade

1 participant