docs: fix Agent deprecation msg (#25464)

This commit is contained in:
Bagatur 2024-08-18 12:15:52 -07:00 committed by GitHub
parent 937b3904eb
commit 49dea06af1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 49 deletions

View File

@ -318,7 +318,7 @@ def _construct_doc(
index_autosummary += f""" index_autosummary += f"""
:ref:`{package_namespace}_{module}` :ref:`{package_namespace}_{module}`
{'^' * (len(module) + 5)} {'^' * (len(package_namespace) + len(module) + 8)}
""" """
if classes: if classes:
@ -448,7 +448,6 @@ def _construct_doc(
""" """
docs.append((f"{module}.rst", module_doc)) docs.append((f"{module}.rst", module_doc))
docs.append(("index.rst", index_doc + index_autosummary)) docs.append(("index.rst", index_doc + index_autosummary))
return docs return docs
@ -530,17 +529,21 @@ def _build_index(dirs: List[str]) -> None:
ordered = ["core", "langchain", "text-splitters", "community", "experimental"] ordered = ["core", "langchain", "text-splitters", "community", "experimental"]
main_ = [dir_ for dir_ in ordered if dir_ in dirs] main_ = [dir_ for dir_ in ordered if dir_ in dirs]
integrations = sorted(dir_ for dir_ in dirs if dir_ not in main_) integrations = sorted(dir_ for dir_ in dirs if dir_ not in main_)
doc = """# LangChain Python API Reference
Welcome to the LangChain Python API reference. This is a reference for all
`langchain-x` packages.
For user guides see [https://python.langchain.com](https://python.langchain.com).
For the legacy API reference hosted on ReadTheDocs see [https://api.python.langchain.com/](https://api.python.langchain.com/).
"""
if main_:
main_headers = [ main_headers = [
" ".join(custom_names.get(x, x.title()) for x in dir_.split("-")) " ".join(custom_names.get(x, x.title()) for x in dir_.split("-"))
for dir_ in main_ for dir_ in main_
] ]
integration_headers = [
" ".join(
custom_names.get(x, x.title().replace("ai", "AI").replace("db", "DB"))
for x in dir_.split("-")
)
for dir_ in integrations
]
main_tree = "\n".join( main_tree = "\n".join(
f"{header_name}<{dir_.replace('-', '_')}/index>" f"{header_name}<{dir_.replace('-', '_')}/index>"
for header_name, dir_ in zip(main_headers, main_) for header_name, dir_ in zip(main_headers, main_)
@ -549,6 +552,30 @@ def _build_index(dirs: List[str]) -> None:
f'- header: "**{header_name}**"\n content: "{_package_namespace(dir_).replace("_", "-")}: {_get_package_version(_package_dir(dir_))}"\n link: {dir_.replace("-", "_")}/index.html' f'- header: "**{header_name}**"\n content: "{_package_namespace(dir_).replace("_", "-")}: {_get_package_version(_package_dir(dir_))}"\n link: {dir_.replace("-", "_")}/index.html'
for header_name, dir_ in zip(main_headers, main_) for header_name, dir_ in zip(main_headers, main_)
) )
doc += f"""## Base packages
```{{gallery-grid}}
:grid-columns: "1 2 2 3"
{main_grid}
```
```{{toctree}}
:maxdepth: 2
:hidden:
:caption: Base packages
{main_tree}
```
"""
if integrations:
integration_headers = [
" ".join(
custom_names.get(x, x.title().replace("ai", "AI").replace("db", "DB"))
for x in dir_.split("-")
)
for dir_ in integrations
]
integration_tree = "\n".join( integration_tree = "\n".join(
f"{header_name}<{dir_.replace('-', '_')}/index>" f"{header_name}<{dir_.replace('-', '_')}/index>"
for header_name, dir_ in zip(integration_headers, integrations) for header_name, dir_ in zip(integration_headers, integrations)
@ -570,32 +597,7 @@ def _build_index(dirs: List[str]) -> None:
else len(integrations_to_show), else len(integrations_to_show),
)[: len(integrations_to_show)]: )[: len(integrations_to_show)]:
integration_grid += f'\n- header: "**{header_name}**"\n content: {_package_namespace(dir_).replace("_", "-")} {_get_package_version(_package_dir(dir_))}\n link: {dir_.replace("-", "_")}/index.html' integration_grid += f'\n- header: "**{header_name}**"\n content: {_package_namespace(dir_).replace("_", "-")} {_get_package_version(_package_dir(dir_))}\n link: {dir_.replace("-", "_")}/index.html'
doc = f"""# LangChain Python API Reference doc += f"""## Integrations
Welcome to the LangChain Python API reference. This is a reference for all
`langchain-x` packages.
For user guides see [https://python.langchain.com](https://python.langchain.com).
For the legacy API reference hosted on ReadTheDocs see [https://api.python.langchain.com/](https://api.python.langchain.com/).
## Base packages
```{{gallery-grid}}
:grid-columns: "1 2 2 3"
{main_grid}
```
```{{toctree}}
:maxdepth: 2
:hidden:
:caption: Base packages
{main_tree}
```
## Integrations
```{{gallery-grid}} ```{{gallery-grid}}
:grid-columns: "1 2 2 3" :grid-columns: "1 2 2 3"
@ -612,7 +614,6 @@ See the full list of integrations in the Section Navigation.
{integration_tree} {integration_tree}
``` ```
""" """
with open(HERE / "reference.md", "w") as f: with open(HERE / "reference.md", "w") as f:
f.write(doc) f.write(doc)

View File

@ -629,7 +629,7 @@ class RunnableMultiActionAgent(BaseMultiActionAgent):
@deprecated( @deprecated(
"0.1.0", "0.1.0",
alternative=( message=(
"Use new agent constructor methods like create_react_agent, create_json_agent, " "Use new agent constructor methods like create_react_agent, create_json_agent, "
"create_structured_chat_agent, etc." "create_structured_chat_agent, etc."
), ),
@ -720,7 +720,7 @@ class LLMSingleActionAgent(BaseSingleActionAgent):
@deprecated( @deprecated(
"0.1.0", "0.1.0",
alternative=( message=(
"Use new agent constructor methods like create_react_agent, create_json_agent, " "Use new agent constructor methods like create_react_agent, create_json_agent, "
"create_structured_chat_agent, etc." "create_structured_chat_agent, etc."
), ),

View File

@ -7,7 +7,7 @@ from langchain_core._api import deprecated
@deprecated( @deprecated(
"0.1.0", "0.1.0",
alternative=( message=(
"Use new agent constructor methods like create_react_agent, create_json_agent, " "Use new agent constructor methods like create_react_agent, create_json_agent, "
"create_structured_chat_agent, etc." "create_structured_chat_agent, etc."
), ),