Skip to content

Conversation

@majiayu000
Copy link
Contributor

@majiayu000 majiayu000 commented Jan 4, 2026

Summary

  • Update ResponseSchema and StructuredOutputParser imports to use langchain_classic.output_parsers
  • Update create_extraction_chain import to use langchain_classic.chains
  • Add langchain-classic>=1.0.0 as explicit dependency
  • Relax async-timeout requirement to >=4.0.0 for compatibility
  • Fix variable name mismatch in generate_answer_node_k_level.py: use content instead of context

Fixes #1017
Fixes #995

Changes

File Change
scrapegraphai/nodes/generate_code_node.py Import from langchain_classic.output_parsers
scrapegraphai/builders/graph_builder.py Import from langchain_classic.chains
scrapegraphai/nodes/generate_answer_node_k_level.py Use content variable instead of context
pyproject.toml Add langchain-classic dependency, relax async-timeout

Test plan

  • Verified imports work correctly with Python 3.14
  • Ran ruff, black, isort checks
  • All modified modules import successfully

- Change ResponseSchema and StructuredOutputParser imports to use
  langchain_classic.output_parsers instead of langchain_core.output_parsers
- Change create_extraction_chain import to use langchain_classic.chains
  instead of langchain.chains
- Add langchain-classic>=1.0.0 as explicit dependency
- Relax async-timeout requirement to >=4.0.0 for compatibility

Fixes ScrapeGraphAI#1017

Signed-off-by: majiayu000 <[email protected]>
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. dependencies Pull requests that update a dependency file labels Jan 4, 2026
The PromptTemplate expects 'content' variable but the code was passing
'context', causing KeyError during graph execution.

Fixes ScrapeGraphAI#995

Signed-off-by: majiayu000 <[email protected]>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the codebase to be compatible with LangChain v1.0+ by migrating deprecated imports to langchain-classic and fixing a variable name mismatch that was causing runtime errors.

Key Changes:

  • Migrated deprecated LangChain imports (ResponseSchema, StructuredOutputParser, create_extraction_chain) to use langchain-classic package
  • Fixed variable name inconsistency in generate_answer_node_k_level.py where template expects content but code was passing context
  • Added langchain-classic>=1.0.0 as explicit dependency and relaxed async-timeout version constraint for better compatibility

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
scrapegraphai/nodes/generate_code_node.py Updated imports to use langchain_classic.output_parsers for ResponseSchema and StructuredOutputParser
scrapegraphai/builders/graph_builder.py Updated import to use langchain_classic.chains for create_extraction_chain; minor formatting improvement
scrapegraphai/nodes/generate_answer_node_k_level.py Fixed variable name from context to content in three locations to match template expectations
pyproject.toml Added langchain-classic>=1.0.0 dependency and relaxed async-timeout requirement from >=5.0.1 to >=4.0.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@VinciGit00 VinciGit00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Great work on this PR! The changes correctly address LangChain v1.0+ compatibility issues. Here's my assessment:

Approved Changes

  1. Import Updates: All import changes from langchain.chains and langchain_core.output_parsers to langchain_classic equivalents are correct and necessary for LangChain v1.0+ compatibility.

  2. Bug Fix: The variable name fix in generate_answer_node_k_level.py (changing context to content) is correct. I verified that all templates use {content}, not {context}, so this was indeed a bug that needed fixing.

  3. Dependency Management: Adding langchain-classic>=1.0.0 is appropriate. The relaxation of async-timeout version seems reasonable, though worth verifying it doesn't break anything.

  4. Code Quality: The formatting improvements are welcome.

📝 Testing Notes

I attempted to test the imports but encountered dependency conflicts in the local environment (expected in a mixed environment). However, the changes are syntactically correct and follow the official LangChain migration path for v1.0+.

Recommendation: Approve

This PR correctly addresses the compatibility issues mentioned in #1017 and #995. The changes are minimal, focused, and follow best practices for LangChain v1.0+ migration.

Ready to merge! 🚀

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 5, 2026
@VinciGit00 VinciGit00 merged commit 5ca0e95 into ScrapeGraphAI:main Jan 5, 2026
7 checks passed
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

🎉 This PR is included in version 1.71.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file lgtm This PR has been approved by a maintainer released on @stable size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

2 participants