The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
BUGFIX: add prompt imports for backwards compat (#13702)
Bagatur16af28242921
diff --git a/libs/core/langchain_core/prompts/__init__.py b/libs/core/langchain_core/prompts/__init__.pyindex bce1fc4d5d..e625578b5d 100644--- a/libs/core/langchain_core/prompts/__init__.py+++ b/libs/core/langchain_core/prompts/__init__.py@@ -41,7 +41,7 @@ from langchain_core.prompts.few_shot import (from langchain_core.prompts.few_shot_with_templates import FewShotPromptWithTemplatesfrom langchain_core.prompts.loading import load_promptfrom langchain_core.prompts.pipeline import PipelinePromptTemplate-from langchain_core.prompts.prompt import Prompt, PromptTemplate+from langchain_core.prompts.prompt import PromptTemplatefrom langchain_core.prompts.string import (StringPromptTemplate,check_valid_template,@@ -62,7 +62,6 @@ __all__ = ["HumanMessagePromptTemplate","MessagesPlaceholder","PipelinePromptTemplate",- "Prompt","PromptTemplate","StringPromptTemplate","SystemMessagePromptTemplate",diff --git a/libs/core/langchain_core/prompts/prompt.py b/libs/core/langchain_core/prompts/prompt.pyindex c192f46c51..012b926953 100644--- a/libs/core/langchain_core/prompts/prompt.py+++ b/libs/core/langchain_core/prompts/prompt.py@@ -244,7 +244,3 @@ class PromptTemplate(StringPromptTemplate):partial_variables=_partial_variables,**kwargs,)---# For backwards compatibility.-Prompt = PromptTemplatediff --git a/libs/core/tests/unit_tests/prompts/test_imports.py b/libs/core/tests/unit_tests/prompts/test_imports.pyindex 250afa2351..a9cacf9157 100644--- a/libs/core/tests/unit_tests/prompts/test_imports.py+++ b/libs/core/tests/unit_tests/prompts/test_imports.py@@ -13,7 +13,6 @@ EXPECTED_ALL = ["HumanMessagePromptTemplate","MessagesPlaceholder","PipelinePromptTemplate",- "Prompt","PromptTemplate","StringPromptTemplate","SystemMessagePromptTemplate",diff --git a/libs/langchain/langchain/prompts/__init__.py b/libs/langchain/langchain/prompts/__init__.pyindex d8ff6a9ad9..9a966fa552 100644--- a/libs/langchain/langchain/prompts/__init__.py+++ b/libs/langchain/langchain/prompts/__init__.py@@ -44,7 +44,6 @@ from langchain_core.prompts import (HumanMessagePromptTemplate,MessagesPlaceholder,PipelinePromptTemplate,- Prompt,PromptTemplate,StringPromptTemplate,SystemMessagePromptTemplate,@@ -52,6 +51,7 @@ from langchain_core.prompts import ()from langchain.prompts.example_selector import NGramOverlapExampleSelector+from langchain.prompts.prompt import Prompt__all__ = ["AIMessagePromptTemplate",@@ -67,11 +67,11 @@ __all__ = ["MessagesPlaceholder","NGramOverlapExampleSelector","PipelinePromptTemplate",- "Prompt","PromptTemplate","SemanticSimilarityExampleSelector","StringPromptTemplate","SystemMessagePromptTemplate","load_prompt","FewShotChatMessagePromptTemplate",+ "Prompt",]diff --git a/libs/langchain/langchain/prompts/base.py b/libs/langchain/langchain/prompts/base.pyindex 7c20569823..a315ec92d8 100644--- a/libs/langchain/langchain/prompts/base.py+++ b/libs/langchain/langchain/prompts/base.py@@ -1,3 +1,4 @@+from langchain_core.prompt_values import StringPromptValuefrom langchain_core.prompts import (BasePromptTemplate,StringPromptTemplate,@@ -6,6 +7,7 @@ from langchain_core.prompts import (jinja2_formatter,validate_jinja2,)+from langchain_core.prompts.string import _get_jinja2_variables_from_template__all__ = ["jinja2_formatter",@@ -14,4 +16,6 @@ __all__ = ["get_template_variables","StringPromptTemplate","BasePromptTemplate",+ "StringPromptValue",+ "_get_jinja2_variables_from_template",]diff --git a/libs/langchain/langchain/prompts/chat.py b/libs/langchain/langchain/prompts/chat.pyindex c44c196cf4..049f19382c 100644--- a/libs/langchain/langchain/prompts/chat.py+++ b/libs/langchain/langchain/prompts/chat.py@@ -1,3 +1,4 @@+from langchain_core.prompt_values import ChatPromptValue, ChatPromptValueConcretefrom langchain_core.prompts.chat import (AIMessagePromptTemplate,BaseChatPromptTemplate,@@ -8,6 +9,8 @@ from langchain_core.prompts.chat import (HumanMessagePromptTemplate,MessagesPlaceholder,SystemMessagePromptTemplate,+ _convert_to_message,+ _create_template_from_message_type,)__all__ = [@@ -20,4 +23,8 @@ __all__ = ["SystemMessagePromptTemplate","BaseChatPromptTemplate","ChatPromptTemplate",+ "ChatPromptValue",+ "ChatPromptValueConcrete",+ "_convert_to_message",+ "_create_template_from_message_type",]diff --git a/libs/langchain/langchain/prompts/few_shot.py b/libs/langchain/langchain/prompts/few_shot.pyindex ab8e24098e..67b3106271 100644--- a/libs/langchain/langchain/prompts/few_shot.py+++ b/libs/langchain/langchain/prompts/few_shot.py@@ -1,6 +1,11 @@from langchain_core.prompts.few_shot import (FewShotChatMessagePromptTemplate,FewShotPromptTemplate,+ _FewShotPromptTemplateMixin,)-__all__ = ["FewShotPromptTemplate", "FewShotChatMessagePromptTemplate"]+__all__ = [+ "FewShotPromptTemplate",+ "FewShotChatMessagePromptTemplate",+ "_FewShotPromptTemplateMixin",+]diff --git a/libs/langchain/langchain/prompts/loading.py b/libs/langchain/langchain/prompts/loading.pyindex df0f62f850..b1dfcd9069 100644--- a/libs/langchain/langchain/prompts/loading.py+++ b/libs/langchain/langchain/prompts/loading.py@@ -1,4 +1,23 @@-from langchain_core.prompts.loading import load_prompt, load_prompt_from_config+from langchain_core.prompts.loading import (+ _load_examples,+ _load_few_shot_prompt,+ _load_output_parser,+ _load_prompt,+ _load_prompt_from_file,+ _load_template,+ load_prompt,+ load_prompt_from_config,+)from langchain_core.utils.loading import try_load_from_hub-__all__ = ["load_prompt_from_config", "load_prompt", "try_load_from_hub"]+__all__ = [+ "load_prompt_from_config",+ "load_prompt",+ "try_load_from_hub",+ "_load_examples",+ "_load_few_shot_prompt",+ "_load_output_parser",+ "_load_prompt",+ "_load_prompt_from_file",+ "_load_template",+]diff --git a/libs/langchain/langchain/prompts/pipeline.py b/libs/langchain/langchain/prompts/pipeline.pyindex 88e73e16f3..88e2cc79ab 100644--- a/libs/langchain/langchain/prompts/pipeline.py+++ b/libs/langchain/langchain/prompts/pipeline.py@@ -1,3 +1,3 @@-from langchain_core.prompts.pipeline import PipelinePromptTemplate+from langchain_core.prompts.pipeline import PipelinePromptTemplate, _get_inputs-__all__ = ["PipelinePromptTemplate"]+__all__ = ["PipelinePromptTemplate", "_get_inputs"]diff --git a/libs/langchain/langchain/prompts/prompt.py b/libs/langchain/langchain/prompts/prompt.pyindex 047d55adfe..5e35f878ba 100644--- a/libs/langchain/langchain/prompts/prompt.py+++ b/libs/langchain/langchain/prompts/prompt.py@@ -1,3 +1,6 @@from langchain_core.prompts.prompt import PromptTemplate-__all__ = ["PromptTemplate"]+# For backwards compatibility.+Prompt = PromptTemplate++__all__ = ["PromptTemplate", "Prompt"]diff --git a/libs/langchain/langchain/tools/base.py b/libs/langchain/langchain/tools/base.pyindex ff81eaa895..fd34a1a5a5 100644--- a/libs/langchain/langchain/tools/base.py+++ b/libs/langchain/langchain/tools/base.py@@ -4,6 +4,9 @@ from langchain_core.tools import (StructuredTool,Tool,ToolException,+ _create_subset_model,+ _get_filtered_args,+ _SchemaConfig,create_schema_from_function,tool,)@@ -16,4 +19,7 @@ __all__ = ["Tool","StructuredTool","tool",+ "_SchemaConfig",+ "_create_subset_model",+ "_get_filtered_args",]diff --git a/libs/langchain/tests/unit_tests/prompts/__init__.py b/libs/langchain/tests/unit_tests/prompts/__init__.pynew file mode 100644index 0000000000..dc72afe0c4--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/__init__.py@@ -0,0 +1 @@+"""Test prompt functionality."""diff --git a/libs/langchain/tests/unit_tests/prompts/test_base.py b/libs/langchain/tests/unit_tests/prompts/test_base.pynew file mode 100644index 0000000000..00e2fccf21--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/test_base.py@@ -0,0 +1,16 @@+from langchain.prompts.base import __all__++EXPECTED_ALL = [+ "BasePromptTemplate",+ "StringPromptTemplate",+ "StringPromptValue",+ "_get_jinja2_variables_from_template",+ "check_valid_template",+ "get_template_variables",+ "jinja2_formatter",+ "validate_jinja2",+]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)diff --git a/libs/langchain/tests/unit_tests/prompts/test_chat.py b/libs/langchain/tests/unit_tests/prompts/test_chat.pynew file mode 100644index 0000000000..5156424177--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/test_chat.py@@ -0,0 +1,21 @@+from langchain.prompts.chat import __all__++EXPECTED_ALL = [+ "AIMessagePromptTemplate",+ "BaseChatPromptTemplate",+ "BaseMessagePromptTemplate",+ "BaseStringMessagePromptTemplate",+ "ChatMessagePromptTemplate",+ "ChatPromptTemplate",+ "ChatPromptValue",+ "ChatPromptValueConcrete",+ "HumanMessagePromptTemplate",+ "MessagesPlaceholder",+ "SystemMessagePromptTemplate",+ "_convert_to_message",+ "_create_template_from_message_type",+]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)diff --git a/libs/langchain/tests/unit_tests/prompts/test_few_shot.py b/libs/langchain/tests/unit_tests/prompts/test_few_shot.pynew file mode 100644index 0000000000..248f309f24--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/test_few_shot.py@@ -0,0 +1,11 @@+from langchain.prompts.few_shot import __all__++EXPECTED_ALL = [+ "FewShotChatMessagePromptTemplate",+ "FewShotPromptTemplate",+ "_FewShotPromptTemplateMixin",+]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)diff --git a/libs/langchain/tests/unit_tests/prompts/test_few_shot_with_templates.py b/libs/langchain/tests/unit_tests/prompts/test_few_shot_with_templates.pynew file mode 100644index 0000000000..012ac4dcb0--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/test_few_shot_with_templates.py@@ -0,0 +1,7 @@+from langchain.prompts.few_shot_with_templates import __all__++EXPECTED_ALL = ["FewShotPromptWithTemplates"]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)diff --git a/libs/langchain/tests/unit_tests/prompts/test_imports.py b/libs/langchain/tests/unit_tests/prompts/test_imports.pynew file mode 100644index 0000000000..6ec17789ad--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/test_imports.py@@ -0,0 +1,28 @@+from langchain.prompts import __all__++EXPECTED_ALL = [+ "AIMessagePromptTemplate",+ "BaseChatPromptTemplate",+ "BasePromptTemplate",+ "ChatMessagePromptTemplate",+ "ChatPromptTemplate",+ "FewShotPromptTemplate",+ "FewShotPromptWithTemplates",+ "HumanMessagePromptTemplate",+ "LengthBasedExampleSelector",+ "MaxMarginalRelevanceExampleSelector",+ "MessagesPlaceholder",+ "NGramOverlapExampleSelector",+ "PipelinePromptTemplate",+ "Prompt",+ "PromptTemplate",+ "SemanticSimilarityExampleSelector",+ "StringPromptTemplate",+ "SystemMessagePromptTemplate",+ "load_prompt",+ "FewShotChatMessagePromptTemplate",+]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)diff --git a/libs/langchain/tests/unit_tests/prompts/test_loading.py b/libs/langchain/tests/unit_tests/prompts/test_loading.pynew file mode 100644index 0000000000..8a14876a84--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/test_loading.py@@ -0,0 +1,17 @@+from langchain.prompts.loading import __all__++EXPECTED_ALL = [+ "_load_examples",+ "_load_few_shot_prompt",+ "_load_output_parser",+ "_load_prompt",+ "_load_prompt_from_file",+ "_load_template",+ "load_prompt",+ "load_prompt_from_config",+ "try_load_from_hub",+]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)diff --git a/libs/langchain/tests/unit_tests/prompts/test_pipeline.py b/libs/langchain/tests/unit_tests/prompts/test_pipeline.pynew file mode 100644index 0000000000..f261db6737--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/test_pipeline.py@@ -0,0 +1,7 @@+from langchain.prompts.pipeline import __all__++EXPECTED_ALL = ["PipelinePromptTemplate", "_get_inputs"]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)diff --git a/libs/langchain/tests/unit_tests/prompts/test_prompt.py b/libs/langchain/tests/unit_tests/prompts/test_prompt.pynew file mode 100644index 0000000000..6e9120cec5--- /dev/null+++ b/libs/langchain/tests/unit_tests/prompts/test_prompt.py@@ -0,0 +1,7 @@+from langchain.prompts.prompt import __all__++EXPECTED_ALL = ["Prompt", "PromptTemplate"]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)diff --git a/libs/langchain/tests/unit_tests/tools/test_base.py b/libs/langchain/tests/unit_tests/tools/test_base.pynew file mode 100644index 0000000000..8c00a846b5--- /dev/null+++ b/libs/langchain/tests/unit_tests/tools/test_base.py@@ -0,0 +1,18 @@+from langchain.tools.base import __all__++EXPECTED_ALL = [+ "BaseTool",+ "SchemaAnnotationError",+ "StructuredTool",+ "Tool",+ "ToolException",+ "_SchemaConfig",+ "_create_subset_model",+ "_get_filtered_args",+ "create_schema_from_function",+ "tool",+]+++def test_all_imports() -> None:+ assert set(__all__) == set(EXPECTED_ALL)