mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-08 04:25:46 +00:00
cli: register new integration doc templates (#24854)
- wait to merge for retriever.ipynb merge #24836
This commit is contained in:
parent
210623b409
commit
e98e4be0f7
@ -1,6 +1,7 @@
|
|||||||
"""__ModuleName__ toolkits."""
|
"""__ModuleName__ toolkits."""
|
||||||
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from langchain_core.tools import BaseTool, BaseToolKit
|
from langchain_core.tools import BaseTool, BaseToolKit
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
from typing import Optional, Type
|
from typing import Optional, Type
|
||||||
|
|
||||||
from langchain_core.callbacks import (
|
from langchain_core.callbacks import (
|
||||||
AsyncCallbackManagerForToolRun,
|
|
||||||
CallbackManagerForToolRun,
|
CallbackManagerForToolRun,
|
||||||
)
|
)
|
||||||
from langchain_core.pydantic_v1 import BaseModel, Field
|
from langchain_core.pydantic_v1 import BaseModel
|
||||||
from langchain_core.tools import BaseTool
|
from langchain_core.tools import BaseTool
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,6 +127,20 @@ def new(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
TEMPLATE_MAP: dict[str, str] = {
|
||||||
|
"ChatModel": "chat.ipynb",
|
||||||
|
"DocumentLoader": "document_loaders.ipynb",
|
||||||
|
"Tool": "tools.ipynb",
|
||||||
|
"VectorStore": "vectorstores.ipynb",
|
||||||
|
"Embeddings": "text_embedding.ipynb",
|
||||||
|
"ByteStore": "kv_store.ipynb",
|
||||||
|
"LLM": "llms.ipynb",
|
||||||
|
"Provider": "provider.ipynb",
|
||||||
|
"Toolkit": "toolkits.ipynb",
|
||||||
|
"Retriever": "retrievers.ipynb",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@integration_cli.command()
|
@integration_cli.command()
|
||||||
def create_doc(
|
def create_doc(
|
||||||
name: Annotated[
|
name: Annotated[
|
||||||
@ -173,7 +187,7 @@ def create_doc(
|
|||||||
Creates a new integration doc.
|
Creates a new integration doc.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
replacements = _process_name(name, community=component_type=="Tool")
|
replacements = _process_name(name, community=component_type == "Tool")
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
typer.echo(e)
|
typer.echo(e)
|
||||||
raise typer.Exit(code=1)
|
raise typer.Exit(code=1)
|
||||||
@ -202,14 +216,8 @@ def create_doc(
|
|||||||
|
|
||||||
# copy over template from ../integration_template
|
# copy over template from ../integration_template
|
||||||
template_dir = Path(__file__).parents[1] / "integration_template" / "docs"
|
template_dir = Path(__file__).parents[1] / "integration_template" / "docs"
|
||||||
if component_type == "ChatModel":
|
if component_type in TEMPLATE_MAP:
|
||||||
docs_template = template_dir / "chat.ipynb"
|
docs_template = template_dir / TEMPLATE_MAP[component_type]
|
||||||
elif component_type == "DocumentLoader":
|
|
||||||
docs_template = template_dir / "document_loaders.ipynb"
|
|
||||||
elif component_type == "Tool":
|
|
||||||
docs_template = template_dir / "tools.ipynb"
|
|
||||||
elif component_type == "VectorStore":
|
|
||||||
docs_template = template_dir / "vectorstores.ipynb"
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Unrecognized {component_type=}. Expected one of 'ChatModel', "
|
f"Unrecognized {component_type=}. Expected one of 'ChatModel', "
|
||||||
|
Loading…
Reference in New Issue
Block a user