The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Add the option to ignore structured output method to LLM graph transf… (#26013)
Tomaz Bratanicc649b449d71e
diff --git a/libs/experimental/langchain_experimental/graph_transformers/llm.py b/libs/experimental/langchain_experimental/graph_transformers/llm.pyindex 61997a8715..24b8bff5d1 100644--- a/libs/experimental/langchain_experimental/graph_transformers/llm.py+++ b/libs/experimental/langchain_experimental/graph_transformers/llm.py@@ -650,6 +650,10 @@ class LLMGraphTransformer:any relationship properties from text. Alternatively, a list of validproperties can be provided for the LLM to extract, restricting extraction tothose specified.+ ignore_tool_usage (bool): Indicates whether the transformer should+ bypass the use of structured output functionality of the language model.+ If set to True, the transformer will not use the language model's native+ function calling capabilities to handle structured output. Defaults to False.Example:.. code-block:: python@@ -675,16 +679,18 @@ class LLMGraphTransformer:strict_mode: bool = True,node_properties: Union[bool, List[str]] = False,relationship_properties: Union[bool, List[str]] = False,+ ignore_tool_usage: bool = False,) -> None:self.allowed_nodes = allowed_nodesself.allowed_relationships = allowed_relationshipsself.strict_mode = strict_mode- self._function_call = True+ self._function_call = not ignore_tool_usage# Check if the LLM really supports structured output- try:- llm.with_structured_output(_Graph)- except NotImplementedError:- self._function_call = False+ if self._function_call:+ try:+ llm.with_structured_output(_Graph)+ except NotImplementedError:+ self._function_call = Falseif not self._function_call:if node_properties or relationship_properties:raise ValueError(