fix #24: [15] Deprecated LLMChain API will break on LangChain upgrade - #49
Merged
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #24.
Summary
LLMChainis deprecated in LangChain 0.2.x and removed in 0.3.x. This migrates the twoLLMChainusages 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.py—create_ideaandcreate_video_promptnow buildprompt | llm | StrOutputParser()and callawait chain.ainvoke({...}).StrOutputParser()is load-bearing: LCELprompt | llmyields anAIMessage, so the parser restores the plain-string return thatLLMChain.arun(...)produced — downstream JSON parsing, the retry loop, error handling, timing, and logging are unchanged.PromptTemplatenow imported fromlangchain_core.prompts.services/simulation_service.py— removed deadLLMChain/PromptTemplateimports (unused; would break on the 0.3 bump).requirements.txt/requirements-prod.txt— pinlangchain==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 bytest_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,ChatOpenAItoken counting) are reachable in this app.test_llm_service.py/test_theme.pyre-pointed fromLLMChain.arunto aRunnableLambdavia_get_llm_instance(no network). Newtests/unit/test_llmchain_lcel_migration_regression.py(8 tests) locks in every acceptance criterion.Run LLMChain LCEL migration regressionstep to theunit-testsjob.Verification (local)
npm run build): succeeded.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.