Skip to content

Commit fac848c

Browse files
Luboslav Yordanovclaude
authored andcommitted
fix: Add fallback import for langchain_classic
Added try/except block to gracefully fall back to langchain.output_parsers if langchain_classic is not available. This ensures compatibility across different deployment environments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6d5aa6a commit fac848c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scrapegraphai/nodes/generate_code_node.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
from bs4 import BeautifulSoup
1313
from jsonschema import ValidationError as JSONSchemaValidationError
1414
from jsonschema import validate
15-
from langchain_classic.output_parsers.structured import (
16-
ResponseSchema,
17-
StructuredOutputParser,
18-
)
15+
try:
16+
from langchain_classic.output_parsers.structured import (
17+
ResponseSchema,
18+
StructuredOutputParser,
19+
)
20+
except ImportError: # fallback for environments without langchain_classic
21+
from langchain.output_parsers import ResponseSchema, StructuredOutputParser
1922
from langchain_core.prompts import PromptTemplate
2023
from langchain_community.chat_models import ChatOllama
2124
from langchain_core.output_parsers import StrOutputParser

0 commit comments

Comments
 (0)