Skip to content

Commit 12ce368

Browse files
committed
WL#17088 Langchain Forward Compatibility [POSTFIX]
Issue: The upcoming langchain v1.0.0 changes some import paths. Solution: Update the code to try both old and new import paths for backwards and forwards compatibility. Change-Id: Ieadb8e80c4370c9be972310dda4ad04aa4df0f60
1 parent 8f5f52d commit 12ce368

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mysql-connector-python/lib/mysql/ai/genai/generation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030

3131
from typing import Any, List, Optional
3232

33-
from langchain.llms.base import LLM
33+
try:
34+
from langchain_core.language_models.llms import LLM
35+
except ImportError:
36+
from langchain.llms.base import LLM
3437
from mysql.ai.utils import atomic_transaction, execute_sql, format_value_sql
3538
from pydantic import PrivateAttr
3639

0 commit comments

Comments
 (0)