The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
core: use qualname in beta message (#20361)
Erick Friis30c795150520
diff --git a/libs/core/langchain_core/_api/beta_decorator.py b/libs/core/langchain_core/_api/beta_decorator.pyindex 280c1c99c2..a481f10338 100644--- a/libs/core/langchain_core/_api/beta_decorator.py+++ b/libs/core/langchain_core/_api/beta_decorator.py@@ -121,7 +121,7 @@ def beta(if not _obj_type:_obj_type = "class"wrapped = obj.__init__ # type: ignore- _name = _name or obj.__name__+ _name = _name or obj.__qualname__old_doc = obj.__doc__def finalize(wrapper: Callable[..., Any], new_doc: str) -> T:@@ -147,10 +147,11 @@ def beta(return cast(T, obj)elif isinstance(obj, property):+ # note(erick): this block doesn't seem to be used?if not _obj_type:_obj_type = "attribute"wrapped = None- _name = _name or obj.fget.__name__+ _name = _name or obj.fget.__qualname__old_doc = obj.__doc__class _beta_property(property):@@ -189,10 +190,12 @@ def beta()else:+ _name = _name or obj.__qualname__if not _obj_type:- _obj_type = "function"+ # edge case: when a function is within another function+ # within a test, this will call it a "method" not a "function"+ _obj_type = "function" if "." not in _name else "method"wrapped = obj- _name = _name or obj.__name__old_doc = wrapped.__doc__def finalize(wrapper: Callable[..., Any], new_doc: str) -> T:diff --git a/libs/core/tests/unit_tests/_api/test_beta_decorator.py b/libs/core/tests/unit_tests/_api/test_beta_decorator.pyindex caef30c251..634773344c 100644--- a/libs/core/tests/unit_tests/_api/test_beta_decorator.py+++ b/libs/core/tests/unit_tests/_api/test_beta_decorator.py@@ -35,7 +35,8 @@ from langchain_core.pydantic_v1 import BaseModel"obj_type": "","addendum": "Please migrate your code.",},- "`SomeFunction` is in beta. It is actively being worked on, so the API may "+ "`SomeFunction` is in beta. It is actively being worked on, "+ "so the API may ""change. Please migrate your code.",),],@@ -106,7 +107,8 @@ def test_beta_function() -> None:assert len(warning_list) == 1warning = warning_list[0].messageassert str(warning) == (- "The function `beta_function` is in beta. It is actively being worked on, "+ "The function `beta_function` is in beta. It is actively being "+ "worked on, ""so the API may change.")@@ -146,7 +148,8 @@ def test_beta_method() -> None:assert len(warning_list) == 1warning = warning_list[0].messageassert str(warning) == (- "The function `beta_method` is in beta. It is actively being worked on, so "+ "The method `ClassWithBetaMethods.beta_method` is in beta. It is actively "+ "being worked on, so ""the API may change.")@@ -167,7 +170,7 @@ async def test_beta_async_method() -> None:assert len(warning_list) == 1warning = warning_list[0].messageassert str(warning) == (- "The function `beta_async_method` is in beta. "+ "The method `ClassWithBetaMethods.beta_async_method` is in beta. ""It is actively being worked on, so the API may change.")@@ -186,8 +189,8 @@ def test_beta_classmethod() -> None:assert len(warning_list) == 1warning = warning_list[0].messageassert str(warning) == (- "The function `beta_classmethod` is in beta. It is actively being worked "- "on, so the API may change."+ "The method `ClassWithBetaMethods.beta_classmethod` is in beta. "+ "It is actively being worked on, so the API may change.")doc = ClassWithBetaMethods.beta_classmethod.__doc__@@ -206,8 +209,8 @@ def test_beta_staticmethod() -> None:warning = warning_list[0].messageassert str(warning) == (- "The function `beta_staticmethod` is in beta. It is actively being worked "- "on, so the API may change."+ "The method `ClassWithBetaMethods.beta_staticmethod` is in beta. "+ "It is actively being worked on, so the API may change.")doc = ClassWithBetaMethods.beta_staticmethod.__doc__assert isinstance(doc, str)@@ -226,8 +229,8 @@ def test_beta_property() -> None:warning = warning_list[0].messageassert str(warning) == (- "The function `beta_property` is in beta. It is actively being worked on, "- "so the API may change."+ "The method `ClassWithBetaMethods.beta_property` is in beta. "+ "It is actively being worked on, so the API may change.")doc = ClassWithBetaMethods.beta_property.__doc__assert isinstance(doc, str)@@ -257,13 +260,15 @@ def test_whole_class_beta() -> None:assert len(warning_list) == 2warning = warning_list[0].messageassert str(warning) == (- "The class `BetaClass` is in beta. It is actively being worked on, so the "+ "The class `test_whole_class_beta.<locals>.BetaClass` is in beta. "+ "It is actively being worked on, so the ""API may change.")warning = warning_list[1].messageassert str(warning) == (- "The function `beta_method` is in beta. It is actively being worked on, so "+ "The method `test_whole_class_beta.<locals>.BetaClass.beta_method` "+ "is in beta. It is actively being worked on, so ""the API may change.")@@ -299,13 +304,15 @@ def test_whole_class_inherited_beta() -> None:assert len(warning_list) == 2warning = warning_list[0].messageassert str(warning) == (- "The class `BetaClass` is in beta. It is actively being worked on, so the "+ "The class `test_whole_class_inherited_beta.<locals>.BetaClass` "+ "is in beta. It is actively being worked on, so the ""API may change.")warning = warning_list[1].messageassert str(warning) == (- "The function `beta_method` is in beta. It is actively being worked on, so "+ "The method `test_whole_class_inherited_beta.<locals>.BetaClass."+ "beta_method` is in beta. It is actively being worked on, so ""the API may change.")@@ -318,14 +325,16 @@ def test_whole_class_inherited_beta() -> None:assert len(warning_list) == 2warning = warning_list[0].messageassert str(warning) == (- "The class `InheritedBetaClass` is in beta. "+ "The class `test_whole_class_inherited_beta.<locals>.InheritedBetaClass` "+ "is in beta. ""It is actively being worked on, so the ""API may change.")warning = warning_list[1].messageassert str(warning) == (- "The function `beta_method` is in beta. "+ "The method `test_whole_class_inherited_beta.<locals>.InheritedBetaClass."+ "beta_method` is in beta. ""It is actively being worked on, so ""the API may change.")@@ -352,7 +361,8 @@ def test_beta_method_pydantic() -> None:assert len(warning_list) == 1warning = warning_list[0].messageassert str(warning) == (- "The function `beta_method` is in beta. It is actively being worked on, so "+ "The method `MyModel.beta_method` is in beta. It is actively being "+ "worked on, so ""the API may change.")