The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
core[patch]: Support .yml extension for YAML (#16783)
Theo / Taeyoon Kang1987f905ed72
diff --git a/libs/community/langchain_community/llms/loading.py b/libs/community/langchain_community/llms/loading.pyindex c9621b784d..f410f7b7c6 100644--- a/libs/community/langchain_community/llms/loading.py+++ b/libs/community/langchain_community/llms/loading.py@@ -35,7 +35,7 @@ def load_llm(file: Union[str, Path]) -> BaseLLM:if file_path.suffix == ".json":with open(file_path) as f:config = json.load(f)- elif file_path.suffix == ".yaml":+ elif file_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "r") as f:config = yaml.safe_load(f)else:diff --git a/libs/core/langchain_core/language_models/llms.py b/libs/core/langchain_core/language_models/llms.pyindex ec2af1b91e..36d9435325 100644--- a/libs/core/langchain_core/language_models/llms.py+++ b/libs/core/langchain_core/language_models/llms.py@@ -1120,7 +1120,7 @@ class BaseLLM(BaseLanguageModel[str], ABC):if save_path.suffix == ".json":with open(file_path, "w") as f:json.dump(prompt_dict, f, indent=4)- elif save_path.suffix == ".yaml":+ elif save_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "w") as f:yaml.dump(prompt_dict, f, default_flow_style=False)else:diff --git a/libs/core/langchain_core/prompts/base.py b/libs/core/langchain_core/prompts/base.pyindex 51eddf0f77..96cfbf6374 100644--- a/libs/core/langchain_core/prompts/base.py+++ b/libs/core/langchain_core/prompts/base.py@@ -221,7 +221,7 @@ class BasePromptTemplate(if save_path.suffix == ".json":with open(file_path, "w") as f:json.dump(prompt_dict, f, indent=4)- elif save_path.suffix == ".yaml":+ elif save_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "w") as f:yaml.dump(prompt_dict, f, default_flow_style=False)else:diff --git a/libs/core/langchain_core/prompts/loading.py b/libs/core/langchain_core/prompts/loading.pyindex dd6e0c3547..baa56a5666 100644--- a/libs/core/langchain_core/prompts/loading.py+++ b/libs/core/langchain_core/prompts/loading.py@@ -146,7 +146,7 @@ def _load_prompt_from_file(file: Union[str, Path]) -> BasePromptTemplate:if file_path.suffix == ".json":with open(file_path) as f:config = json.load(f)- elif file_path.suffix == ".yaml":+ elif file_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "r") as f:config = yaml.safe_load(f)else:diff --git a/libs/experimental/langchain_experimental/data_anonymizer/presidio.py b/libs/experimental/langchain_experimental/data_anonymizer/presidio.pyindex f9b35788b0..fbfad3703e 100644--- a/libs/experimental/langchain_experimental/data_anonymizer/presidio.py+++ b/libs/experimental/langchain_experimental/data_anonymizer/presidio.py@@ -428,7 +428,7 @@ class PresidioReversibleAnonymizer(PresidioAnonymizerBase, ReversibleAnonymizerBif save_path.suffix == ".json":with open(save_path, "w") as f:json.dump(self.deanonymizer_mapping, f, indent=2)- elif save_path.suffix == ".yaml":+ elif save_path.suffix.endswith((".yaml", ".yml")):with open(save_path, "w") as f:yaml.dump(self.deanonymizer_mapping, f, default_flow_style=False)@@ -452,7 +452,7 @@ class PresidioReversibleAnonymizer(PresidioAnonymizerBase, ReversibleAnonymizerBif load_path.suffix == ".json":with open(load_path, "r") as f:loaded_mapping = json.load(f)- elif load_path.suffix == ".yaml":+ elif load_path.suffix.endswith((".yaml", ".yml")):with open(load_path, "r") as f:loaded_mapping = yaml.load(f, Loader=yaml.FullLoader)diff --git a/libs/experimental/langchain_experimental/prompts/load.py b/libs/experimental/langchain_experimental/prompts/load.pyindex a732256577..51efdc98db 100644--- a/libs/experimental/langchain_experimental/prompts/load.py+++ b/libs/experimental/langchain_experimental/prompts/load.py@@ -30,7 +30,7 @@ def _load_prompt_from_file(file: Union[str, Path]) -> BasePromptTemplate:if file_path.suffix == ".json":with open(file_path) as f:config = json.load(f)- elif file_path.suffix == ".yaml":+ elif file_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "r") as f:config = yaml.safe_load(f)elif file_path.suffix == ".py":diff --git a/libs/langchain/langchain/agents/agent.py b/libs/langchain/langchain/agents/agent.pyindex 8bd7b6d478..e6f9df4939 100644--- a/libs/langchain/langchain/agents/agent.py+++ b/libs/langchain/langchain/agents/agent.py@@ -185,7 +185,7 @@ class BaseSingleActionAgent(BaseModel):if save_path.suffix == ".json":with open(file_path, "w") as f:json.dump(agent_dict, f, indent=4)- elif save_path.suffix == ".yaml":+ elif save_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "w") as f:yaml.dump(agent_dict, f, default_flow_style=False)else:@@ -310,7 +310,7 @@ class BaseMultiActionAgent(BaseModel):if save_path.suffix == ".json":with open(file_path, "w") as f:json.dump(agent_dict, f, indent=4)- elif save_path.suffix == ".yaml":+ elif save_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "w") as f:yaml.dump(agent_dict, f, default_flow_style=False)else:diff --git a/libs/langchain/langchain/chains/base.py b/libs/langchain/langchain/chains/base.pyindex dc665ae997..1bb6d1636b 100644--- a/libs/langchain/langchain/chains/base.py+++ b/libs/langchain/langchain/chains/base.py@@ -687,7 +687,7 @@ class Chain(RunnableSerializable[Dict[str, Any], Dict[str, Any]], ABC):if save_path.suffix == ".json":with open(file_path, "w") as f:json.dump(chain_dict, f, indent=4)- elif save_path.suffix == ".yaml":+ elif save_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "w") as f:yaml.dump(chain_dict, f, default_flow_style=False)else:diff --git a/libs/langchain/langchain/chains/loading.py b/libs/langchain/langchain/chains/loading.pyindex 0675b87141..0fc3da3f49 100644--- a/libs/langchain/langchain/chains/loading.py+++ b/libs/langchain/langchain/chains/loading.py@@ -607,7 +607,7 @@ def _load_chain_from_file(file: Union[str, Path], **kwargs: Any) -> Chain:if file_path.suffix == ".json":with open(file_path) as f:config = json.load(f)- elif file_path.suffix == ".yaml":+ elif file_path.suffix.endswith((".yaml", ".yml")):with open(file_path, "r") as f:config = yaml.safe_load(f)else: