Skip to content

Commit 4ad551b

Browse files
committed
make is instance of langchain check prettier
1 parent b7cc001 commit 4ad551b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/neo4j_graphrag/generation/graphrag.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,16 @@ def _build_query(
225225

226226
def is_langchain_compatible(self) -> bool:
227227
"""Checks if the LLM is compatible with LangChain."""
228-
return isinstance(self.llm, LLMInterfaceV2) or self.llm.__module__.startswith(
229-
"langchain"
230-
)
228+
if isinstance(self.llm, LLMInterfaceV2):
229+
return True
230+
231+
try:
232+
# langchain-core is an optional dependency
233+
from langchain_core.language_models import BaseChatModel
234+
235+
return isinstance(self.llm, BaseChatModel)
236+
except ImportError:
237+
return False
231238

232239
def _chat_summary_prompt(self, message_history: List[LLMMessage]) -> str:
233240
message_list = [

0 commit comments

Comments
 (0)