The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
chore(cli): remove ruff exclusion of templates (#32864)
Christophe Bornet352ff363ca03
diff --git a/libs/cli/langchain_cli/integration_template/docs/chat.ipynb b/libs/cli/langchain_cli/integration_template/docs/chat.ipynbindex 136a5a7db2..86221b5fc6 100644--- a/libs/cli/langchain_cli/integration_template/docs/chat.ipynb+++ b/libs/cli/langchain_cli/integration_template/docs/chat.ipynb@@ -1,260 +1,262 @@{- "cells": [- {- "cell_type": "raw",- "id": "afaf8039",- "metadata": {},- "source": [- "---\n",- "sidebar_label: __ModuleName__\n",- "---"- ]- },- {- "cell_type": "markdown",- "id": "e49f1e0d",- "metadata": {},- "source": [- "# Chat__ModuleName__\n",- "\n",- "- TODO: Make sure API reference link is correct.\n",- "\n",- "This will help you get started with __ModuleName__ [chat models](/docs/concepts/chat_models). For detailed documentation of all Chat__ModuleName__ features and configurations head to the [API reference](https://python.langchain.com/api_reference/__package_name_short_snake__/chat_models/__module_name__.chat_models.Chat__ModuleName__.html).\n",- "\n",- "- TODO: Add any other relevant links, like information about models, prices, context windows, etc. See https://python.langchain.com/docs/integrations/chat/openai/ for an example.\n",- "\n",- "## Overview\n",- "### Integration details\n",- "\n",- "- TODO: Fill in table features.\n",- "- TODO: Remove JS support link if not relevant, otherwise ensure link is correct.\n",- "- TODO: Make sure API reference links are correct.\n",- "\n",- "| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/chat/__package_name_short_snake__) | Package downloads | Package latest |\n",- "| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",- "| [Chat__ModuleName__](https://python.langchain.com/api_reference/__package_name_short_snake__/chat_models/__module_name__.chat_models.Chat__ModuleName__.html) | [__package_name__](https://python.langchain.com/api_reference/__package_name_short_snake__/) | ✅/❌ | beta/❌ | ✅/❌ |  |  |\n",- "\n",- "### Model features\n",- "| [Tool calling](/docs/how_to/tool_calling) | [Structured output](/docs/how_to/structured_output/) | JSON mode | [Image input](/docs/how_to/multimodal_inputs/) | Audio input | Video input | [Token-level streaming](/docs/how_to/chat_streaming/) | Native async | [Token usage](/docs/how_to/chat_token_usage_tracking/) | [Logprobs](/docs/how_to/logprobs/) |\n",- "| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |\n",- "| ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ |\n",- "\n",- "## Setup\n",- "\n",- "- TODO: Update with relevant info.\n",- "\n",- "To access __ModuleName__ models you'll need to create a/an __ModuleName__ account, get an API key, and install the `__package_name__` integration package.\n",- "\n",- "### Credentials\n",- "\n",- "- TODO: Update with relevant info.\n",- "\n",- "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "433e8d2b-9519-4b49-b2c4-7ab65b046c94",- "metadata": {},- "outputs": [],- "source": [- "import getpass\n",- "import os\n",- "\n",- "if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",- " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\"Enter your __ModuleName__ API key: \")"- ]- },- {- "cell_type": "markdown",- "id": "72ee0c4b-9764-423a-9dbf-95129e185210",- "metadata": {},- "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"- },- {- "cell_type": "code",- "execution_count": null,- "id": "a15d341e-3e26-4ca3-830b-5aab30ed66de",- "metadata": {},- "outputs": [],- "source": [- "# os.environ[\"LANGSMITH_TRACING\"] = \"true\"\n",- "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"- ]- },- {- "cell_type": "markdown",- "id": "0730d6a1-c893-4840-9817-5e5251676d5d",- "metadata": {},- "source": [- "### Installation\n",- "\n",- "The LangChain __ModuleName__ integration lives in the `__package_name__` package:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "652d6238-1f87-422a-b135-f5abbb8652fc",- "metadata": {},- "outputs": [],- "source": [- "%pip install -qU __package_name__"- ]- },- {- "cell_type": "markdown",- "id": "a38cde65-254d-4219-a441-068766c0d4b5",- "metadata": {},- "source": [- "## Instantiation\n",- "\n",- "Now we can instantiate our model object and generate chat completions:\n",- "\n",- "- TODO: Update model instantiation with relevant params."- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",- "metadata": {},- "outputs": [],- "source": [- "from __module_name__ import Chat__ModuleName__\n",- "\n",- "llm = Chat__ModuleName__(\n",- " model=\"model-name\",\n",- " temperature=0,\n",- " max_tokens=None,\n",- " timeout=None,\n",- " max_retries=2,\n",- " # other params...\n",- ")"- ]- },- {- "cell_type": "markdown",- "id": "2b4f3e15",- "metadata": {},- "source": [- "## Invocation\n",- "\n",- "- TODO: Run cells so output can be seen."- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "62e0dbc3",- "metadata": {- "tags": []- },- "outputs": [],- "source": [- "messages = [\n",- " (\n",- " \"system\",\n",- " \"You are a helpful assistant that translates English to French. Translate the user sentence.\",\n",- " ),\n",- " (\"human\", \"I love programming.\"),\n",- "]\n",- "ai_msg = llm.invoke(messages)\n",- "ai_msg"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "d86145b3-bfef-46e8-b227-4dda5c9c2705",- "metadata": {},- "outputs": [],- "source": [- "print(ai_msg.content)"- ]- },- {- "cell_type": "markdown",- "id": "18e2bfc0-7e78-4528-a73f-499ac150dca8",- "metadata": {},- "source": [- "## Chaining\n",- "\n",- "We can [chain](/docs/how_to/sequence/) our model with a prompt template like so:\n",- "\n",- "- TODO: Run cells so output can be seen."- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b",- "metadata": {},- "outputs": [],- "source": [- "from langchain_core.prompts import ChatPromptTemplate\n",- "\n",- "prompt = ChatPromptTemplate(\n",- " [\n",- " (\n",- " \"system\",\n",- " \"You are a helpful assistant that translates {input_language} to {output_language}.\",\n",- " ),\n",- " (\"human\", \"{input}\"),\n",- " ]\n",- ")\n",- "\n",- "chain = prompt | llm\n",- "chain.invoke(\n",- " {\n",- " \"input_language\": \"English\",\n",- " \"output_language\": \"German\",\n",- " \"input\": \"I love programming.\",\n",- " }\n",- ")"- ]- },- {- "cell_type": "markdown",- "id": "d1ee55bc-ffc8-4cfa-801c-993953a08cfd",- "metadata": {},- "source": [- "## TODO: Any functionality specific to this model provider\n",- "\n",- "E.g. creating/using finetuned models via this provider. Delete if not relevant."- ]- },- {- "cell_type": "markdown",- "id": "3a5bb5ca-c3ae-4a58-be67-2cd18574b9a3",- "metadata": {},- "source": [- "## API reference\n",- "\n",- "For detailed documentation of all Chat__ModuleName__ features and configurations head to the [API reference](https://python.langchain.com/api_reference/__package_name_short_snake__/chat_models/__module_name__.chat_models.Chat__ModuleName__.html)"- ]- }- ],- "metadata": {- "kernelspec": {- "display_name": "Python 3 (ipykernel)",- "language": "python",- "name": "python3"- },- "language_info": {- "codemirror_mode": {- "name": "ipython",- "version": 3- },- "file_extension": ".py",- "mimetype": "text/x-python",- "name": "python",- "nbconvert_exporter": "python",- "pygments_lexer": "ipython3",- "version": "3.11.9"- }+ "cells": [+ {+ "cell_type": "raw",+ "id": "afaf8039",+ "metadata": {},+ "source": [+ "---\n",+ "sidebar_label: __ModuleName__\n",+ "---"+ ]},- "nbformat": 4,- "nbformat_minor": 5+ {+ "cell_type": "markdown",+ "id": "e49f1e0d",+ "metadata": {},+ "source": [+ "# Chat__ModuleName__\n",+ "\n",+ "- TODO: Make sure API reference link is correct.\n",+ "\n",+ "This will help you get started with __ModuleName__ [chat models](/docs/concepts/chat_models). For detailed documentation of all Chat__ModuleName__ features and configurations head to the [API reference](https://python.langchain.com/api_reference/__package_name_short_snake__/chat_models/__module_name__.chat_models.Chat__ModuleName__.html).\n",+ "\n",+ "- TODO: Add any other relevant links, like information about models, prices, context windows, etc. See https://python.langchain.com/docs/integrations/chat/openai/ for an example.\n",+ "\n",+ "## Overview\n",+ "### Integration details\n",+ "\n",+ "- TODO: Fill in table features.\n",+ "- TODO: Remove JS support link if not relevant, otherwise ensure link is correct.\n",+ "- TODO: Make sure API reference links are correct.\n",+ "\n",+ "| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/chat/__package_name_short_snake__) | Package downloads | Package latest |\n",+ "| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",+ "| [Chat__ModuleName__](https://python.langchain.com/api_reference/__package_name_short_snake__/chat_models/__module_name__.chat_models.Chat__ModuleName__.html) | [__package_name__](https://python.langchain.com/api_reference/__package_name_short_snake__/) | ✅/❌ | beta/❌ | ✅/❌ |  |  |\n",+ "\n",+ "### Model features\n",+ "| [Tool calling](/docs/how_to/tool_calling) | [Structured output](/docs/how_to/structured_output/) | JSON mode | [Image input](/docs/how_to/multimodal_inputs/) | Audio input | Video input | [Token-level streaming](/docs/how_to/chat_streaming/) | Native async | [Token usage](/docs/how_to/chat_token_usage_tracking/) | [Logprobs](/docs/how_to/logprobs/) |\n",+ "| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |\n",+ "| ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ | ✅/❌ |\n",+ "\n",+ "## Setup\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "\n",+ "To access __ModuleName__ models you'll need to create a/an __ModuleName__ account, get an API key, and install the `__package_name__` integration package.\n",+ "\n",+ "### Credentials\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "\n",+ "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "433e8d2b-9519-4b49-b2c4-7ab65b046c94",+ "metadata": {},+ "outputs": [],+ "source": [+ "import getpass\n",+ "import os\n",+ "\n",+ "if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",+ " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\n",+ " \"Enter your __ModuleName__ API key: \"\n",+ " )"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "72ee0c4b-9764-423a-9dbf-95129e185210",+ "metadata": {},+ "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "a15d341e-3e26-4ca3-830b-5aab30ed66de",+ "metadata": {},+ "outputs": [],+ "source": [+ "# os.environ[\"LANGSMITH_TRACING\"] = \"true\"\n",+ "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "0730d6a1-c893-4840-9817-5e5251676d5d",+ "metadata": {},+ "source": [+ "### Installation\n",+ "\n",+ "The LangChain __ModuleName__ integration lives in the `__package_name__` package:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "652d6238-1f87-422a-b135-f5abbb8652fc",+ "metadata": {},+ "outputs": [],+ "source": [+ "%pip install -qU __package_name__"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "a38cde65-254d-4219-a441-068766c0d4b5",+ "metadata": {},+ "source": [+ "## Instantiation\n",+ "\n",+ "Now we can instantiate our model object and generate chat completions:\n",+ "\n",+ "- TODO: Update model instantiation with relevant params."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",+ "metadata": {},+ "outputs": [],+ "source": [+ "from __module_name__ import Chat__ModuleName__\n",+ "\n",+ "llm = Chat__ModuleName__(\n",+ " model=\"model-name\",\n",+ " temperature=0,\n",+ " max_tokens=None,\n",+ " timeout=None,\n",+ " max_retries=2,\n",+ " # other params...\n",+ ")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "2b4f3e15",+ "metadata": {},+ "source": [+ "## Invocation\n",+ "\n",+ "- TODO: Run cells so output can be seen."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "62e0dbc3",+ "metadata": {+ "tags": []+ },+ "outputs": [],+ "source": [+ "messages = [\n",+ " (\n",+ " \"system\",\n",+ " \"You are a helpful assistant that translates English to French. Translate the user sentence.\",\n",+ " ),\n",+ " (\"human\", \"I love programming.\"),\n",+ "]\n",+ "ai_msg = llm.invoke(messages)\n",+ "ai_msg"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "d86145b3-bfef-46e8-b227-4dda5c9c2705",+ "metadata": {},+ "outputs": [],+ "source": [+ "print(ai_msg.content)"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "18e2bfc0-7e78-4528-a73f-499ac150dca8",+ "metadata": {},+ "source": [+ "## Chaining\n",+ "\n",+ "We can [chain](/docs/how_to/sequence/) our model with a prompt template like so:\n",+ "\n",+ "- TODO: Run cells so output can be seen."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b",+ "metadata": {},+ "outputs": [],+ "source": [+ "from langchain_core.prompts import ChatPromptTemplate\n",+ "\n",+ "prompt = ChatPromptTemplate(\n",+ " [\n",+ " (\n",+ " \"system\",\n",+ " \"You are a helpful assistant that translates {input_language} to {output_language}.\",\n",+ " ),\n",+ " (\"human\", \"{input}\"),\n",+ " ]\n",+ ")\n",+ "\n",+ "chain = prompt | llm\n",+ "chain.invoke(\n",+ " {\n",+ " \"input_language\": \"English\",\n",+ " \"output_language\": \"German\",\n",+ " \"input\": \"I love programming.\",\n",+ " }\n",+ ")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "d1ee55bc-ffc8-4cfa-801c-993953a08cfd",+ "metadata": {},+ "source": [+ "## TODO: Any functionality specific to this model provider\n",+ "\n",+ "E.g. creating/using finetuned models via this provider. Delete if not relevant."+ ]+ },+ {+ "cell_type": "markdown",+ "id": "3a5bb5ca-c3ae-4a58-be67-2cd18574b9a3",+ "metadata": {},+ "source": [+ "## API reference\n",+ "\n",+ "For detailed documentation of all Chat__ModuleName__ features and configurations head to the [API reference](https://python.langchain.com/api_reference/__package_name_short_snake__/chat_models/__module_name__.chat_models.Chat__ModuleName__.html)"+ ]+ }+ ],+ "metadata": {+ "kernelspec": {+ "display_name": "Python 3 (ipykernel)",+ "language": "python",+ "name": "python3"+ },+ "language_info": {+ "codemirror_mode": {+ "name": "ipython",+ "version": 3+ },+ "file_extension": ".py",+ "mimetype": "text/x-python",+ "name": "python",+ "nbconvert_exporter": "python",+ "pygments_lexer": "ipython3",+ "version": "3.11.9"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 5}diff --git a/libs/cli/langchain_cli/integration_template/docs/document_loaders.ipynb b/libs/cli/langchain_cli/integration_template/docs/document_loaders.ipynbindex 072ba47466..b7779b4a6f 100644--- a/libs/cli/langchain_cli/integration_template/docs/document_loaders.ipynb+++ b/libs/cli/langchain_cli/integration_template/docs/document_loaders.ipynb@@ -1,217 +1,219 @@{- "cells": [- {- "cell_type": "markdown",- "metadata": {},- "source": [- "---\n",- "sidebar_label: __ModuleName__\n",- "---"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "# __ModuleName__Loader\n",- "\n",- "- TODO: Make sure API reference link is correct.\n",- "\n",- "This notebook provides a quick overview for getting started with __ModuleName__ [document loader](https://python.langchain.com/docs/concepts/document_loaders). For detailed documentation of all __ModuleName__Loader features and configurations head to the [API reference](https://python.langchain.com/v0.2/api_reference/community/document_loaders/langchain_community.document_loaders.__module_name___loader.__ModuleName__Loader.html).\n",- "\n",- "- TODO: Add any other relevant links, like information about underlying API, etc.\n",- "\n",- "## Overview\n",- "### Integration details\n",- "\n",- "- TODO: Fill in table features.\n",- "- TODO: Remove JS support link if not relevant, otherwise ensure link is correct.\n",- "- TODO: Make sure API reference links are correct.\n",- "\n",- "| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/document_loaders/web_loaders/__module_name___loader)|\n",- "| :--- | :--- | :---: | :---: | :---: |\n",- "| [__ModuleName__Loader](https://python.langchain.com/v0.2/api_reference/community/document_loaders/langchain_community.document_loaders.__module_name__loader.__ModuleName__Loader.html) | [langchain_community](https://api.python.langchain.com/en/latest/community_api_reference.html) | ✅/❌ | beta/❌ | ✅/❌ | \n",- "### Loader features\n",- "| Source | Document Lazy Loading | Native Async Support\n",- "| :---: | :---: | :---: | \n",- "| __ModuleName__Loader | ✅/❌ | ✅/❌ | \n",- "\n",- "## Setup\n",- "\n",- "- TODO: Update with relevant info.\n",- "\n",- "To access __ModuleName__ document loader you'll need to install the `__package_name__` integration package, and create a **ModuleName** account and get an API key.\n",- "\n",- "### Credentials\n",- "\n",- "- TODO: Update with relevant info.\n",- "\n",- "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "import getpass\n",- "import os\n",- "\n",- "os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\"Enter your __ModuleName__ API key: \")"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")\n",- "# os.environ[\"LANGSMITH_TRACING\"] = \"true\""- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "### Installation\n",- "\n",- "Install **langchain_community**.\n",- "\n",- "- TODO: Add any other required packages"- ]- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "%pip install -qU langchain_community"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "## Initialization\n",- "\n",- "Now we can instantiate our model object and load documents:\n",- "\n",- "- TODO: Update model instantiation with relevant params."- ]- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "from langchain_community.document_loaders import __ModuleName__Loader\n",- "\n",- "loader = __ModuleName__Loader(\n",- " # required params = ...\n",- " # optional params = ...\n",- ")"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "## Load\n",- "\n",- "- TODO: Run cells to show loading capabilities"- ]- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "docs = loader.load()\n",- "docs[0]"- ]- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "print(docs[0].metadata)"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "## Lazy Load\n",- "\n",- "- TODO: Run cells to show lazy loading capabilities. Delete if lazy loading is not implemented."- ]- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "page = []\n",- "for doc in loader.lazy_load():\n",- " page.append(doc)\n",- " if len(page) >= 10:\n",- " # do some paged operation, e.g.\n",- " # index.upsert(page)\n",- "\n",- " page = []"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "## TODO: Any functionality specific to this document loader\n",- "\n",- "E.g. using specific configs for different loading behavior. Delete if not relevant."- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "## API reference\n",- "\n",- "For detailed documentation of all __ModuleName__Loader features and configurations head to the API reference: https://python.langchain.com/v0.2/api_reference/community/document_loaders/langchain_community.document_loaders.__module_name___loader.__ModuleName__Loader.html"- ]- }- ],- "metadata": {- "kernelspec": {- "display_name": "Python 3 (ipykernel)",- "language": "python",- "name": "python3"- },- "language_info": {- "codemirror_mode": {- "name": "ipython",- "version": 3- },- "file_extension": ".py",- "mimetype": "text/x-python",- "name": "python",- "nbconvert_exporter": "python",- "pygments_lexer": "ipython3",- "version": "3.11.9"- }- },- "nbformat": 4,- "nbformat_minor": 4+ "cells": [+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "---\n",+ "sidebar_label: __ModuleName__\n",+ "---"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "# __ModuleName__Loader\n",+ "\n",+ "- TODO: Make sure API reference link is correct.\n",+ "\n",+ "This notebook provides a quick overview for getting started with __ModuleName__ [document loader](https://python.langchain.com/docs/concepts/document_loaders). For detailed documentation of all __ModuleName__Loader features and configurations head to the [API reference](https://python.langchain.com/v0.2/api_reference/community/document_loaders/langchain_community.document_loaders.__module_name___loader.__ModuleName__Loader.html).\n",+ "\n",+ "- TODO: Add any other relevant links, like information about underlying API, etc.\n",+ "\n",+ "## Overview\n",+ "### Integration details\n",+ "\n",+ "- TODO: Fill in table features.\n",+ "- TODO: Remove JS support link if not relevant, otherwise ensure link is correct.\n",+ "- TODO: Make sure API reference links are correct.\n",+ "\n",+ "| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/document_loaders/web_loaders/__module_name___loader)|\n",+ "| :--- | :--- | :---: | :---: | :---: |\n",+ "| [__ModuleName__Loader](https://python.langchain.com/v0.2/api_reference/community/document_loaders/langchain_community.document_loaders.__module_name__loader.__ModuleName__Loader.html) | [langchain_community](https://api.python.langchain.com/en/latest/community_api_reference.html) | ✅/❌ | beta/❌ | ✅/❌ | \n",+ "### Loader features\n",+ "| Source | Document Lazy Loading | Native Async Support\n",+ "| :---: | :---: | :---: | \n",+ "| __ModuleName__Loader | ✅/❌ | ✅/❌ | \n",+ "\n",+ "## Setup\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "\n",+ "To access __ModuleName__ document loader you'll need to install the `__package_name__` integration package, and create a **ModuleName** account and get an API key.\n",+ "\n",+ "### Credentials\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "\n",+ "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "import getpass\n",+ "import os\n",+ "\n",+ "os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\n",+ " \"Enter your __ModuleName__ API key: \"\n",+ ")"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")\n",+ "# os.environ[\"LANGSMITH_TRACING\"] = \"true\""+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "### Installation\n",+ "\n",+ "Install **langchain_community**.\n",+ "\n",+ "- TODO: Add any other required packages"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "%pip install -qU langchain_community"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "## Initialization\n",+ "\n",+ "Now we can instantiate our model object and load documents:\n",+ "\n",+ "- TODO: Update model instantiation with relevant params."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "from langchain_community.document_loaders import __ModuleName__Loader\n",+ "\n",+ "loader = __ModuleName__Loader(\n",+ " # required params = ...\n",+ " # optional params = ...\n",+ ")"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "## Load\n",+ "\n",+ "- TODO: Run cells to show loading capabilities"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "docs = loader.load()\n",+ "docs[0]"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "print(docs[0].metadata)"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "## Lazy Load\n",+ "\n",+ "- TODO: Run cells to show lazy loading capabilities. Delete if lazy loading is not implemented."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {},+ "outputs": [],+ "source": [+ "page = []\n",+ "for doc in loader.lazy_load():\n",+ " page.append(doc)\n",+ " if len(page) >= 10:\n",+ " # do some paged operation, e.g.\n",+ " # index.upsert(page)\n",+ "\n",+ " page = []"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "## TODO: Any functionality specific to this document loader\n",+ "\n",+ "E.g. using specific configs for different loading behavior. Delete if not relevant."+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {},+ "source": [+ "## API reference\n",+ "\n",+ "For detailed documentation of all __ModuleName__Loader features and configurations head to the API reference: https://python.langchain.com/v0.2/api_reference/community/document_loaders/langchain_community.document_loaders.__module_name___loader.__ModuleName__Loader.html"+ ]+ }+ ],+ "metadata": {+ "kernelspec": {+ "display_name": "Python 3 (ipykernel)",+ "language": "python",+ "name": "python3"+ },+ "language_info": {+ "codemirror_mode": {+ "name": "ipython",+ "version": 3+ },+ "file_extension": ".py",+ "mimetype": "text/x-python",+ "name": "python",+ "nbconvert_exporter": "python",+ "pygments_lexer": "ipython3",+ "version": "3.11.9"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 4}diff --git a/libs/cli/langchain_cli/integration_template/docs/llms.ipynb b/libs/cli/langchain_cli/integration_template/docs/llms.ipynbindex 4700ced811..217929fff7 100644--- a/libs/cli/langchain_cli/integration_template/docs/llms.ipynb+++ b/libs/cli/langchain_cli/integration_template/docs/llms.ipynb@@ -1,236 +1,236 @@{- "cells": [- {- "cell_type": "raw",- "id": "67db2992",- "metadata": {},- "source": [- "---\n",- "sidebar_label: __ModuleName__\n",- "---"- ]- },- {- "cell_type": "markdown",- "id": "9597802c",- "metadata": {},- "source": [- "# __ModuleName__LLM\n",- "\n",- "- [ ] TODO: Make sure API reference link is correct\n",- "\n",- "This will help you get started with __ModuleName__ completion models (LLMs) using LangChain. For detailed documentation on `__ModuleName__LLM` features and configuration options, please refer to the [API reference](https://api.python.langchain.com/en/latest/llms/__module_name__.llms.__ModuleName__LLM.html).\n",- "\n",- "## Overview\n",- "### Integration details\n",- "\n",- "- TODO: Fill in table features.\n",- "- TODO: Remove JS support link if not relevant, otherwise ensure link is correct.\n",- "- TODO: Make sure API reference links are correct.\n",- "\n",- "| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/llms/__package_name_short_snake__) | Package downloads | Package latest |\n",- "| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",- "| [__ModuleName__LLM](https://api.python.langchain.com/en/latest/llms/__module_name__.llms.__ModuleName__LLM.html) | [__package_name__](https://api.python.langchain.com/en/latest/__package_name_short_snake___api_reference.html) | ✅/❌ | beta/❌ | ✅/❌ |  |  |\n",- "\n",- "## Setup\n",- "\n",- "- TODO: Update with relevant info.\n",- "\n",- "To access __ModuleName__ models you'll need to create a/an __ModuleName__ account, get an API key, and install the `__package_name__` integration package.\n",- "\n",- "### Credentials\n",- "\n",- "- TODO: Update with relevant info.\n",- "\n",- "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "bc51e756",- "metadata": {},- "outputs": [],- "source": [- "import getpass\n",- "import os\n",- "\n",- "if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",- " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\"Enter your __ModuleName__ API key: \")"- ]- },- {- "cell_type": "markdown",- "id": "4b6e1ca6",- "metadata": {},- "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"- },- {- "cell_type": "code",- "execution_count": null,- "id": "196c2b41",- "metadata": {},- "outputs": [],- "source": [- "# os.environ[\"LANGSMITH_TRACING\"] = \"true\"\n",- "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"- ]- },- {- "cell_type": "markdown",- "id": "809c6577",- "metadata": {},- "source": [- "### Installation\n",- "\n",- "The LangChain __ModuleName__ integration lives in the `__package_name__` package:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "59c710c4",- "metadata": {},- "outputs": [],- "source": [- "%pip install -qU __package_name__"- ]- },- {- "cell_type": "markdown",- "id": "0a760037",- "metadata": {},- "source": [- "## Instantiation\n",- "\n",- "Now we can instantiate our model object and generate chat completions:\n",- "\n",- "- TODO: Update model instantiation with relevant params."- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "a0562a13",- "metadata": {},- "outputs": [],- "source": [- "from __module_name__ import __ModuleName__LLM\n",- "\n",- "llm = __ModuleName__LLM(\n",- " model=\"model-name\",\n",- " temperature=0,\n",- " max_tokens=None,\n",- " timeout=None,\n",- " max_retries=2,\n",- " # other params...\n",- ")"- ]- },- {- "cell_type": "markdown",- "id": "0ee90032",- "metadata": {},- "source": [- "## Invocation\n",- "\n",- "- [ ] TODO: Run cells so output can be seen."- ]- },- {- "cell_type": "code",- "execution_count": 4,- "id": "035dea0f",- "metadata": {- "tags": []- },- "outputs": [],- "source": [- "input_text = \"__ModuleName__ is an AI company that \"\n",- "\n",- "completion = llm.invoke(input_text)\n",- "completion"- ]- },- {- "cell_type": "markdown",- "id": "add38532",- "metadata": {},- "source": [- "## Chaining\n",- "\n",- "We can [chain](/docs/how_to/sequence/) our completion model with a prompt template like so:\n",- "\n",- "- TODO: Run cells so output can be seen."- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "078e9db2",- "metadata": {},- "outputs": [],- "source": [- "from langchain_core.prompts import PromptTemplate\n",- "\n",- "prompt = PromptTemplate(\n",- " \"How to say {input} in {output_language}:\\n\"\n",- ")\n",- "\n",- "chain = prompt | llm\n",- "chain.invoke(\n",- " {\n",- " \"output_language\": \"German\",\n",- " \"input\": \"I love programming.\",\n",- " }\n",- ")"- ]- },- {- "cell_type": "markdown",- "id": "e99eef30",- "metadata": {},- "source": [- "## TODO: Any functionality specific to this model provider\n",- "\n",- "E.g. creating/using finetuned models via this provider. Delete if not relevant"- ]- },- {- "cell_type": "markdown",- "id": "e9bdfcef",- "metadata": {},- "source": [- "## API reference\n",- "\n",- "For detailed documentation of all `__ModuleName__LLM` features and configurations head to the API reference: https://api.python.langchain.com/en/latest/llms/__module_name__.llms.__ModuleName__LLM.html"- ]- }- ],- "metadata": {- "kernelspec": {- "display_name": "Python 3.11.1 64-bit",- "language": "python",- "name": "python3"- },- "language_info": {- "codemirror_mode": {- "name": "ipython",- "version": 3- },- "file_extension": ".py",- "mimetype": "text/x-python",- "name": "python",- "nbconvert_exporter": "python",- "pygments_lexer": "ipython3",- "version": "3.9.7"- },- "vscode": {- "interpreter": {- "hash": "e971737741ff4ec9aff7dc6155a1060a59a8a6d52c757dbbe66bf8ee389494b1"- }- }- },- "nbformat": 4,- "nbformat_minor": 5+ "cells": [+ {+ "cell_type": "raw",+ "id": "67db2992",+ "metadata": {},+ "source": [+ "---\n",+ "sidebar_label: __ModuleName__\n",+ "---"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "9597802c",+ "metadata": {},+ "source": [+ "# __ModuleName__LLM\n",+ "\n",+ "- [ ] TODO: Make sure API reference link is correct\n",+ "\n",+ "This will help you get started with __ModuleName__ completion models (LLMs) using LangChain. For detailed documentation on `__ModuleName__LLM` features and configuration options, please refer to the [API reference](https://api.python.langchain.com/en/latest/llms/__module_name__.llms.__ModuleName__LLM.html).\n",+ "\n",+ "## Overview\n",+ "### Integration details\n",+ "\n",+ "- TODO: Fill in table features.\n",+ "- TODO: Remove JS support link if not relevant, otherwise ensure link is correct.\n",+ "- TODO: Make sure API reference links are correct.\n",+ "\n",+ "| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/docs/integrations/llms/__package_name_short_snake__) | Package downloads | Package latest |\n",+ "| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",+ "| [__ModuleName__LLM](https://api.python.langchain.com/en/latest/llms/__module_name__.llms.__ModuleName__LLM.html) | [__package_name__](https://api.python.langchain.com/en/latest/__package_name_short_snake___api_reference.html) | ✅/❌ | beta/❌ | ✅/❌ |  |  |\n",+ "\n",+ "## Setup\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "\n",+ "To access __ModuleName__ models you'll need to create a/an __ModuleName__ account, get an API key, and install the `__package_name__` integration package.\n",+ "\n",+ "### Credentials\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "\n",+ "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "bc51e756",+ "metadata": {},+ "outputs": [],+ "source": [+ "import getpass\n",+ "import os\n",+ "\n",+ "if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",+ " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\n",+ " \"Enter your __ModuleName__ API key: \"\n",+ " )"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "4b6e1ca6",+ "metadata": {},+ "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "196c2b41",+ "metadata": {},+ "outputs": [],+ "source": [+ "# os.environ[\"LANGSMITH_TRACING\"] = \"true\"\n",+ "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "809c6577",+ "metadata": {},+ "source": [+ "### Installation\n",+ "\n",+ "The LangChain __ModuleName__ integration lives in the `__package_name__` package:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "59c710c4",+ "metadata": {},+ "outputs": [],+ "source": [+ "%pip install -qU __package_name__"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "0a760037",+ "metadata": {},+ "source": [+ "## Instantiation\n",+ "\n",+ "Now we can instantiate our model object and generate chat completions:\n",+ "\n",+ "- TODO: Update model instantiation with relevant params."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "a0562a13",+ "metadata": {},+ "outputs": [],+ "source": [+ "from __module_name__ import __ModuleName__LLM\n",+ "\n",+ "llm = __ModuleName__LLM(\n",+ " model=\"model-name\",\n",+ " temperature=0,\n",+ " max_tokens=None,\n",+ " timeout=None,\n",+ " max_retries=2,\n",+ " # other params...\n",+ ")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "0ee90032",+ "metadata": {},+ "source": [+ "## Invocation\n",+ "\n",+ "- [ ] TODO: Run cells so output can be seen."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": 4,+ "id": "035dea0f",+ "metadata": {+ "tags": []+ },+ "outputs": [],+ "source": [+ "input_text = \"__ModuleName__ is an AI company that \"\n",+ "\n",+ "completion = llm.invoke(input_text)\n",+ "completion"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "add38532",+ "metadata": {},+ "source": [+ "## Chaining\n",+ "\n",+ "We can [chain](/docs/how_to/sequence/) our completion model with a prompt template like so:\n",+ "\n",+ "- TODO: Run cells so output can be seen."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "078e9db2",+ "metadata": {},+ "outputs": [],+ "source": [+ "from langchain_core.prompts import PromptTemplate\n",+ "\n",+ "prompt = PromptTemplate(\"How to say {input} in {output_language}:\\n\")\n",+ "\n",+ "chain = prompt | llm\n",+ "chain.invoke(\n",+ " {\n",+ " \"output_language\": \"German\",\n",+ " \"input\": \"I love programming.\",\n",+ " }\n",+ ")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "e99eef30",+ "metadata": {},+ "source": [+ "## TODO: Any functionality specific to this model provider\n",+ "\n",+ "E.g. creating/using finetuned models via this provider. Delete if not relevant"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "e9bdfcef",+ "metadata": {},+ "source": [+ "## API reference\n",+ "\n",+ "For detailed documentation of all `__ModuleName__LLM` features and configurations head to the API reference: https://api.python.langchain.com/en/latest/llms/__module_name__.llms.__ModuleName__LLM.html"+ ]+ }+ ],+ "metadata": {+ "kernelspec": {+ "display_name": "Python 3.11.1 64-bit",+ "language": "python",+ "name": "python3"+ },+ "language_info": {+ "codemirror_mode": {+ "name": "ipython",+ "version": 3+ },+ "file_extension": ".py",+ "mimetype": "text/x-python",+ "name": "python",+ "nbconvert_exporter": "python",+ "pygments_lexer": "ipython3",+ "version": "3.9.7"+ },+ "vscode": {+ "interpreter": {+ "hash": "e971737741ff4ec9aff7dc6155a1060a59a8a6d52c757dbbe66bf8ee389494b1"+ }+ }+ },+ "nbformat": 4,+ "nbformat_minor": 5}diff --git a/libs/cli/langchain_cli/integration_template/docs/stores.ipynb b/libs/cli/langchain_cli/integration_template/docs/stores.ipynbindex 7f5a48aa1a..5daa0568c4 100644--- a/libs/cli/langchain_cli/integration_template/docs/stores.ipynb+++ b/libs/cli/langchain_cli/integration_template/docs/stores.ipynb@@ -62,7 +62,9 @@"import os\n","\n","if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",- " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\"Enter your __ModuleName__ API key: \")"+ " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\n",+ " \"Enter your __ModuleName__ API key: \"\n",+ " )"]},{diff --git a/libs/cli/langchain_cli/integration_template/docs/text_embedding.ipynb b/libs/cli/langchain_cli/integration_template/docs/text_embedding.ipynbindex 306512bde2..3f400248b0 100644--- a/libs/cli/langchain_cli/integration_template/docs/text_embedding.ipynb+++ b/libs/cli/langchain_cli/integration_template/docs/text_embedding.ipynb@@ -1,244 +1,246 @@{- "cells": [- {- "cell_type": "raw",- "id": "afaf8039",- "metadata": {},- "source": [- "---\n",- "sidebar_label: __ModuleName__\n",- "---"- ]- },- {- "cell_type": "markdown",- "id": "9a3d6f34",- "metadata": {},- "source": [- "# __ModuleName__Embeddings\n",- "\n",- "- [ ] TODO: Make sure API reference link is correct\n",- "\n",- "This will help you get started with __ModuleName__ embedding models using LangChain. For detailed documentation on `__ModuleName__Embeddings` features and configuration options, please refer to the [API reference](https://python.langchain.com/v0.2/api_reference/__package_name_short__/embeddings/__module_name__.embeddings__ModuleName__Embeddings.html).\n",- "\n",- "## Overview\n",- "### Integration details\n",- "\n",- "| Provider | Package |\n",- "|:--------:|:-------:|\n",- "| [__ModuleName__](/docs/integrations/providers/__package_name_short__/) | [__package_name__](https://python.langchain.com/v0.2/api_reference/__module_name__/embeddings/__module_name__.embeddings__ModuleName__Embeddings.html) |\n",- "\n",- "## Setup\n",- "\n",- "- [ ] TODO: Update with relevant info.\n",- "\n",- "To access __ModuleName__ embedding models you'll need to create a/an __ModuleName__ account, get an API key, and install the `__package_name__` integration package.\n",- "\n",- "### Credentials\n",- "\n",- "- TODO: Update with relevant info.\n",- "\n",- "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "36521c2a",- "metadata": {},- "outputs": [],- "source": [- "import getpass\n",- "import os\n",- "\n",- "if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",- " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\"Enter your __ModuleName__ API key: \")"- ]- },- {- "cell_type": "markdown",- "id": "c84fb993",- "metadata": {},- "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"- },- {- "cell_type": "code",- "execution_count": null,- "id": "39a4953b",- "metadata": {},- "outputs": [],- "source": [- "# os.environ[\"LANGSMITH_TRACING\"] = \"true\"\n",- "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"- ]- },- {- "cell_type": "markdown",- "id": "d9664366",- "metadata": {},- "source": [- "### Installation\n",- "\n",- "The LangChain __ModuleName__ integration lives in the `__package_name__` package:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "64853226",- "metadata": {},- "outputs": [],- "source": [- "%pip install -qU __package_name__"- ]- },- {- "cell_type": "markdown",- "id": "45dd1724",- "metadata": {},- "source": [- "## Instantiation\n",- "\n",- "Now we can instantiate our model object and generate chat completions:\n",- "\n",- "- TODO: Update model instantiation with relevant params."- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "9ea7a09b",- "metadata": {},- "outputs": [],- "source": [- "from __module_name__ import __ModuleName__Embeddings\n",- "\n",- "embeddings = __ModuleName__Embeddings(\n",- " model=\"model-name\",\n",- ")"- ]- },- {- "cell_type": "markdown",- "id": "77d271b6",- "metadata": {},- "source": [- "## Indexing and Retrieval\n",- "\n",- "Embedding models are often used in retrieval-augmented generation (RAG) flows, both as part of indexing data as well as later retrieving it. For more detailed instructions, please see our [RAG tutorials](/docs/tutorials/).\n",- "\n",- "Below, see how to index and retrieve data using the `embeddings` object we initialized above. In this example, we will index and retrieve a sample document in the `InMemoryVectorStore`."- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "d817716b",- "metadata": {},- "outputs": [],- "source": [- "# Create a vector store with a sample text\n",- "from langchain_core.vectorstores import InMemoryVectorStore\n",- "\n",- "text = \"LangChain is the framework for building context-aware reasoning applications\"\n",- "\n",- "vectorstore = InMemoryVectorStore.from_texts(\n",- " [text],\n",- " embedding=embeddings,\n",- ")\n",- "\n",- "# Use the vectorstore as a retriever\n",- "retriever = vectorstore.as_retriever()\n",- "\n",- "# Retrieve the most similar text\n",- "retrieved_documents = retriever.invoke(\"What is LangChain?\")\n",- "\n",- "# show the retrieved document's content\n",- "retrieved_documents[0].page_content"- ]- },- {- "cell_type": "markdown",- "id": "e02b9855",- "metadata": {},- "source": [- "## Direct Usage\n",- "\n",- "Under the hood, the vectorstore and retriever implementations are calling `embeddings.embed_documents(...)` and `embeddings.embed_query(...)` to create embeddings for the text(s) used in `from_texts` and retrieval `invoke` operations, respectively.\n",- "\n",- "You can directly call these methods to get embeddings for your own use cases.\n",- "\n",- "### Embed single texts\n",- "\n",- "You can embed single texts or documents with `embed_query`:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "0d2befcd",- "metadata": {},- "outputs": [],- "source": [- "single_vector = embeddings.embed_query(text)\n",- "print(str(single_vector)[:100]) # Show the first 100 characters of the vector"- ]- },- {- "cell_type": "markdown",- "id": "1b5a7d03",- "metadata": {},- "source": [- "### Embed multiple texts\n",- "\n",- "You can embed multiple texts with `embed_documents`:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "2f4d6e97",- "metadata": {},- "outputs": [],- "source": [- "text2 = (\n",- " \"LangGraph is a library for building stateful, multi-actor applications with LLMs\"\n",- ")\n",- "two_vectors = embeddings.embed_documents([text, text2])\n",- "for vector in two_vectors:\n",- " print(str(vector)[:100]) # Show the first 100 characters of the vector"- ]- },- {- "cell_type": "markdown",- "id": "98785c12",- "metadata": {},- "source": [- "## API Reference\n",- "\n",- "For detailed documentation on `__ModuleName__Embeddings` features and configuration options, please refer to the [API reference](https://api.python.langchain.com/en/latest/embeddings/__module_name__.embeddings.__ModuleName__Embeddings.html).\n"- ]- }- ],- "metadata": {- "kernelspec": {- "display_name": "Python 3 (ipykernel)",- "language": "python",- "name": "python3"- },- "language_info": {- "codemirror_mode": {- "name": "ipython",- "version": 3- },- "file_extension": ".py",- "mimetype": "text/x-python",- "name": "python",- "nbconvert_exporter": "python",- "pygments_lexer": "ipython3",- "version": "3.10.5"- }- },- "nbformat": 4,- "nbformat_minor": 5+ "cells": [+ {+ "cell_type": "raw",+ "id": "afaf8039",+ "metadata": {},+ "source": [+ "---\n",+ "sidebar_label: __ModuleName__\n",+ "---"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "9a3d6f34",+ "metadata": {},+ "source": [+ "# __ModuleName__Embeddings\n",+ "\n",+ "- [ ] TODO: Make sure API reference link is correct\n",+ "\n",+ "This will help you get started with __ModuleName__ embedding models using LangChain. For detailed documentation on `__ModuleName__Embeddings` features and configuration options, please refer to the [API reference](https://python.langchain.com/v0.2/api_reference/__package_name_short__/embeddings/__module_name__.embeddings__ModuleName__Embeddings.html).\n",+ "\n",+ "## Overview\n",+ "### Integration details\n",+ "\n",+ "| Provider | Package |\n",+ "|:--------:|:-------:|\n",+ "| [__ModuleName__](/docs/integrations/providers/__package_name_short__/) | [__package_name__](https://python.langchain.com/v0.2/api_reference/__module_name__/embeddings/__module_name__.embeddings__ModuleName__Embeddings.html) |\n",+ "\n",+ "## Setup\n",+ "\n",+ "- [ ] TODO: Update with relevant info.\n",+ "\n",+ "To access __ModuleName__ embedding models you'll need to create a/an __ModuleName__ account, get an API key, and install the `__package_name__` integration package.\n",+ "\n",+ "### Credentials\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "\n",+ "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "36521c2a",+ "metadata": {},+ "outputs": [],+ "source": [+ "import getpass\n",+ "import os\n",+ "\n",+ "if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",+ " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\n",+ " \"Enter your __ModuleName__ API key: \"\n",+ " )"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "c84fb993",+ "metadata": {},+ "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "39a4953b",+ "metadata": {},+ "outputs": [],+ "source": [+ "# os.environ[\"LANGSMITH_TRACING\"] = \"true\"\n",+ "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "d9664366",+ "metadata": {},+ "source": [+ "### Installation\n",+ "\n",+ "The LangChain __ModuleName__ integration lives in the `__package_name__` package:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "64853226",+ "metadata": {},+ "outputs": [],+ "source": [+ "%pip install -qU __package_name__"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "45dd1724",+ "metadata": {},+ "source": [+ "## Instantiation\n",+ "\n",+ "Now we can instantiate our model object and generate chat completions:\n",+ "\n",+ "- TODO: Update model instantiation with relevant params."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "9ea7a09b",+ "metadata": {},+ "outputs": [],+ "source": [+ "from __module_name__ import __ModuleName__Embeddings\n",+ "\n",+ "embeddings = __ModuleName__Embeddings(\n",+ " model=\"model-name\",\n",+ ")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "77d271b6",+ "metadata": {},+ "source": [+ "## Indexing and Retrieval\n",+ "\n",+ "Embedding models are often used in retrieval-augmented generation (RAG) flows, both as part of indexing data as well as later retrieving it. For more detailed instructions, please see our [RAG tutorials](/docs/tutorials/).\n",+ "\n",+ "Below, see how to index and retrieve data using the `embeddings` object we initialized above. In this example, we will index and retrieve a sample document in the `InMemoryVectorStore`."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "d817716b",+ "metadata": {},+ "outputs": [],+ "source": [+ "# Create a vector store with a sample text\n",+ "from langchain_core.vectorstores import InMemoryVectorStore\n",+ "\n",+ "text = \"LangChain is the framework for building context-aware reasoning applications\"\n",+ "\n",+ "vectorstore = InMemoryVectorStore.from_texts(\n",+ " [text],\n",+ " embedding=embeddings,\n",+ ")\n",+ "\n",+ "# Use the vectorstore as a retriever\n",+ "retriever = vectorstore.as_retriever()\n",+ "\n",+ "# Retrieve the most similar text\n",+ "retrieved_documents = retriever.invoke(\"What is LangChain?\")\n",+ "\n",+ "# show the retrieved document's content\n",+ "retrieved_documents[0].page_content"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "e02b9855",+ "metadata": {},+ "source": [+ "## Direct Usage\n",+ "\n",+ "Under the hood, the vectorstore and retriever implementations are calling `embeddings.embed_documents(...)` and `embeddings.embed_query(...)` to create embeddings for the text(s) used in `from_texts` and retrieval `invoke` operations, respectively.\n",+ "\n",+ "You can directly call these methods to get embeddings for your own use cases.\n",+ "\n",+ "### Embed single texts\n",+ "\n",+ "You can embed single texts or documents with `embed_query`:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "0d2befcd",+ "metadata": {},+ "outputs": [],+ "source": [+ "single_vector = embeddings.embed_query(text)\n",+ "print(str(single_vector)[:100]) # Show the first 100 characters of the vector"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "1b5a7d03",+ "metadata": {},+ "source": [+ "### Embed multiple texts\n",+ "\n",+ "You can embed multiple texts with `embed_documents`:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "2f4d6e97",+ "metadata": {},+ "outputs": [],+ "source": [+ "text2 = (\n",+ " \"LangGraph is a library for building stateful, multi-actor applications with LLMs\"\n",+ ")\n",+ "two_vectors = embeddings.embed_documents([text, text2])\n",+ "for vector in two_vectors:\n",+ " print(str(vector)[:100]) # Show the first 100 characters of the vector"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "98785c12",+ "metadata": {},+ "source": [+ "## API Reference\n",+ "\n",+ "For detailed documentation on `__ModuleName__Embeddings` features and configuration options, please refer to the [API reference](https://api.python.langchain.com/en/latest/embeddings/__module_name__.embeddings.__ModuleName__Embeddings.html).\n"+ ]+ }+ ],+ "metadata": {+ "kernelspec": {+ "display_name": "Python 3 (ipykernel)",+ "language": "python",+ "name": "python3"+ },+ "language_info": {+ "codemirror_mode": {+ "name": "ipython",+ "version": 3+ },+ "file_extension": ".py",+ "mimetype": "text/x-python",+ "name": "python",+ "nbconvert_exporter": "python",+ "pygments_lexer": "ipython3",+ "version": "3.10.5"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 5}diff --git a/libs/cli/langchain_cli/integration_template/docs/tools.ipynb b/libs/cli/langchain_cli/integration_template/docs/tools.ipynbindex f62e83fc6d..a160b95658 100644--- a/libs/cli/langchain_cli/integration_template/docs/tools.ipynb+++ b/libs/cli/langchain_cli/integration_template/docs/tools.ipynb@@ -120,9 +120,7 @@"from langchain_community.tools import __ModuleName__\n","\n","\n",- "tool = __ModuleName__(\n",- " ...\n",- ")"+ "tool = __ModuleName__(...)"]},{diff --git a/libs/cli/langchain_cli/integration_template/docs/vectorstores.ipynb b/libs/cli/langchain_cli/integration_template/docs/vectorstores.ipynbindex dcc1869654..7f7f58b15c 100644--- a/libs/cli/langchain_cli/integration_template/docs/vectorstores.ipynb+++ b/libs/cli/langchain_cli/integration_template/docs/vectorstores.ipynb@@ -1,340 +1,333 @@{- "cells": [- {- "cell_type": "raw",- "id": "1957f5cb",- "metadata": {},- "source": [- "---\n",- "sidebar_label: __ModuleName__\n",- "---"- ]- },- {- "cell_type": "markdown",- "id": "ef1f0986",- "metadata": {},- "source": [- "# __ModuleName__VectorStore\n",- "\n",- "This notebook covers how to get started with the __ModuleName__ vector store."- ]- },- {- "cell_type": "markdown",- "id": "36fdc060",- "metadata": {},- "source": [- "## Setup\n",- "\n",- "- TODO: Update with relevant info.\n",- "- TODO: Update minimum version to be correct.\n",- "\n",- "To access __ModuleName__ vector stores you'll need to create a/an __ModuleName__ account, get an API key, and install the `__package_name__` integration package."- ]- },- {- "cell_type": "raw",- "id": "64e28aa6",- "metadata": {- "vscode": {- "languageId": "raw"- }- },- "source": [- "%pip install -qU \"__package_name__>=MINIMUM_VERSION\""- ]- },- {- "cell_type": "markdown",- "id": "9695dee7",- "metadata": {},- "source": [- "### Credentials\n",- "\n",- "- TODO: Update with relevant info.\n",- "\n",- "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "894c30e4",- "metadata": {},- "outputs": [],- "source": [- "import getpass\n",- "import os\n",- "\n",- "if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",- " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\"Enter your __ModuleName__ API key: \")"- ]- },- {- "cell_type": "markdown",- "id": "7f98392b",- "metadata": {},- "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"- },- {- "cell_type": "code",- "execution_count": null,- "id": "e7b6a6e0",- "metadata": {},- "outputs": [],- "source": [- "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")\n",- "# os.environ[\"LANGSMITH_TRACING\"] = \"true\""- ]- },- {- "cell_type": "markdown",- "id": "93df377e",- "metadata": {},- "source": [- "## Initialization\n",- "\n",- "- TODO: Fill out with relevant init params\n",- "\n",- "\n",- "```{=mdx}\n",- "import EmbeddingTabs from \"@theme/EmbeddingTabs\";\n",- "\n",- "<EmbeddingTabs/>\n",- "```"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "dc37144c-208d-4ab3-9f3a-0407a69fe052",- "metadata": {- "tags": []- },- "outputs": [],- "source": [- "from __module_name__.vectorstores import __ModuleName__VectorStore\n",- "\n",- "vector_store = __ModuleName__VectorStore(embeddings=embeddings)"- ]- },- {- "cell_type": "markdown",- "id": "ac6071d4",- "metadata": {},- "source": [- "## Manage vector store\n",- "\n",- "### Add items to vector store\n",- "\n",- "- TODO: Edit and then run code cell to generate output"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "17f5efc0",- "metadata": {},- "outputs": [],- "source": [- "from langchain_core.documents import Document\n",- "\n",- "document_1 = Document(\n",- " page_content=\"foo\",\n",- " metadata={\"source\": \"https://example.com\"}\n",- ")\n",- "\n",- "document_2 = Document(\n",- " page_content=\"bar\",\n",- " metadata={\"source\": \"https://example.com\"}\n",- ")\n",- "\n",- "document_3 = Document(\n",- " page_content=\"baz\",\n",- " metadata={\"source\": \"https://example.com\"}\n",- ")\n",- "\n",- "documents = [document_1, document_2, document_3]\n",- "\n",- "vector_store.add_documents(documents=documents,ids=[\"1\",\"2\",\"3\"])"- ]- },- {- "cell_type": "markdown",- "id": "c738c3e0",- "metadata": {},- "source": [- "### Update items in vector store\n",- "\n",- "- TODO: Edit and then run code cell to generate output"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "f0aa8b71",- "metadata": {},- "outputs": [],- "source": [- "updated_document = Document(\n",- " page_content=\"qux\",\n",- " metadata={\"source\": \"https://another-example.com\"}\n",- ")\n",- "\n",- "vector_store.update_documents(document_id=\"1\",document=updated_document)"- ]- },- {- "cell_type": "markdown",- "id": "dcf1b905",- "metadata": {},- "source": [- "### Delete items from vector store\n",- "\n",- "- TODO: Edit and then run code cell to generate output"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "ef61e188",- "metadata": {},- "outputs": [],- "source": [- "vector_store.delete(ids=[\"3\"])"- ]- },- {- "cell_type": "markdown",- "id": "c3620501",- "metadata": {},- "source": [- "## Query vector store\n",- "\n",- "Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.\n",- "\n",- "### Query directly\n",- "\n",- "Performing a simple similarity search can be done as follows:\n",- "\n",- "- TODO: Edit and then run code cell to generate output"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "aa0a16fa",- "metadata": {},- "outputs": [],- "source": [- "results = vector_store.similarity_search(query=\"thud\",k=1,filter={\"source\":\"https://another-example.com\"})\n",- "for doc in results:\n",- " print(f\"* {doc.page_content} [{doc.metadata}]\")"- ]- },- {- "cell_type": "markdown",- "id": "3ed9d733",- "metadata": {},- "source": [- "If you want to execute a similarity search and receive the corresponding scores you can run:\n",- "\n",- "- TODO: Edit and then run code cell to generate output"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "5efd2eaa",- "metadata": {},- "outputs": [],- "source": [- "results = vector_store.similarity_search_with_score(query=\"thud\",k=1,filter={\"source\":\"https://example.com\"})\n",- "for doc, score in results:\n",- " print(f\"* [SIM={score:3f}] {doc.page_content} [{doc.metadata}]\")"- ]- },- {- "cell_type": "markdown",- "id": "0c235cdc",- "metadata": {},- "source": [- "### Query by turning into retriever\n",- "\n",- "You can also transform the vector store into a retriever for easier usage in your chains.\n",- "\n",- "- TODO: Edit and then run code cell to generate output"- ]- },- {- "cell_type": "code",- "execution_count": null,- "id": "f3460093",- "metadata": {},- "outputs": [],- "source": [- "retriever = vector_store.as_retriever(\n",- " search_type=\"mmr\",\n",- " search_kwargs={\"k\": 1}\n",- ")\n",- "retriever.invoke(\"thud\")"- ]- },- {- "cell_type": "markdown",- "id": "901c75dc",- "metadata": {},- "source": [- "## Usage for retrieval-augmented generation\n",- "\n",- "For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:\n",- "\n",- "- [Tutorials](/docs/tutorials/)\n",- "- [How-to: Question and answer with RAG](https://python.langchain.com/docs/how_to/#qa-with-rag)\n",- "- [Retrieval conceptual docs](https://python.langchain.com/docs/concepts/retrieval/)"- ]- },- {- "cell_type": "markdown",- "id": "069f1b5f",- "metadata": {},- "source": [- "## TODO: Any functionality specific to this vector store\n",- "\n",- "E.g. creating a persisten database to save to your disk, etc."- ]- },- {- "cell_type": "markdown",- "id": "8a27244f",- "metadata": {},- "source": [- "## API reference\n",- "\n",- "For detailed documentation of all __ModuleName__VectorStore features and configurations head to the API reference: https://api.python.langchain.com/en/latest/vectorstores/__module_name__.vectorstores.__ModuleName__VectorStore.html"- ]- }- ],- "metadata": {- "kernelspec": {- "display_name": "Python 3 (ipykernel)",- "language": "python",- "name": "python3"- },- "language_info": {- "codemirror_mode": {- "name": "ipython",- "version": 3- },- "file_extension": ".py",- "mimetype": "text/x-python",- "name": "python",- "nbconvert_exporter": "python",- "pygments_lexer": "ipython3",- "version": "3.10.12"+ "cells": [+ {+ "cell_type": "raw",+ "id": "1957f5cb",+ "metadata": {},+ "source": [+ "---\n",+ "sidebar_label: __ModuleName__\n",+ "---"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "ef1f0986",+ "metadata": {},+ "source": [+ "# __ModuleName__VectorStore\n",+ "\n",+ "This notebook covers how to get started with the __ModuleName__ vector store."+ ]+ },+ {+ "cell_type": "markdown",+ "id": "36fdc060",+ "metadata": {},+ "source": [+ "## Setup\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "- TODO: Update minimum version to be correct.\n",+ "\n",+ "To access __ModuleName__ vector stores you'll need to create a/an __ModuleName__ account, get an API key, and install the `__package_name__` integration package."+ ]+ },+ {+ "cell_type": "raw",+ "id": "64e28aa6",+ "metadata": {+ "vscode": {+ "languageId": "raw"}+ },+ "source": [+ "%pip install -qU \"__package_name__>=MINIMUM_VERSION\""+ ]+ },+ {+ "cell_type": "markdown",+ "id": "9695dee7",+ "metadata": {},+ "source": [+ "### Credentials\n",+ "\n",+ "- TODO: Update with relevant info.\n",+ "\n",+ "Head to (TODO: link) to sign up to __ModuleName__ and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "894c30e4",+ "metadata": {},+ "outputs": [],+ "source": [+ "import getpass\n",+ "import os\n",+ "\n",+ "if not os.getenv(\"__MODULE_NAME___API_KEY\"):\n",+ " os.environ[\"__MODULE_NAME___API_KEY\"] = getpass.getpass(\n",+ " \"Enter your __ModuleName__ API key: \"\n",+ " )"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "7f98392b",+ "metadata": {},+ "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:"+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "e7b6a6e0",+ "metadata": {},+ "outputs": [],+ "source": [+ "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")\n",+ "# os.environ[\"LANGSMITH_TRACING\"] = \"true\""+ ]+ },+ {+ "cell_type": "markdown",+ "id": "93df377e",+ "metadata": {},+ "source": [+ "## Initialization\n",+ "\n",+ "- TODO: Fill out with relevant init params\n",+ "\n",+ "\n",+ "```{=mdx}\n",+ "import EmbeddingTabs from \"@theme/EmbeddingTabs\";\n",+ "\n",+ "<EmbeddingTabs/>\n",+ "```"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "dc37144c-208d-4ab3-9f3a-0407a69fe052",+ "metadata": {+ "tags": []+ },+ "outputs": [],+ "source": [+ "from __module_name__.vectorstores import __ModuleName__VectorStore\n",+ "\n",+ "vector_store = __ModuleName__VectorStore(embeddings=embeddings)"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "ac6071d4",+ "metadata": {},+ "source": [+ "## Manage vector store\n",+ "\n",+ "### Add items to vector store\n",+ "\n",+ "- TODO: Edit and then run code cell to generate output"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "17f5efc0",+ "metadata": {},+ "outputs": [],+ "source": [+ "from langchain_core.documents import Document\n",+ "\n",+ "document_1 = Document(page_content=\"foo\", metadata={\"source\": \"https://example.com\"})\n",+ "\n",+ "document_2 = Document(page_content=\"bar\", metadata={\"source\": \"https://example.com\"})\n",+ "\n",+ "document_3 = Document(page_content=\"baz\", metadata={\"source\": \"https://example.com\"})\n",+ "\n",+ "documents = [document_1, document_2, document_3]\n",+ "\n",+ "vector_store.add_documents(documents=documents, ids=[\"1\", \"2\", \"3\"])"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "c738c3e0",+ "metadata": {},+ "source": [+ "### Update items in vector store\n",+ "\n",+ "- TODO: Edit and then run code cell to generate output"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "f0aa8b71",+ "metadata": {},+ "outputs": [],+ "source": [+ "updated_document = Document(\n",+ " page_content=\"qux\", metadata={\"source\": \"https://another-example.com\"}\n",+ ")\n",+ "\n",+ "vector_store.update_documents(document_id=\"1\", document=updated_document)"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "dcf1b905",+ "metadata": {},+ "source": [+ "### Delete items from vector store\n",+ "\n",+ "- TODO: Edit and then run code cell to generate output"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "ef61e188",+ "metadata": {},+ "outputs": [],+ "source": [+ "vector_store.delete(ids=[\"3\"])"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "c3620501",+ "metadata": {},+ "source": [+ "## Query vector store\n",+ "\n",+ "Once your vector store has been created and the relevant documents have been added you will most likely wish to query it during the running of your chain or agent.\n",+ "\n",+ "### Query directly\n",+ "\n",+ "Performing a simple similarity search can be done as follows:\n",+ "\n",+ "- TODO: Edit and then run code cell to generate output"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "aa0a16fa",+ "metadata": {},+ "outputs": [],+ "source": [+ "results = vector_store.similarity_search(\n",+ " query=\"thud\", k=1, filter={\"source\": \"https://another-example.com\"}\n",+ ")\n",+ "for doc in results:\n",+ " print(f\"* {doc.page_content} [{doc.metadata}]\")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "3ed9d733",+ "metadata": {},+ "source": [+ "If you want to execute a similarity search and receive the corresponding scores you can run:\n",+ "\n",+ "- TODO: Edit and then run code cell to generate output"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "5efd2eaa",+ "metadata": {},+ "outputs": [],+ "source": [+ "results = vector_store.similarity_search_with_score(\n",+ " query=\"thud\", k=1, filter={\"source\": \"https://example.com\"}\n",+ ")\n",+ "for doc, score in results:\n",+ " print(f\"* [SIM={score:3f}] {doc.page_content} [{doc.metadata}]\")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "0c235cdc",+ "metadata": {},+ "source": [+ "### Query by turning into retriever\n",+ "\n",+ "You can also transform the vector store into a retriever for easier usage in your chains.\n",+ "\n",+ "- TODO: Edit and then run code cell to generate output"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "id": "f3460093",+ "metadata": {},+ "outputs": [],+ "source": [+ "retriever = vector_store.as_retriever(search_type=\"mmr\", search_kwargs={\"k\": 1})\n",+ "retriever.invoke(\"thud\")"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "901c75dc",+ "metadata": {},+ "source": [+ "## Usage for retrieval-augmented generation\n",+ "\n",+ "For guides on how to use this vector store for retrieval-augmented generation (RAG), see the following sections:\n",+ "\n",+ "- [Tutorials](/docs/tutorials/)\n",+ "- [How-to: Question and answer with RAG](https://python.langchain.com/docs/how_to/#qa-with-rag)\n",+ "- [Retrieval conceptual docs](https://python.langchain.com/docs/concepts/retrieval/)"+ ]+ },+ {+ "cell_type": "markdown",+ "id": "069f1b5f",+ "metadata": {},+ "source": [+ "## TODO: Any functionality specific to this vector store\n",+ "\n",+ "E.g. creating a persisten database to save to your disk, etc."+ ]+ },+ {+ "cell_type": "markdown",+ "id": "8a27244f",+ "metadata": {},+ "source": [+ "## API reference\n",+ "\n",+ "For detailed documentation of all __ModuleName__VectorStore features and configurations head to the API reference: https://api.python.langchain.com/en/latest/vectorstores/__module_name__.vectorstores.__ModuleName__VectorStore.html"+ ]+ }+ ],+ "metadata": {+ "kernelspec": {+ "display_name": "Python 3 (ipykernel)",+ "language": "python",+ "name": "python3"},- "nbformat": 4,- "nbformat_minor": 5+ "language_info": {+ "codemirror_mode": {+ "name": "ipython",+ "version": 3+ },+ "file_extension": ".py",+ "mimetype": "text/x-python",+ "name": "python",+ "nbconvert_exporter": "python",+ "pygments_lexer": "ipython3",+ "version": "3.10.12"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 5}diff --git a/libs/cli/langchain_cli/integration_template/integration_template/chat_models.py b/libs/cli/langchain_cli/integration_template/integration_template/chat_models.pyindex 9703b50358..4d9fc586c7 100644--- a/libs/cli/langchain_cli/integration_template/integration_template/chat_models.py+++ b/libs/cli/langchain_cli/integration_template/integration_template/chat_models.py@@ -21,11 +21,13 @@ class Chat__ModuleName__(BaseChatModel):# https://github.com/langchain-ai/langchain/blob/7ff05357bac6eaedf5058a2af88f23a1817d40fe/libs/partners/openai/langchain_openai/chat_models/base.py#L1120"""__ModuleName__ chat model integration.- The default implementation echoes the first `parrot_buffer_length` characters of the input.+ The default implementation echoes the first `parrot_buffer_length` characters of+ the input.# TODO: Replace with relevant packages, env vars.Setup:- Install ``__package_name__`` and set environment variable ``__MODULE_NAME___API_KEY``.+ Install ``__package_name__`` and set environment variable+ ``__MODULE_NAME___API_KEY``... code-block:: bash@@ -48,7 +50,8 @@ class Chat__ModuleName__(BaseChatModel):max_retries: intMax number of retries.api_key: Optional[str]- __ModuleName__ API key. If not passed in will be read from env var __MODULE_NAME___API_KEY.+ __ModuleName__ API key. If not passed in will be read from env var+ __MODULE_NAME___API_KEY.See full list of supported init args and their descriptions in the params section.diff --git a/libs/cli/langchain_cli/integration_template/integration_template/document_loaders.py b/libs/cli/langchain_cli/integration_template/integration_template/document_loaders.pyindex cb4c1aa78f..5266ca1e2e 100644--- a/libs/cli/langchain_cli/integration_template/integration_template/document_loaders.py+++ b/libs/cli/langchain_cli/integration_template/integration_template/document_loaders.py@@ -14,7 +14,8 @@ class __ModuleName__Loader(BaseLoader):# TODO: Replace with relevant packages, env vars.Setup:- Install ``__package_name__`` and set environment variable ``__MODULE_NAME___API_KEY``.+ Install ``__package_name__`` and set environment variable+ ``__MODULE_NAME___API_KEY``... code-block:: bash@@ -62,7 +63,7 @@ class __ModuleName__Loader(BaseLoader):TODO: Example output- """ # noqa: E501+ """# TODO: This method must be implemented to load documents.# Do not implement load(), a default implementation is already available.diff --git a/libs/cli/langchain_cli/integration_template/integration_template/toolkits.py b/libs/cli/langchain_cli/integration_template/integration_template/toolkits.pyindex b3eda23bd2..7c0632bb0a 100644--- a/libs/cli/langchain_cli/integration_template/integration_template/toolkits.py+++ b/libs/cli/langchain_cli/integration_template/integration_template/toolkits.py@@ -12,7 +12,8 @@ class __ModuleName__Toolkit(BaseToolkit):# TODO: Replace with relevant packages, env vars, etc.Setup:- Install ``__package_name__`` and set environment variable ``__MODULE_NAME___API_KEY``.+ Install ``__package_name__`` and set environment variable+ ``__MODULE_NAME___API_KEY``... code-block:: bash@@ -65,7 +66,7 @@ class __ModuleName__Toolkit(BaseToolkit):# TODO: Example output.- """ # noqa: E501+ """# TODO: This method must be implemented to list tools.def get_tools(self) -> List[BaseTool]:diff --git a/libs/cli/langchain_cli/integration_template/integration_template/tools.py b/libs/cli/langchain_cli/integration_template/integration_template/tools.pyindex 156f9c719c..1504723671 100644--- a/libs/cli/langchain_cli/integration_template/integration_template/tools.py+++ b/libs/cli/langchain_cli/integration_template/integration_template/tools.py@@ -27,7 +27,8 @@ class __ModuleName__Tool(BaseTool): # type: ignore[override]Setup:# TODO: Replace with relevant packages, env vars.- Install ``__package_name__`` and set environment variable ``__MODULE_NAME___API_KEY``.+ Install ``__package_name__`` and set environment variable+ ``__MODULE_NAME___API_KEY``... code-block:: bashdiff --git a/libs/cli/langchain_cli/integration_template/pyproject.toml b/libs/cli/langchain_cli/integration_template/pyproject.tomlindex fa3c596b06..d94989dc00 100644--- a/libs/cli/langchain_cli/integration_template/pyproject.toml+++ b/libs/cli/langchain_cli/integration_template/pyproject.toml@@ -25,6 +25,9 @@ langchain-core = "^0.3.15"[tool.ruff.lint]select = ["E", "F", "I", "T201"]+[tool.ruff.lint.per-file-ignores]+"docs/**" = [ "ALL",]+[tool.coverage.run]omit = ["tests/*"]diff --git a/libs/cli/langchain_cli/package_template/package_template/__init__.py b/libs/cli/langchain_cli/package_template/package_template/__init__.pyindex ee137d673a..21d83701aa 100644--- a/libs/cli/langchain_cli/package_template/package_template/__init__.py+++ b/libs/cli/langchain_cli/package_template/package_template/__init__.py@@ -1,3 +1,5 @@+"""__module_name__ module."""+from __module_name__.chain import chain__all__ = ["chain"]diff --git a/libs/cli/langchain_cli/package_template/package_template/chain.py b/libs/cli/langchain_cli/package_template/package_template/chain.pyindex f5a8ebc690..a7e28a8ac0 100644--- a/libs/cli/langchain_cli/package_template/package_template/chain.py+++ b/libs/cli/langchain_cli/package_template/package_template/chain.py@@ -1,3 +1,5 @@+"""Chain definition."""+from langchain_core.prompts import ChatPromptTemplatefrom langchain_openai import ChatOpenAIdiff --git a/libs/cli/langchain_cli/package_template/tests/__init__.py b/libs/cli/langchain_cli/package_template/tests/__init__.pyindex e69de29bb2..d420712d8b 100644--- a/libs/cli/langchain_cli/package_template/tests/__init__.py+++ b/libs/cli/langchain_cli/package_template/tests/__init__.py@@ -0,0 +1 @@+"""Tests."""diff --git a/libs/cli/langchain_cli/project_template/app/__init__.py b/libs/cli/langchain_cli/project_template/app/__init__.pyindex e69de29bb2..432c8b7f1e 100644--- a/libs/cli/langchain_cli/project_template/app/__init__.py+++ b/libs/cli/langchain_cli/project_template/app/__init__.py@@ -0,0 +1 @@+"""Server application."""diff --git a/libs/cli/langchain_cli/project_template/app/server.py b/libs/cli/langchain_cli/project_template/app/server.pyindex 91db31ba0e..a8133c9e3d 100644--- a/libs/cli/langchain_cli/project_template/app/server.py+++ b/libs/cli/langchain_cli/project_template/app/server.py@@ -1,3 +1,5 @@+"""Chain server."""+from fastapi import FastAPIfrom fastapi.responses import RedirectResponsefrom langserve import add_routes@@ -6,7 +8,7 @@ app = FastAPI()@app.get("/")-async def redirect_root_to_docs() -> RedirectResponse:+async def _redirect_root_to_docs() -> RedirectResponse:return RedirectResponse("/docs")@@ -16,4 +18,4 @@ add_routes(app, NotImplemented)if __name__ == "__main__":import uvicorn- uvicorn.run(app, host="0.0.0.0", port=8000)+ uvicorn.run(app, host="0.0.0.0", port=8000) # noqa: S104diff --git a/libs/cli/pyproject.toml b/libs/cli/pyproject.tomlindex cf333f246e..473cd6ae32 100644--- a/libs/cli/pyproject.toml+++ b/libs/cli/pyproject.toml@@ -41,11 +41,9 @@ langchain = { path = "../langchain", editable = true }[tool.ruff]target-version = "py39"-exclude = [- "langchain_cli/integration_template",- "langchain_cli/package_template",- "langchain_cli/project_template",-]++[tool.ruff.format]+docstring-code-format = true[tool.ruff.lint]select = [ "ALL",]diff --git a/libs/cli/uv.lock b/libs/cli/uv.lockindex efe67b1401..f80ac35535 100644--- a/libs/cli/uv.lock+++ b/libs/cli/uv.lock@@ -667,9 +667,10 @@ test-integration = [{ name = "transformers", specifier = ">=4.51.3,<5.0.0" },]typing = [+ { name = "beautifulsoup4", specifier = ">=4.13.5,<5.0.0" },{ name = "lxml-stubs", specifier = ">=0.5.1,<1.0.0" },{ name = "mypy", specifier = ">=1.17.1,<1.18" },- { name = "tiktoken", specifier = ">=0.8.0,<1.0.0" },+ { name = "tiktoken", specifier = ">=0.11.0,<1.0.0" },{ name = "types-requests", specifier = ">=2.31.0.20240218,<3.0.0.0" },]