From 9ebd412f14723e7de3a408290d48953fcae400e3 Mon Sep 17 00:00:00 2001 From: markshao <37647536@qq.com> Date: Sat, 1 Nov 2025 15:30:08 +0800 Subject: [PATCH 01/14] bufix: add bind_tools impl for MoonshotChat --- .../chat_models/moonshot.py | 35 ++++++++++++++++--- .../unit_tests/chat_models/test_moonshot.py | 13 +++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 libs/community/tests/unit_tests/chat_models/test_moonshot.py diff --git a/libs/community/langchain_community/chat_models/moonshot.py b/libs/community/langchain_community/chat_models/moonshot.py index 6d31426fd..48ffd4949 100644 --- a/libs/community/langchain_community/chat_models/moonshot.py +++ b/libs/community/langchain_community/chat_models/moonshot.py @@ -1,12 +1,18 @@ """Wrapper around Moonshot chat models.""" -from typing import Dict +from typing import Any, Callable, Dict, Sequence, Type, Union +from langchain_core.language_models import LanguageModelInput +from langchain_core.messages import AIMessage +from langchain_core.runnables import Runnable +from langchain_core.tools import BaseTool from langchain_core.utils import ( convert_to_secret_str, get_from_dict_or_env, pre_init, ) +from langchain_core.utils.function_calling import convert_to_openai_tool +from pydantic import BaseModel from langchain_community.chat_models import ChatOpenAI from langchain_community.llms.moonshot import MOONSHOT_SERVICE_URL_BASE, MoonshotCommon @@ -172,9 +178,11 @@ def validate_environment(cls, values: Dict) -> Dict: client_params = { "api_key": values["moonshot_api_key"].get_secret_value(), - "base_url": values["base_url"] - if "base_url" in values - else MOONSHOT_SERVICE_URL_BASE, + "base_url": ( + values["base_url"] + if "base_url" in values + else MOONSHOT_SERVICE_URL_BASE + ), } if not values.get("client"): @@ -185,3 +193,22 @@ def validate_environment(cls, values: Dict) -> Dict: ).chat.completions return values + + def bind_tools( + self, + tools: Sequence[Union[Dict[str, Any], Type[BaseModel], Callable, BaseTool]], + **kwargs: Any, + ) -> Runnable[LanguageModelInput, AIMessage]: + """Bind tool-like objects to this chat model. + + Args: + tools: A list of tool definitions to bind to this chat model. + Can be a dictionary, pydantic model, callable, or BaseTool. Pydantic + models, callables, and BaseTools will be automatically converted to + their schema dictionary representation. + **kwargs: Any additional parameters to pass to the + :class:`~langchain.runnable.Runnable` constructor. + """ + + formatted_tools = [convert_to_openai_tool(tool) for tool in tools] + return super().bind(tools=formatted_tools, **kwargs) diff --git a/libs/community/tests/unit_tests/chat_models/test_moonshot.py b/libs/community/tests/unit_tests/chat_models/test_moonshot.py new file mode 100644 index 000000000..531d8c179 --- /dev/null +++ b/libs/community/tests/unit_tests/chat_models/test_moonshot.py @@ -0,0 +1,13 @@ +import pytest +from langchain_core.runnables import Runnable + +from langchain_community.chat_models.moonshot import MoonshotChat + +mock_tool_list = [lambda: f"tool-id-{i}" for i in range(3)] + + +@pytest.mark.requires("openai") +def test_moonshot_bind_tools() -> None: + llm = MoonshotChat(name="moonshot") + ret: Runnable = llm.bind_tools(mock_tool_list) + assert len(ret.kwargs["tools"]) == 3 From b95b011345e00419966a1c5d1043a1a0b4a93f75 Mon Sep 17 00:00:00 2001 From: tbice <1206345694@qq.com> Date: Thu, 6 Nov 2025 00:26:23 +0800 Subject: [PATCH 02/14] fix(chat_models): parallel tool calls in ChatTongyi when incremental streaming output is enabled. (#111) In the latest Alibaba Cloud Qwen models, such as Qwen-Plus-latest and Qwen3-235B-A22B, these models must use incremental_output for streaming output in reasoning mode. However, there will be issues when using parallel_tool_calls at the same time. The sample code is as follows: ```python import asyncio from langchain_community.chat_models import ChatTongyi from langchain_core.tools import tool @tool def get_weather(city: str): """Get the weather of a city""" return f"{city} is sunny" model = ChatTongyi( model="qwen-plus-latest", streaming=True, model_kwargs={"incremental_output": True, "enable_thinking": True}, ) # pyright:ignore model = model.bind_tools([get_weather]) print( model.invoke( "Check the weather in San Francisco and New York", parallel_tool_calls=True ) ) ``` ![image](https://github.com/user-attachments/assets/8ed24300-aa37-43c7-b781-fa96b8005a38) The following output will be generated, showing that there is a problem with tool_calls. ```base tool_calls=[{'name': 'get_weatherget_weather', 'args': {'city': 'San Francisco'}, 'id': 'call_4835d51c1d444b0886ade5call_5a2c75ffc0ca4beb9a9eef', 'type': 'tool_call'}] ``` It should originally contain two tools' JSON schemas, but there is only one, and even that one is problematic. The specific reason is that the same field in the two JSON schemas has been merged. This is clearly an issue. The reason is that this source code uses the array's subscript as the index, but in the case of incremental streaming output, this index is almost always 0. That is, this code does not adapt well to incremental streaming output. However, the documentation of BaiLian Qwen already states that it will return the corresponding index, https://help.aliyun.com/zh/model-studio/deep-thinking ![image](https://github.com/user-attachments/assets/172432c8-ef13-450d-a6fb-68e16c7b6dae) Therefore, the following modifications were made, resulting in this PR. ```python tool_calls.append( { "name": value["function"].get("name"), "args": value["function"].get("arguments"), "id": value.get("id"), # Tongyi does not respond with index, # use index in the list instead "index": value.get("index", index), } ) ``` After correction, it was found to be successfully parsed. ![image](https://github.com/user-attachments/assets/c35af748-7396-42f4-bb05-f601464ee2f0) --------- Co-authored-by: Mason Daugherty Co-authored-by: Mason Daugherty --- .../langchain_community/chat_models/tongyi.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libs/community/langchain_community/chat_models/tongyi.py b/libs/community/langchain_community/chat_models/tongyi.py index 402c5d03c..69354d298 100644 --- a/libs/community/langchain_community/chat_models/tongyi.py +++ b/libs/community/langchain_community/chat_models/tongyi.py @@ -100,28 +100,33 @@ def convert_dict_to_message( if "tool_calls" in _dict: additional_kwargs = {"tool_calls": _dict["tool_calls"]} - for index, value in enumerate(_dict["tool_calls"]): + for enum_index, tool_call_data in enumerate(_dict["tool_calls"]): if is_chunk: try: + # For incremental streaming: newer Qwen models provide proper + # index to prevent parallel tool calls from being merged + # incorrectly. Fall back to enumeration index if not provided. + api_index = tool_call_data.get("index", enum_index) + tool_calls.append( { - "name": value["function"].get("name"), - "args": value["function"].get("arguments"), - "id": value.get("id"), - # Tongyi does not respond with index, - # use index in the list instead - "index": index, + "name": tool_call_data["function"].get("name"), + "args": tool_call_data["function"].get("arguments"), + "id": tool_call_data.get("id"), + "index": api_index, } ) except KeyError: pass else: try: - parsed_tool = parse_tool_call(value, return_id=True) + parsed_tool = parse_tool_call(tool_call_data, return_id=True) if parsed_tool: tool_calls.append(parsed_tool) except Exception as e: - invalid_tool_calls.append(make_invalid_tool_call(value, str(e))) + invalid_tool_calls.append( + make_invalid_tool_call(tool_call_data, str(e)) + ) elif "reasoning_content" in _dict: additional_kwargs = {"reasoning_content": _dict["reasoning_content"]} elif "partial" in _dict and isinstance(_dict["partial"], bool): From 0fa7c634aa5e9bc5085853e0a8dbfd4cdb8e4f80 Mon Sep 17 00:00:00 2001 From: Nicolas Noirbent Date: Wed, 5 Nov 2025 17:30:26 +0100 Subject: [PATCH 03/14] fix(infra): remove unused `dataclasses-json` dependency (#270) Co-authored-by: Mason Daugherty --- libs/community/pyproject.toml | 2 +- .../tests/unit_tests/test_dependencies.py | 2 +- libs/community/uv.lock | 42 +------------------ 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/libs/community/pyproject.toml b/libs/community/pyproject.toml index 32a936c2c..3931459bf 100644 --- a/libs/community/pyproject.toml +++ b/libs/community/pyproject.toml @@ -14,7 +14,6 @@ dependencies = [ "PyYAML>=5.3.0,<7.0.0", "aiohttp>=3.8.3,<4.0.0", "tenacity!=8.4.0,>=8.1.0,<10.0.0", - "dataclasses-json>=0.6.7,<0.7.0", "pydantic-settings>=2.10.1,<3.0.0", "langsmith>=0.1.125,<1.0.0", "httpx-sse>=0.4.0,<1.0.0", @@ -56,6 +55,7 @@ test = [ "cffi; python_version >= \"3.10\"", "langchain-tests>=1.0.0,<2.0.0", "toml>=0.10.2,<1.0.0", + "mypy-extensions>=1.0.0", ] test_integration = ["vcrpy>=6.0.0"] lint = [ diff --git a/libs/community/tests/unit_tests/test_dependencies.py b/libs/community/tests/unit_tests/test_dependencies.py index 03607c214..1ce576f81 100644 --- a/libs/community/tests/unit_tests/test_dependencies.py +++ b/libs/community/tests/unit_tests/test_dependencies.py @@ -34,7 +34,6 @@ def test_required_dependencies(uv_conf: Mapping[str, Any]) -> None: "PyYAML", "SQLAlchemy", "aiohttp", - "dataclasses-json", "httpx-sse", "langchain-core", "langsmith", @@ -65,6 +64,7 @@ def test_test_group_dependencies(uv_conf: Mapping[str, Any]) -> None: "freezegun", "langchain-tests", "lark", + "mypy-extensions", "pandas", "pytest", "pytest-asyncio", diff --git a/libs/community/uv.lock b/libs/community/uv.lock index 7d52d6056..90ea02b91 100644 --- a/libs/community/uv.lock +++ b/libs/community/uv.lock @@ -707,19 +707,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/0d/c3/e90f4a4feae6410f914f8ebac129b9ae7a8c92eb60a638012dde42030a9d/cryptography-46.0.3-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:6b5063083824e5509fdba180721d55909ffacccc8adbec85268b48439423d78c", size = 3438528, upload-time = "2025-10-15T23:18:26.227Z" }, ] -[[package]] -name = "dataclasses-json" -version = "0.6.7" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "marshmallow" }, - { name = "typing-inspect" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/64/a4/f71d9cf3a5ac257c993b5ca3f93df5f7fb395c725e7f1e6479d2514173c3/dataclasses_json-0.6.7.tar.gz", hash = "sha256:b6b3e528266ea45b9535223bc53ca645f5208833c29229e847b3f26a1cc55fc0", size = 32227, upload-time = "2024-06-09T16:20:19.103Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/c3/be/d0d44e092656fe7a06b55e6103cbce807cdbdee17884a5367c68c9860853/dataclasses_json-0.6.7-py3-none-any.whl", hash = "sha256:0dbf33f26c8d5305befd61b39d2b3414e8a407bedc2834dea9b8d642666fb40a", size = 28686, upload-time = "2024-06-09T16:20:16.715Z" }, -] - [[package]] name = "debugpy" version = "1.8.17" @@ -1576,7 +1563,6 @@ version = "0.4.1" source = { editable = "." } dependencies = [ { name = "aiohttp" }, - { name = "dataclasses-json" }, { name = "httpx-sse" }, { name = "langchain-classic" }, { name = "langchain-core" }, @@ -1607,6 +1593,7 @@ test = [ { name = "freezegun" }, { name = "langchain-tests" }, { name = "lark" }, + { name = "mypy-extensions" }, { name = "pandas" }, { name = "pytest" }, { name = "pytest-asyncio" }, @@ -1641,7 +1628,6 @@ typing = [ [package.metadata] requires-dist = [ { name = "aiohttp", specifier = ">=3.8.3,<4.0.0" }, - { name = "dataclasses-json", specifier = ">=0.6.7,<0.7.0" }, { name = "httpx-sse", specifier = ">=0.4.0,<1.0.0" }, { name = "langchain-classic", specifier = ">=1.0.0,<2.0.0" }, { name = "langchain-core", specifier = ">=1.0.1,<2.0.0" }, @@ -1674,6 +1660,7 @@ test = [ { name = "freezegun", specifier = ">=1.2.2,<2.0.0" }, { name = "langchain-tests", specifier = ">=1.0.0,<2.0.0" }, { name = "lark", specifier = ">=1.1.5,<2.0.0" }, + { name = "mypy-extensions", specifier = ">=1" }, { name = "pandas", specifier = ">=2.0.0,<3.0.0" }, { name = "pytest", specifier = ">=8.4.1,<9.0.0" }, { name = "pytest-asyncio", specifier = ">=0.20.3,<1.0.0" }, @@ -1880,18 +1867,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/70/bc/6f1c2f612465f5fa89b95bead1f44dcb607670fd42891d8fdcd5d039f4f4/markupsafe-3.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa", size = 14146, upload-time = "2025-09-27T18:37:28.327Z" }, ] -[[package]] -name = "marshmallow" -version = "3.26.1" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "packaging" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/ab/5e/5e53d26b42ab75491cda89b871dab9e97c840bf12c63ec58a1919710cd06/marshmallow-3.26.1.tar.gz", hash = "sha256:e6d8affb6cb61d39d26402096dc0aee12d5a26d490a121f118d2e81dc0719dc6", size = 221825, upload-time = "2025-02-03T15:32:25.093Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/34/75/51952c7b2d3873b44a0028b1bd26a25078c18f92f256608e8d1dc61b39fd/marshmallow-3.26.1-py3-none-any.whl", hash = "sha256:3350409f20a70a7e4e11a27661187b77cdcaeb20abca41c1454fe33636bea09c", size = 50878, upload-time = "2025-02-03T15:32:22.295Z" }, -] - [[package]] name = "matplotlib-inline" version = "0.1.7" @@ -3935,19 +3910,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, ] -[[package]] -name = "typing-inspect" -version = "0.9.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "mypy-extensions" }, - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/dc/74/1789779d91f1961fa9438e9a8710cdae6bd138c80d7303996933d117264a/typing_inspect-0.9.0.tar.gz", hash = "sha256:b23fc42ff6f6ef6954e4852c1fb512cdd18dbea03134f91f856a95ccc9461f78", size = 13825, upload-time = "2023-05-24T20:25:47.612Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/65/f3/107a22063bf27bdccf2024833d3445f4eea42b2e598abfbd46f6a63b6cb0/typing_inspect-0.9.0-py3-none-any.whl", hash = "sha256:9ee6fc59062311ef8547596ab6b955e1b8aa46242d854bfc78f4f6b0eff35f9f", size = 8827, upload-time = "2023-05-24T20:25:45.287Z" }, -] - [[package]] name = "typing-inspection" version = "0.4.2" From 888a38b625510d44b4672c6fc2dd82e075d0fb8f Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Wed, 5 Nov 2025 13:20:14 -0500 Subject: [PATCH 04/14] chore: update `README.md` (#408) --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 82e1ae07d..008a8ebf0 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,10 @@ This repository contains community-maintained LangChain integrations in the [`langchain-community`](https://pypi.org/project/langchain-community/) package. -**Documentation**: To learn more about LangChain, check out [the docs](https://docs.langchain.com/oss/python/langchain/overview). +**Documentation**: + +- [docs.langchain.com](https://docs.langchain.com/oss/python/langchain/overview) – Comprehensive documentation, including conceptual overviews and guides +- [reference.langchain.com/python](https://reference.langchain.com/python/langchain_community/) – API reference docs for community integrations **Discussions**: Visit the [LangChain Forum](https://forum.langchain.com) to connect with the community and share all of your technical questions, ideas, and feedback. @@ -24,6 +27,5 @@ This repository contains community-maintained LangChain integrations in the [`la ## Additional resources -- [API Reference](https://reference.langchain.com/python): Detailed reference on navigating base packages and integrations for LangChain. -- [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview): Learn how to contribute to LangChain and find good first issues. +- [Contributing Guide](https://docs.langchain.com/oss/python/contributing/overview): Learn how to contribute to LangChain projects and find good first issues. - [Code of Conduct](https://github.com/langchain-ai/langchain-community/blob/master/.github/CODE_OF_CONDUCT.md): Our community guidelines and standards for participation. From 1107250492def3de5171268cd90bbd5550ed296c Mon Sep 17 00:00:00 2001 From: Miklos Erdelyi Date: Wed, 5 Nov 2025 20:32:49 +0100 Subject: [PATCH 05/14] feat(agent_toolkits): Make `WebClient` injectable for Slack toolkit (#145) This PR enables injecting a [`WebClient`](https://tools.slack.dev/python-slack-sdk/api-docs/slack_sdk/web/client.html) instance into all tools within the Slack toolkit. This simplifies usage for agents that need to work with [user tokens](https://api.slack.com/concepts/token-types#user). --------- Co-authored-by: Mason Daugherty --- .../agent_toolkits/slack/toolkit.py | 14 +++-- .../agent_toolkits/test_slack_toolkit.py | 62 +++++++++++++++++++ 2 files changed, 72 insertions(+), 4 deletions(-) create mode 100644 libs/community/tests/unit_tests/agent_toolkits/test_slack_toolkit.py diff --git a/libs/community/langchain_community/agent_toolkits/slack/toolkit.py b/libs/community/langchain_community/agent_toolkits/slack/toolkit.py index a8ca7f564..01a996f3a 100644 --- a/libs/community/langchain_community/agent_toolkits/slack/toolkit.py +++ b/libs/community/langchain_community/agent_toolkits/slack/toolkit.py @@ -46,8 +46,14 @@ class SlackToolkit(BaseToolkit): from langchain_community.agent_toolkits import SlackToolkit + # Using environment variables (default) toolkit = SlackToolkit() + # Or with an existing WebClient instance + from slack_sdk import WebClient + client = WebClient(token="your-user-token") + toolkit = SlackToolkit(client=client) + Tools: .. code-block:: python @@ -105,8 +111,8 @@ class SlackToolkit(BaseToolkit): def get_tools(self) -> List[BaseTool]: """Get the tools in the toolkit.""" return [ - SlackGetChannel(), - SlackGetMessage(), - SlackScheduleMessage(), - SlackSendMessage(), + SlackGetChannel(client=self.client), + SlackGetMessage(client=self.client), + SlackScheduleMessage(client=self.client), + SlackSendMessage(client=self.client), ] diff --git a/libs/community/tests/unit_tests/agent_toolkits/test_slack_toolkit.py b/libs/community/tests/unit_tests/agent_toolkits/test_slack_toolkit.py new file mode 100644 index 000000000..07a9ff4f4 --- /dev/null +++ b/libs/community/tests/unit_tests/agent_toolkits/test_slack_toolkit.py @@ -0,0 +1,62 @@ +import sys +from unittest.mock import MagicMock + +import pytest + +# Mock slack_sdk module and WebClient class. +mock_slack_sdk = MagicMock() +mock_webclient_class = MagicMock() +mock_slack_sdk.WebClient = mock_webclient_class +sys.modules["slack_sdk"] = mock_slack_sdk + +# We need to import the toolkit after patching sys.modules. +# ruff: noqa: E402 +from langchain_community.agent_toolkits.slack.toolkit import SlackToolkit +from langchain_community.tools.slack.base import SlackBaseTool + + +@pytest.fixture +def mock_webclient() -> MagicMock: + mock_client = MagicMock() + mock_client.api_test.return_value = {"ok": True} + return mock_client + + +def test_slack_toolkit_default_instantiation() -> None: + """Test SlackToolkit can be instantiated with default settings.""" + toolkit = SlackToolkit() + assert toolkit is not None + + tools = toolkit.get_tools() + + assert len(tools) == 4 + for tool in tools: + assert isinstance(tool, SlackBaseTool) + assert tool.client == toolkit.client + + +def test_slack_toolkit_get_tools_provided_client(mock_webclient: MagicMock) -> None: + """Test that get_tools() creates tools with the provided client.""" + toolkit = SlackToolkit(client=mock_webclient) + + tools = toolkit.get_tools() + + assert len(tools) == 4 + for tool in tools: + assert isinstance(tool, SlackBaseTool) + assert tool.client == mock_webclient + + +def test_slack_toolkit_provided_client_reuse(mock_webclient: MagicMock) -> None: + """Test that provided client instance is reused across multiple get_tools() + calls.""" + toolkit = SlackToolkit(client=mock_webclient) + tools1 = toolkit.get_tools() + tools2 = toolkit.get_tools() + + for i in range(len(tools1)): + tool1 = tools1[i] + tool2 = tools2[i] + assert isinstance(tool1, SlackBaseTool) + assert isinstance(tool2, SlackBaseTool) + assert tool1.client == tool2.client == mock_webclient From d3864680113c02f10a8e156cbabe19228205c99e Mon Sep 17 00:00:00 2001 From: Parth Pathak Date: Thu, 6 Nov 2025 01:04:13 +0530 Subject: [PATCH 06/14] feat(document_loaders): add flexible timeout to `PlaywrightURLLoader` (#104) ## Description This PR enhances the `PlaywrightURLLoader` by adding configurable timeout and page load strategy options, making it more flexible for handling dynamic web pages. This addresses issue #103. ### Changes - Added `timeout` parameter (default: 30000ms) to control page navigation timeout - Added `wait_until` parameter to control when navigation is considered complete - Supported `wait_until` options: - `"load"` (default): wait for the "load" event - `"domcontentloaded"`: wait for the "DOMContentLoaded" event - `"networkidle"`: wait until there are no network connections for at least 500ms - `"commit"`: wait for the first network request to be sent ### Why The current implementation has a hardcoded 30-second timeout, which can be insufficient for heavy dynamic pages. This change allows users to: - Set longer timeouts for complex pages - Choose appropriate page load strategies based on their needs - Better handle dynamic content loading ### Real-World Examples This PR solves timeout issues with various types of websites: 1. Weather websites: ```python loader = PlaywrightURLLoader( urls=["https://weather.com/en-IN/weather/tenday/l/Chennai+Tamil+Nadu?canonicalCityId=251b7b4afedf19f747b425e048038eb1"], timeout=60000, # 60 second timeout wait_until="domcontentloaded" ) ``` 2. Dynamic news sites: ```python loader = PlaywrightURLLoader( urls=["https://www.reuters.com/markets/"], timeout=45000, wait_until="networkidle" ) ``` 3. E-commerce sites: ```python loader = PlaywrightURLLoader( urls=["https://www.amazon.com/dp/B08N5KWB9H"], timeout=90000, # 90 second timeout for complex product pages wait_until="load" ) ``` ### Testing - Added new test cases for both sync and async methods - Maintained backward compatibility - All existing tests pass - Tested with various real-world websites ### Related Issues Closes #103 --------- Co-authored-by: Parth Pathak Co-authored-by: Mason Daugherty Co-authored-by: Mason Daugherty --- .../document_loaders/url_playwright.py | 35 ++++++++++++++++--- .../document_loaders/test_url_playwright.py | 28 +++++++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/libs/community/langchain_community/document_loaders/url_playwright.py b/libs/community/langchain_community/document_loaders/url_playwright.py index 9a5aa87ae..778f8f8c7 100644 --- a/libs/community/langchain_community/document_loaders/url_playwright.py +++ b/libs/community/langchain_community/document_loaders/url_playwright.py @@ -116,6 +116,16 @@ class PlaywrightURLLoader(BaseLoader): through the specified proxy. browser_session (Optional[Union[str, os.PathLike[str]]]): Path to a file with browser session data that can be used to restore the browser session. + timeout (Optional[int]): Timeout in milliseconds for page navigation. + wait_until (Optional[str]): When to consider navigation succeeded. + + Can be one of: + + - "load": wait for the "load" event to fire + - "domcontentloaded": wait for the "DOMContentLoaded" event to fire + - "networkidle": wait until there are no network connections for at least + 500ms + - "commit": wait for the first network request to be sent Example: .. code-block:: python @@ -128,7 +138,12 @@ class PlaywrightURLLoader(BaseLoader): "username": "username", "password": "password" } - loader = PlaywrightURLLoader(urls, proxy=proxy) + loader = PlaywrightURLLoader( + urls=urls, + proxy=proxy, + timeout=60000, # 60 second timeout + wait_until="domcontentloaded" # Wait for DOM content to load + ) data = loader.load() """ @@ -141,6 +156,8 @@ def __init__( evaluator: Optional[PlaywrightEvaluator] = None, proxy: Optional[Dict[str, str]] = None, browser_session: Optional[Union[str, os.PathLike[str]]] = None, + timeout: Optional[int] = 30000, + wait_until: Optional[str] = "load", ): """Load a list of URLs using Playwright.""" try: @@ -156,6 +173,8 @@ def __init__( self.headless = headless self.proxy = proxy self.browser_session = browser_session + self.timeout = timeout + self.wait_until = wait_until if remove_selectors and evaluator: raise ValueError( @@ -189,11 +208,13 @@ def lazy_load(self) -> Iterator[Document]: for url in self.urls: try: page = context.new_page() - response = page.goto(url) + response = page.goto( + url, timeout=self.timeout, wait_until=self.wait_until + ) if response is None: raise ValueError(f"page.goto() returned None for url {url}") - page.wait_for_load_state("load") + page.wait_for_load_state(self.wait_until, timeout=self.timeout) text = self.evaluator.evaluate(page, browser, response) page.close() @@ -244,11 +265,15 @@ async def alazy_load(self) -> AsyncIterator[Document]: for url in self.urls: try: page = await context.new_page() - response = await page.goto(url) + response = await page.goto( + url, timeout=self.timeout, wait_until=self.wait_until + ) if response is None: raise ValueError(f"page.goto() returned None for url {url}") - await page.wait_for_load_state("load") + await page.wait_for_load_state( + self.wait_until, timeout=self.timeout + ) text = await self.evaluator.evaluate_async(page, browser, response) await page.close() diff --git a/libs/community/tests/integration_tests/document_loaders/test_url_playwright.py b/libs/community/tests/integration_tests/document_loaders/test_url_playwright.py index 4f0d405eb..3a21da53b 100644 --- a/libs/community/tests/integration_tests/document_loaders/test_url_playwright.py +++ b/libs/community/tests/integration_tests/document_loaders/test_url_playwright.py @@ -42,6 +42,20 @@ def test_playwright_url_loader() -> None: assert len(docs) > 0 +def test_playwright_url_loader_with_timeout() -> None: + """Test Playwright URL loader with custom timeout and wait_until.""" + urls = ["https://techmeme.com"] + loader = PlaywrightURLLoader( + urls=urls, + timeout=60000, # 60 second timeout + wait_until="domcontentloaded", # Wait for DOM content to load + continue_on_failure=False, + headless=True, + ) + docs = loader.load() + assert len(docs) > 0 + + async def test_playwright_async_url_loader() -> None: """Test Playwright async URL loader.""" urls = [ @@ -60,6 +74,20 @@ async def test_playwright_async_url_loader() -> None: assert len(docs) > 0 +async def test_playwright_async_url_loader_with_timeout() -> None: + """Test Playwright async URL loader with custom timeout and wait_until.""" + urls = ["https://techmeme.com"] + loader = PlaywrightURLLoader( + urls=urls, + timeout=60000, # 60 second timeout + wait_until="domcontentloaded", # Wait for DOM content to load + continue_on_failure=False, + headless=True, + ) + docs = await loader.aload() + assert len(docs) > 0 + + def test_playwright_url_loader_with_custom_evaluator() -> None: """Test Playwright URL loader with a custom evaluator.""" urls = ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"] From 82c99be1afe71a41445d4e5d595025c4c9c9c74f Mon Sep 17 00:00:00 2001 From: Rajesh Kumar <31363564+rajasblack@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:27:43 -0700 Subject: [PATCH 07/14] feat: add SSL verification option to recursive link fetching (#46) In the current implementation of the method _get_child_links_recursive, the requests.get call doesn't accept verify as a parameter. This does not allow users to disable SSL certificate verification when needed. Please consider exposing the verify parameter as a configurable argument to the method, defaulting to True for safety, but allowing users to override it when necessary. https://github.com/langchain-ai/langchain-community/blob/bc87773064735e649cfd798185502e156d5e948a/libs/community/langchain_community/document_loaders/recursive_url_loader.py#L376-L377 --------- Co-authored-by: Mason Daugherty --- .../document_loaders/recursive_url_loader.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/document_loaders/recursive_url_loader.py b/libs/community/langchain_community/document_loaders/recursive_url_loader.py index 813ef1154..b18384c8f 100644 --- a/libs/community/langchain_community/document_loaders/recursive_url_loader.py +++ b/libs/community/langchain_community/document_loaders/recursive_url_loader.py @@ -408,7 +408,11 @@ def _get_child_links_recursive( visited.add(url) try: response = requests.get( - url, timeout=self.timeout, headers=self.headers, proxies=self.proxies + url, + timeout=self.timeout, + headers=self.headers, + proxies=self.proxies, + verify=self.ssl, ) if self.encoding is not None: @@ -488,7 +492,7 @@ async def _async_get_child_links_recursive( ) visited.add(url) try: - async with session.get(url) as response: + async with session.get(url, ssl=self.ssl) as response: text = await response.text() if self.check_response_status and 400 <= response.status <= 599: raise ValueError(f"Received HTTP status {response.status}") From 3259e261d54298e8855a1ceee240fc670cde444d Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Thu, 6 Nov 2025 23:41:33 -0500 Subject: [PATCH 08/14] chore: some cleanup (#412) --- .../chains/graph_qa/arangodb.py | 4 +- .../chains/graph_qa/base.py | 14 ++----- .../chains/graph_qa/cypher.py | 20 ++++------ .../chains/graph_qa/falkordb.py | 14 ++----- .../chains/graph_qa/gremlin.py | 14 ++----- .../chains/graph_qa/hugegraph.py | 14 ++----- .../chains/graph_qa/kuzu.py | 14 ++----- .../chains/graph_qa/memgraph.py | 20 ++++------ .../chains/graph_qa/nebulagraph.py | 14 ++----- .../chains/graph_qa/ontotext_graphdb.py | 4 +- .../chains/graph_qa/sparql.py | 16 +++----- .../chains/llm_requests.py | 16 +++----- .../chains/openapi/chain.py | 16 +++----- .../chains/pebblo_retrieval/base.py | 34 +++++++---------- .../chat_models/baidu_qianfan_endpoint.py | 23 +++++++---- .../chat_models/deepinfra.py | 2 +- .../chat_models/google_palm.py | 2 +- .../chat_models/gpt_router.py | 2 +- .../chat_models/jinachat.py | 4 +- .../langchain_community/chat_models/konko.py | 2 +- .../chat_models/llamacpp.py | 27 ++++++++----- .../chat_models/minimax.py | 19 +++++++--- .../langchain_community/chat_models/naver.py | 4 +- .../chat_models/oci_data_science.py | 19 +++++++--- .../chat_models/oci_generative_ai.py | 18 ++++++--- .../langchain_community/chat_models/openai.py | 4 +- .../chat_models/outlines.py | 38 +++++++++---------- .../langchain_community/chat_models/reka.py | 4 +- .../chat_models/sparkllm.py | 10 ++--- .../langchain_community/chat_models/tongyi.py | 21 ++++++---- .../langchain_community/chat_models/writer.py | 4 +- .../langchain_community/chat_models/yuan2.py | 4 +- .../chat_models/zhipuai.py | 19 +++++++--- .../cross_encoders/huggingface.py | 2 +- .../cross_encoders/sagemaker_endpoint.py | 2 +- .../document_loaders/base_o365.py | 12 +++--- .../blob_loaders/cloud_blob_loader.py | 2 +- .../embeddings/aleph_alpha.py | 28 +++++++------- .../langchain_community/embeddings/awa.py | 2 +- .../embeddings/baichuan.py | 2 +- .../langchain_community/embeddings/bedrock.py | 4 +- .../embeddings/clarifai.py | 2 +- .../langchain_community/embeddings/cohere.py | 4 +- .../embeddings/dashscope.py | 2 +- .../embeddings/fastembed.py | 2 +- .../langchain_community/embeddings/gpt4all.py | 2 +- .../embeddings/gradient_ai.py | 4 +- .../embeddings/huggingface.py | 10 ++--- .../embeddings/huggingface_hub.py | 4 +- .../embeddings/infinity.py | 4 +- .../embeddings/infinity_local.py | 2 +- .../embeddings/ipex_llm.py | 2 +- .../langchain_community/embeddings/jina.py | 2 +- .../langchain_community/embeddings/laser.py | 2 +- .../embeddings/llamacpp.py | 6 +-- .../langchain_community/embeddings/localai.py | 2 +- .../langchain_community/embeddings/naver.py | 4 +- .../embeddings/nlpcloud.py | 2 +- .../embeddings/oci_generative_ai.py | 16 ++++---- .../langchain_community/embeddings/openai.py | 24 ++++++------ .../embeddings/self_hosted_hugging_face.py | 2 +- .../embeddings/tensorflow_hub.py | 2 +- .../embeddings/vertexai.py | 2 +- .../langchain_community/embeddings/zhipuai.py | 2 +- .../langchain_community/llms/aleph_alpha.py | 18 ++++----- .../langchain_community/llms/anthropic.py | 4 +- .../langchain_community/llms/aphrodite.py | 12 +++--- .../langchain_community/llms/arcee.py | 2 +- .../llms/azureml_endpoint.py | 30 +++++++-------- .../langchain_community/llms/bedrock.py | 4 +- .../langchain_community/llms/clarifai.py | 6 +-- .../langchain_community/llms/cohere.py | 4 +- .../langchain_community/llms/ctransformers.py | 2 +- .../langchain_community/llms/ctranslate2.py | 6 +-- .../langchain_community/llms/deepsparse.py | 2 +- .../langchain_community/llms/google_palm.py | 2 +- .../langchain_community/llms/gpt4all.py | 4 +- .../langchain_community/llms/gradient_ai.py | 2 +- .../llms/huggingface_hub.py | 6 +-- .../llms/huggingface_pipeline.py | 2 +- .../langchain_community/llms/ipex_llm.py | 4 +- .../llms/layerup_security.py | 2 +- .../langchain_community/llms/llamacpp.py | 6 +-- .../langchain_community/llms/manifest.py | 2 +- .../langchain_community/llms/mlx_pipeline.py | 4 +- .../langchain_community/llms/nlpcloud.py | 2 +- .../llms/oci_generative_ai.py | 18 ++++----- .../langchain_community/llms/openai.py | 36 +++++++++--------- .../langchain_community/llms/outlines.py | 38 +++++++++---------- .../llms/predictionguard.py | 2 +- .../langchain_community/llms/rwkv.py | 10 ++--- .../langchain_community/llms/sambanova.py | 6 ++- .../langchain_community/llms/self_hosted.py | 8 ++-- .../llms/self_hosted_hugging_face.py | 2 +- .../langchain_community/llms/sparkllm.py | 10 ++--- .../langchain_community/llms/tongyi.py | 2 +- .../langchain_community/llms/vertexai.py | 12 ++---- .../langchain_community/llms/vllm.py | 12 +++--- .../llms/weight_only_quantization.py | 2 +- .../langchain_community/llms/writer.py | 10 ++--- .../langchain_community/memory/kg.py | 7 +--- .../langchain_community/retrievers/arcee.py | 2 +- .../google_cloud_documentai_warehouse.py | 2 +- .../retrievers/thirdai_neuraldb.py | 2 +- .../document_intelligence.py | 6 +-- .../tools/azure_ai_services/image_analysis.py | 6 +-- .../tools/azure_ai_services/speech_to_text.py | 8 ++-- .../text_analytics_for_health.py | 6 +-- .../tools/azure_ai_services/text_to_speech.py | 8 ++-- .../form_recognizer.py | 6 +-- .../image_analysis.py | 8 ++-- .../azure_cognitive_services/speech2text.py | 8 ++-- .../azure_cognitive_services/text2speech.py | 8 ++-- .../text_analytics_health.py | 6 +-- .../langchain_community/utilities/arxiv.py | 4 +- .../langchain_community/utilities/asknews.py | 4 +- .../utilities/awslambda.py | 2 +- .../utilities/dalle_image_generator.py | 6 +-- .../utilities/dataherald.py | 2 +- .../langchain_community/utilities/github.py | 4 +- .../langchain_community/utilities/gitlab.py | 14 +++++-- .../utilities/google_search.py | 8 +++- .../langchain_community/utilities/graphql.py | 8 +++- .../langchain_community/utilities/jira.py | 8 +++- .../langchain_community/utilities/pubmed.py | 17 ++++++--- .../utilities/searx_search.py | 5 +-- .../utilities/semanticscholar.py | 7 +++- .../langchain_community/utilities/serpapi.py | 13 ++++--- .../utilities/stackexchange.py | 10 +++-- .../utilities/tensorflow_datasets.py | 6 ++- .../langchain_community/utilities/twilio.py | 21 +++++----- .../langchain_community/utilities/wikidata.py | 10 ++++- .../utilities/wikipedia.py | 6 ++- .../utilities/wolfram_alpha.py | 3 +- .../vectorstores/thirdai_neuraldb.py | 4 +- libs/community/pyproject.toml | 11 +++--- 136 files changed, 587 insertions(+), 561 deletions(-) diff --git a/libs/community/langchain_community/chains/graph_qa/arangodb.py b/libs/community/langchain_community/chains/graph_qa/arangodb.py index 42a3d362b..ad763369d 100644 --- a/libs/community/langchain_community/chains/graph_qa/arangodb.py +++ b/libs/community/langchain_community/chains/graph_qa/arangodb.py @@ -39,8 +39,8 @@ class ArangoGraphQAChain(Chain): aql_generation_chain: LLMChain aql_fix_chain: LLMChain qa_chain: LLMChain - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" # Specifies the maximum number of AQL Query Results to return top_k: int = 10 diff --git a/libs/community/langchain_community/chains/graph_qa/base.py b/libs/community/langchain_community/chains/graph_qa/base.py index f3e31af96..18c74eb8b 100644 --- a/libs/community/langchain_community/chains/graph_qa/base.py +++ b/libs/community/langchain_community/chains/graph_qa/base.py @@ -36,23 +36,17 @@ class GraphQAChain(Chain): graph: NetworkxEntityGraph = Field(exclude=True) entity_extraction_chain: LLMChain qa_chain: LLMChain - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" @property def input_keys(self) -> List[str]: - """Input keys. - - :meta private: - """ + """Input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Output keys. - - :meta private: - """ + """Output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/graph_qa/cypher.py b/libs/community/langchain_community/chains/graph_qa/cypher.py index 925be36d5..4e0d2017a 100644 --- a/libs/community/langchain_community/chains/graph_qa/cypher.py +++ b/libs/community/langchain_community/chains/graph_qa/cypher.py @@ -38,9 +38,9 @@ INTERMEDIATE_STEPS_KEY = "intermediate_steps" -FUNCTION_RESPONSE_SYSTEM = """You are an assistant that helps to form nice and human +FUNCTION_RESPONSE_SYSTEM = """You are an assistant that helps to form nice and human understandable answers based on the provided information from tools. -Do not add any other information that wasn't present in the tools, and use +Do not add any other information that wasn't present in the tools, and use very concise style in interpreting results! """ @@ -189,8 +189,8 @@ class GraphCypherQAChain(Chain): cypher_generation_chain: LLMChain qa_chain: Union[LLMChain, Runnable] graph_schema: str - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" top_k: int = 10 """Number of results to return from the query""" return_intermediate_steps: bool = False @@ -203,7 +203,7 @@ class GraphCypherQAChain(Chain): """Whether to wrap the database context as tool/function response""" allow_dangerous_requests: bool = False """Forced user opt-in to acknowledge that the chain can make dangerous requests. - + *Security note*: Make sure that the database connection uses credentials that are narrowly-scoped to only include necessary permissions. Failure to do so may result in data corruption or loss, since the calling @@ -234,18 +234,12 @@ def __init__(self, **kwargs: Any) -> None: @property def input_keys(self) -> List[str]: - """Return the input keys. - - :meta private: - """ + """Return the input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Return the output keys. - - :meta private: - """ + """Return the output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/graph_qa/falkordb.py b/libs/community/langchain_community/chains/graph_qa/falkordb.py index 1f47fb561..d9674a0e4 100644 --- a/libs/community/langchain_community/chains/graph_qa/falkordb.py +++ b/libs/community/langchain_community/chains/graph_qa/falkordb.py @@ -57,8 +57,8 @@ class FalkorDBQAChain(Chain): graph: FalkorDBGraph = Field(exclude=True) cypher_generation_chain: LLMChain qa_chain: LLMChain - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" top_k: int = 10 """Number of results to return from the query""" return_intermediate_steps: bool = False @@ -99,18 +99,12 @@ def __init__(self, **kwargs: Any) -> None: @property def input_keys(self) -> List[str]: - """Return the input keys. - - :meta private: - """ + """Return the input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Return the output keys. - - :meta private: - """ + """Return the output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/graph_qa/gremlin.py b/libs/community/langchain_community/chains/graph_qa/gremlin.py index 1680bd8f4..6716798f3 100644 --- a/libs/community/langchain_community/chains/graph_qa/gremlin.py +++ b/libs/community/langchain_community/chains/graph_qa/gremlin.py @@ -57,8 +57,8 @@ class GremlinQAChain(Chain): qa_chain: LLMChain gremlin_fix_chain: LLMChain max_fix_retries: int = 3 - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" top_k: int = 100 return_direct: bool = False return_intermediate_steps: bool = False @@ -96,18 +96,12 @@ def __init__(self, **kwargs: Any) -> None: @property def input_keys(self) -> List[str]: - """Input keys. - - :meta private: - """ + """Input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Output keys. - - :meta private: - """ + """Output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/graph_qa/hugegraph.py b/libs/community/langchain_community/chains/graph_qa/hugegraph.py index 206e26df3..c3408aa41 100644 --- a/libs/community/langchain_community/chains/graph_qa/hugegraph.py +++ b/libs/community/langchain_community/chains/graph_qa/hugegraph.py @@ -36,8 +36,8 @@ class HugeGraphQAChain(Chain): graph: HugeGraph = Field(exclude=True) gremlin_generation_chain: LLMChain qa_chain: LLMChain - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" allow_dangerous_requests: bool = False """Forced user opt-in to acknowledge that the chain can make dangerous requests. @@ -72,18 +72,12 @@ def __init__(self, **kwargs: Any) -> None: @property def input_keys(self) -> List[str]: - """Input keys. - - :meta private: - """ + """Input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Output keys. - - :meta private: - """ + """Output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/graph_qa/kuzu.py b/libs/community/langchain_community/chains/graph_qa/kuzu.py index c4da7b5dc..acd331341 100644 --- a/libs/community/langchain_community/chains/graph_qa/kuzu.py +++ b/libs/community/langchain_community/chains/graph_qa/kuzu.py @@ -70,8 +70,8 @@ class KuzuQAChain(Chain): graph: KuzuGraph = Field(exclude=True) cypher_generation_chain: LLMChain qa_chain: LLMChain - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" allow_dangerous_requests: bool = False """Forced user opt-in to acknowledge that the chain can make dangerous requests. @@ -106,18 +106,12 @@ def __init__(self, **kwargs: Any) -> None: @property def input_keys(self) -> List[str]: - """Return the input keys. - - :meta private: - """ + """Return the input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Return the output keys. - - :meta private: - """ + """Return the output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/graph_qa/memgraph.py b/libs/community/langchain_community/chains/graph_qa/memgraph.py index 349bdf67d..d688f0624 100644 --- a/libs/community/langchain_community/chains/graph_qa/memgraph.py +++ b/libs/community/langchain_community/chains/graph_qa/memgraph.py @@ -32,9 +32,9 @@ INTERMEDIATE_STEPS_KEY = "intermediate_steps" -FUNCTION_RESPONSE_SYSTEM = """You are an assistant that helps to form nice and human +FUNCTION_RESPONSE_SYSTEM = """You are an assistant that helps to form nice and human understandable answers based on the provided information from tools. -Do not add any other information that wasn't present in the tools, and use +Do not add any other information that wasn't present in the tools, and use very concise style in interpreting results! """ @@ -101,8 +101,8 @@ class MemgraphQAChain(Chain): cypher_generation_chain: Runnable qa_chain: Runnable graph_schema: str - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" top_k: int = 10 """Number of results to return from the query""" return_intermediate_steps: bool = False @@ -113,7 +113,7 @@ class MemgraphQAChain(Chain): """Whether to wrap the database context as tool/function response""" allow_dangerous_requests: bool = False """Forced user opt-in to acknowledge that the chain can make dangerous requests. - + *Security note*: Make sure that the database connection uses credentials that are narrowly-scoped to only include necessary permissions. Failure to do so may result in data corruption or loss, since the calling @@ -144,18 +144,12 @@ def __init__(self, **kwargs: Any) -> None: @property def input_keys(self) -> List[str]: - """Return the input keys. - - :meta private: - """ + """Return the input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Return the output keys. - - :meta private: - """ + """Return the output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/graph_qa/nebulagraph.py b/libs/community/langchain_community/chains/graph_qa/nebulagraph.py index 48326b508..765594bdf 100644 --- a/libs/community/langchain_community/chains/graph_qa/nebulagraph.py +++ b/libs/community/langchain_community/chains/graph_qa/nebulagraph.py @@ -36,8 +36,8 @@ class NebulaGraphQAChain(Chain): graph: NebulaGraph = Field(exclude=True) ngql_generation_chain: LLMChain qa_chain: LLMChain - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" allow_dangerous_requests: bool = False """Forced user opt-in to acknowledge that the chain can make dangerous requests. @@ -72,18 +72,12 @@ def __init__(self, **kwargs: Any) -> None: @property def input_keys(self) -> List[str]: - """Return the input keys. - - :meta private: - """ + """Return the input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Return the output keys. - - :meta private: - """ + """Return the output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/graph_qa/ontotext_graphdb.py b/libs/community/langchain_community/chains/graph_qa/ontotext_graphdb.py index 613100a33..9ee61e76f 100644 --- a/libs/community/langchain_community/chains/graph_qa/ontotext_graphdb.py +++ b/libs/community/langchain_community/chains/graph_qa/ontotext_graphdb.py @@ -43,8 +43,8 @@ class OntotextGraphDBQAChain(Chain): sparql_fix_chain: LLMChain max_fix_retries: int qa_chain: LLMChain - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" allow_dangerous_requests: bool = False """Forced user opt-in to acknowledge that the chain can make dangerous requests. diff --git a/libs/community/langchain_community/chains/graph_qa/sparql.py b/libs/community/langchain_community/chains/graph_qa/sparql.py index 56ed5cc9b..ab8a81e90 100644 --- a/libs/community/langchain_community/chains/graph_qa/sparql.py +++ b/libs/community/langchain_community/chains/graph_qa/sparql.py @@ -43,9 +43,9 @@ class GraphSparqlQAChain(Chain): sparql_intent_chain: LLMChain qa_chain: LLMChain return_sparql_query: bool = False - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: - sparql_query_key: str = "sparql_query" #: :meta private: + input_key: str = "query" + output_key: str = "result" + sparql_query_key: str = "sparql_query" allow_dangerous_requests: bool = False """Forced user opt-in to acknowledge that the chain can make dangerous requests. @@ -80,18 +80,12 @@ def __init__(self, **kwargs: Any) -> None: @property def input_keys(self) -> List[str]: - """Return the input keys. - - :meta private: - """ + """Return the input keys.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Return the output keys. - - :meta private: - """ + """Return the output keys.""" _output_keys = [self.output_key] return _output_keys diff --git a/libs/community/langchain_community/chains/llm_requests.py b/libs/community/langchain_community/chains/llm_requests.py index b5bf412d5..a8920e94b 100644 --- a/libs/community/langchain_community/chains/llm_requests.py +++ b/libs/community/langchain_community/chains/llm_requests.py @@ -34,9 +34,9 @@ class LLMRequestsChain(Chain): exclude=True, ) text_length: int = 8000 - requests_key: str = "requests_result" #: :meta private: - input_key: str = "url" #: :meta private: - output_key: str = "output" #: :meta private: + requests_key: str = "requests_result" + input_key: str = "url" + output_key: str = "output" model_config = ConfigDict( arbitrary_types_allowed=True, @@ -45,18 +45,12 @@ class LLMRequestsChain(Chain): @property def input_keys(self) -> List[str]: - """Will be whatever keys the prompt expects. - - :meta private: - """ + """Will be whatever keys the prompt expects.""" return [self.input_key] @property def output_keys(self) -> List[str]: - """Will always return text key. - - :meta private: - """ + """Will always return text key.""" return [self.output_key] @model_validator(mode="before") diff --git a/libs/community/langchain_community/chains/openapi/chain.py b/libs/community/langchain_community/chains/openapi/chain.py index 3b9ebe9a3..5d462b801 100644 --- a/libs/community/langchain_community/chains/openapi/chain.py +++ b/libs/community/langchain_community/chains/openapi/chain.py @@ -35,24 +35,18 @@ class OpenAPIEndpointChain(Chain, BaseModel): requests: Requests = Field(exclude=True, default_factory=Requests) param_mapping: _ParamMapping = Field(alias="param_mapping") return_intermediate_steps: bool = False - instructions_key: str = "instructions" #: :meta private: - output_key: str = "output" #: :meta private: - max_text_length: Optional[int] = Field(ge=0) #: :meta private: + instructions_key: str = "instructions" + output_key: str = "output" + max_text_length: Optional[int] = Field(ge=0) @property def input_keys(self) -> List[str]: - """Expect input key. - - :meta private: - """ + """Expect input key.""" return [self.instructions_key] @property def output_keys(self) -> List[str]: - """Expect output key. - - :meta private: - """ + """Expect output key.""" if not self.return_intermediate_steps: return [self.output_key] else: diff --git a/libs/community/langchain_community/chains/pebblo_retrieval/base.py b/libs/community/langchain_community/chains/pebblo_retrieval/base.py index 29ae7ba2a..0e6451d01 100644 --- a/libs/community/langchain_community/chains/pebblo_retrieval/base.py +++ b/libs/community/langchain_community/chains/pebblo_retrieval/base.py @@ -50,32 +50,32 @@ class PebbloRetrievalQA(Chain): combine_documents_chain: BaseCombineDocumentsChain """Chain to use to combine the documents.""" - input_key: str = "query" #: :meta private: - output_key: str = "result" #: :meta private: + input_key: str = "query" + output_key: str = "result" return_source_documents: bool = False """Return the source documents or not.""" retriever: VectorStoreRetriever = Field(exclude=True) """VectorStore to use for retrieval.""" - auth_context_key: str = "auth_context" #: :meta private: + auth_context_key: str = "auth_context" """Authentication context for identity enforcement.""" - semantic_context_key: str = "semantic_context" #: :meta private: + semantic_context_key: str = "semantic_context" """Semantic context for semantic enforcement.""" - app_name: str #: :meta private: + app_name: str """App name.""" - owner: str #: :meta private: + owner: str """Owner of app.""" - description: str #: :meta private: + description: str """Description of app.""" - api_key: Optional[str] = None #: :meta private: + api_key: Optional[str] = None """Pebblo cloud API key for app.""" - classifier_url: Optional[str] = None #: :meta private: + classifier_url: Optional[str] = None """Classifier endpoint.""" - classifier_location: str = "local" #: :meta private: + classifier_location: str = "local" """Classifier location. It could be either of 'local' or 'pebblo-cloud'.""" - _discover_sent: bool = False #: :meta private: + _discover_sent: bool = False """Flag to check if discover payload has been sent.""" - enable_prompt_gov: bool = True #: :meta private: + enable_prompt_gov: bool = True """Flag to check if prompt governance is enabled or not""" pb_client: PebbloRetrievalAPIWrapper = Field( default_factory=PebbloRetrievalAPIWrapper @@ -197,18 +197,12 @@ async def _acall( @property def input_keys(self) -> List[str]: - """Input keys. - - :meta private: - """ + """Input keys.""" return [self.input_key, self.auth_context_key, self.semantic_context_key] @property def output_keys(self) -> List[str]: - """Output keys. - - :meta private: - """ + """Output keys.""" _output_keys = [self.output_key] if self.return_source_documents: _output_keys += ["source_documents"] diff --git a/libs/community/langchain_community/chat_models/baidu_qianfan_endpoint.py b/libs/community/langchain_community/chat_models/baidu_qianfan_endpoint.py index 0f1fa6012..e6e95ff5c 100644 --- a/libs/community/langchain_community/chat_models/baidu_qianfan_endpoint.py +++ b/libs/community/langchain_community/chat_models/baidu_qianfan_endpoint.py @@ -349,7 +349,7 @@ class Joke(BaseModel): model_kwargs: Dict[str, Any] = Field(default_factory=dict) """extra params for model invoke using with `do`.""" - client: Any = None #: :meta private: + client: Any = None # It could be empty due to the use of Console API # And they're not list here @@ -719,18 +719,25 @@ def with_structured_output( """Model wrapper that returns outputs formatted to match the given schema. Args: - schema: The output schema as a dict or a Pydantic class. If a Pydantic class + schema: The output schema as a dict or a Pydantic class.If a Pydantic class then the model output will be an object of that class. If a dict then the model output will be a dict. With a Pydantic class the returned attributes will be validated, whereas with a dict they will not be. If `method` is "function_calling" and `schema` is a dict, then the dict must match the OpenAI function-calling spec. - include_raw: If False then only the parsed structured output is returned. If - an error occurs during model output parsing it will be raised. If True - then both the raw model response (a BaseMessage) and the parsed model - response will be returned. If an error occurs during output parsing it - will be caught and returned as well. The final output is always a dict - with keys "raw", "parsed", and "parsing_error". + include_raw: + If `False` then only the parsed structured output is returned. + + If an error occurs during model output parsing it will be raised. + + If `True` then both the raw model response (a `BaseMessage`) and the + parsed model response will be returned. + + If an error occurs during output parsing it will be caught and returned + as well. + + The final output is always a `dict` with keys `'raw'`, `'parsed'`, and + `'parsing_error'`. Returns: A Runnable that takes any ChatModel input and returns as output: diff --git a/libs/community/langchain_community/chat_models/deepinfra.py b/libs/community/langchain_community/chat_models/deepinfra.py index a0f9cf733..57c7ad603 100644 --- a/libs/community/langchain_community/chat_models/deepinfra.py +++ b/libs/community/langchain_community/chat_models/deepinfra.py @@ -204,7 +204,7 @@ def _convert_message_to_dict(message: BaseMessage) -> dict: class ChatDeepInfra(BaseChatModel): """A chat model that uses the DeepInfra API.""" - # client: Any #: :meta private: + # client: Any model_name: str = Field(default="meta-llama/Llama-2-70b-chat-hf", alias="model") """Model name to use.""" diff --git a/libs/community/langchain_community/chat_models/google_palm.py b/libs/community/langchain_community/chat_models/google_palm.py index 2204c3ecc..e4aec6430 100644 --- a/libs/community/langchain_community/chat_models/google_palm.py +++ b/libs/community/langchain_community/chat_models/google_palm.py @@ -237,7 +237,7 @@ class ChatGooglePalm(BaseChatModel, BaseModel): """ - client: Any #: :meta private: + client: Any model_name: str = "models/chat-bison-001" """Model name to use.""" google_api_key: Optional[SecretStr] = None diff --git a/libs/community/langchain_community/chat_models/gpt_router.py b/libs/community/langchain_community/chat_models/gpt_router.py index 91f314a8a..91ad26595 100644 --- a/libs/community/langchain_community/chat_models/gpt_router.py +++ b/libs/community/langchain_community/chat_models/gpt_router.py @@ -150,7 +150,7 @@ class GPTRouter(BaseChatModel): For more information, see https://gpt-router.writesonic.com/docs """ - client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) models_priority_list: List[GPTRouterModel] = Field(min_length=1) gpt_router_api_base: str = Field(default="") """WriteSonic GPTRouter custom endpoint""" diff --git a/libs/community/langchain_community/chat_models/jinachat.py b/libs/community/langchain_community/chat_models/jinachat.py index 52627f72d..05c4089ea 100644 --- a/libs/community/langchain_community/chat_models/jinachat.py +++ b/libs/community/langchain_community/chat_models/jinachat.py @@ -171,13 +171,13 @@ def is_lc_serializable(cls) -> bool: """Return whether this model can be serialized by Langchain.""" return False - client: Any = None #: :meta private: + client: Any = None temperature: float = 0.7 """What sampling temperature to use.""" model_kwargs: Dict[str, Any] = Field(default_factory=dict) """Holds any model parameters valid for `create` call not explicitly specified.""" jinachat_api_key: Optional[SecretStr] = None - """Base URL path for API requests, + """Base URL path for API requests, leave blank if not using a proxy or service emulator.""" request_timeout: Optional[Union[float, Tuple[float, float]]] = None """Timeout for requests to JinaChat completion API. Default is 600 seconds.""" diff --git a/libs/community/langchain_community/chat_models/konko.py b/libs/community/langchain_community/chat_models/konko.py index db4f1eded..690925a27 100644 --- a/libs/community/langchain_community/chat_models/konko.py +++ b/libs/community/langchain_community/chat_models/konko.py @@ -68,7 +68,7 @@ def is_lc_serializable(cls) -> bool: """Return whether this model can be serialized by Langchain.""" return False - client: Any = None #: :meta private: + client: Any = None model: str = Field(default=DEFAULT_MODEL, alias="model") """Model name to use.""" temperature: float = 0.7 diff --git a/libs/community/langchain_community/chat_models/llamacpp.py b/libs/community/langchain_community/chat_models/llamacpp.py index ec954360a..5a711fe7f 100644 --- a/libs/community/langchain_community/chat_models/llamacpp.py +++ b/libs/community/langchain_community/chat_models/llamacpp.py @@ -67,7 +67,7 @@ class ChatLlamaCpp(BaseChatModel): """ - client: Any = None #: :meta private: + client: Any = None model_path: str """The path to the Llama model file.""" @@ -165,8 +165,8 @@ class ChatLlamaCpp(BaseChatModel): """ grammar: Any = None """ - grammar: formal grammar for constraining model outputs. For instance, the grammar - can be used to force the model to generate valid JSON or to speak exclusively in + grammar: formal grammar for constraining model outputs. For instance, the grammar + can be used to force the model to generate valid JSON or to speak exclusively in emojis. At most one of grammar_path and grammar should be passed in. """ @@ -380,7 +380,7 @@ def bind_tools( tool_choice = formatted_tools[0] else: raise ValueError( - """Unrecognized tool_choice type. Expected dict having format like + """Unrecognized tool_choice type. Expected dict having format like this {"type": "function", "function": {"name": <>}}""" f"Received: {tool_choice}" ) @@ -406,12 +406,19 @@ def with_structured_output( `method` is "function_calling" and `schema` is a dict, then the dict must match the OpenAI function-calling spec or be a valid JSON schema with top level 'title' and 'description' keys specified. - include_raw: If False then only the parsed structured output is returned. If - an error occurs during model output parsing it will be raised. If True - then both the raw model response (a BaseMessage) and the parsed model - response will be returned. If an error occurs during output parsing it - will be caught and returned as well. The final output is always a dict - with keys "raw", "parsed", and "parsing_error". + include_raw: + If `False` then only the parsed structured output is returned. + + If an error occurs during model output parsing it will be raised. + + If `True` then both the raw model response (a `BaseMessage`) and the + parsed model response will be returned. + + If an error occurs during output parsing it will be caught and returned + as well. + + The final output is always a `dict` with keys `'raw'`, `'parsed'`, and + `'parsing_error'`. kwargs: Any other args to bind to model, ``self.bind(..., **kwargs)``. Returns: diff --git a/libs/community/langchain_community/chat_models/minimax.py b/libs/community/langchain_community/chat_models/minimax.py index 2ea1889f1..ebbbe49eb 100644 --- a/libs/community/langchain_community/chat_models/minimax.py +++ b/libs/community/langchain_community/chat_models/minimax.py @@ -681,12 +681,19 @@ def with_structured_output( attributes will be validated, whereas with a dict they will not be. If `method` is "function_calling" and `schema` is a dict, then the dict must match the OpenAI function-calling spec. - include_raw: If False then only the parsed structured output is returned. If - an error occurs during model output parsing it will be raised. If True - then both the raw model response (a BaseMessage) and the parsed model - response will be returned. If an error occurs during output parsing it - will be caught and returned as well. The final output is always a dict - with keys "raw", "parsed", and "parsing_error". + include_raw: + If `False` then only the parsed structured output is returned. + + If an error occurs during model output parsing it will be raised. + + If `True` then both the raw model response (a `BaseMessage`) and the + parsed model response will be returned. + + If an error occurs during output parsing it will be caught and returned + as well. + + The final output is always a `dict` with keys `'raw'`, `'parsed'`, and + `'parsing_error'`. Returns: A Runnable that takes any ChatModel input and returns as output: diff --git a/libs/community/langchain_community/chat_models/naver.py b/libs/community/langchain_community/chat_models/naver.py index 413c9e79c..4e7ea88eb 100644 --- a/libs/community/langchain_community/chat_models/naver.py +++ b/libs/community/langchain_community/chat_models/naver.py @@ -196,8 +196,8 @@ class ChatClovaX(BaseChatModel): model.invoke([HumanMessage(content="Come up with 10 names for a song about parrots.")]) """ # noqa: E501 - client: Optional[httpx.Client] = Field(default=None) #: :meta private: - async_client: Optional[httpx.AsyncClient] = Field(default=None) #: :meta private: + client: Optional[httpx.Client] = Field(default=None) + async_client: Optional[httpx.AsyncClient] = Field(default=None) model_name: str = Field( default="HCX-003", diff --git a/libs/community/langchain_community/chat_models/oci_data_science.py b/libs/community/langchain_community/chat_models/oci_data_science.py index 439cd85ce..abc7fd8bb 100644 --- a/libs/community/langchain_community/chat_models/oci_data_science.py +++ b/libs/community/langchain_community/chat_models/oci_data_science.py @@ -562,12 +562,19 @@ def with_structured_output( for "json_mode". If "json_mode" then JSON mode will be used. Note that if using "json_mode" then you must include instructions for formatting the output into the desired schema into the model call. - include_raw: If False then only the parsed structured output is returned. If - an error occurs during model output parsing it will be raised. If True - then both the raw model response (a BaseMessage) and the parsed model - response will be returned. If an error occurs during output parsing it - will be caught and returned as well. The final output is always a dict - with keys "raw", "parsed", and "parsing_error". + include_raw: + If `False` then only the parsed structured output is returned. + + If an error occurs during model output parsing it will be raised. + + If `True` then both the raw model response (a `BaseMessage`) and the + parsed model response will be returned. + + If an error occurs during output parsing it will be caught and returned + as well. + + The final output is always a `dict` with keys `'raw'`, `'parsed'`, and + `'parsing_error'`. Returns: A Runnable that takes any ChatModel input and returns as output: diff --git a/libs/community/langchain_community/chat_models/oci_generative_ai.py b/libs/community/langchain_community/chat_models/oci_generative_ai.py index 914cb9c81..ff506acd6 100644 --- a/libs/community/langchain_community/chat_models/oci_generative_ai.py +++ b/libs/community/langchain_community/chat_models/oci_generative_ai.py @@ -678,12 +678,18 @@ def with_structured_output( used. Note that if using "json_mode" then you must include instructions for formatting the output into the desired schema into the model call. include_raw: - If False then only the parsed structured output is returned. If - an error occurs during model output parsing it will be raised. If True - then both the raw model response (a BaseMessage) and the parsed model - response will be returned. If an error occurs during output parsing it - will be caught and returned as well. The final output is always a dict - with keys "raw", "parsed", and "parsing_error". + If `False` then only the parsed structured output is returned. + + If an error occurs during model output parsing it will be raised. + + If `True` then both the raw model response (a `BaseMessage`) and the + parsed model response will be returned. + + If an error occurs during output parsing it will be caught and returned + as well. + + The final output is always a `dict` with keys `'raw'`, `'parsed'`, and + `'parsing_error'`. Returns: A Runnable that takes any ChatModel input and returns as output: diff --git a/libs/community/langchain_community/chat_models/openai.py b/libs/community/langchain_community/chat_models/openai.py index 7b69019ba..65e059d8d 100644 --- a/libs/community/langchain_community/chat_models/openai.py +++ b/libs/community/langchain_community/chat_models/openai.py @@ -223,8 +223,8 @@ def is_lc_serializable(cls) -> bool: """Return whether this model can be serialized by Langchain.""" return True - client: Any = Field(default=None, exclude=True) #: :meta private: - async_client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) + async_client: Any = Field(default=None, exclude=True) model_name: str = Field(default="gpt-3.5-turbo", alias="model") """Model name to use.""" temperature: float = 0.7 diff --git a/libs/community/langchain_community/chat_models/outlines.py b/libs/community/langchain_community/chat_models/outlines.py index 0fa41dc8d..162331ff5 100644 --- a/libs/community/langchain_community/chat_models/outlines.py +++ b/libs/community/langchain_community/chat_models/outlines.py @@ -73,17 +73,17 @@ class ChatOutlines(BaseChatModel): """ # noqa: E501 - client: Any = None # :meta private: + client: Any = None model: str """Identifier for the model to use with Outlines. - + The model identifier should be a string specifying: - A Hugging Face model name (e.g., "meta-llama/Llama-2-7b-chat-hf") - A local path to a model - For GGUF models, the format is "repo_id/file_name" (e.g., "TheBloke/Llama-2-7B-Chat-GGUF/llama-2-7b-chat.Q4_K_M.gguf") - + Examples: - "TheBloke/Llama-2-7B-Chat-GGUF/llama-2-7b-chat.Q4_K_M.gguf" - "meta-llama/Llama-2-7b-chat-hf" @@ -93,14 +93,14 @@ class ChatOutlines(BaseChatModel): "llamacpp", "transformers", "transformers_vision", "vllm", "mlxlm" ] = "transformers" """Specifies the backend to use for the model. - + Supported backends are: - "llamacpp": For GGUF models using llama.cpp - "transformers": For Hugging Face Transformers models (default) - "transformers_vision": For vision-language models (e.g., LLaVA) - "vllm": For models using the vLLM library - "mlxlm": For models using the MLX framework - + Note: Ensure you have the necessary dependencies installed for the chosen backend. The system will attempt to import required packages and may raise an ImportError if they are not available. @@ -117,35 +117,35 @@ class ChatOutlines(BaseChatModel): regex: Optional[str] = None """Regular expression for structured generation. - + If provided, Outlines will guarantee that the generated text matches this regex. This can be useful for generating structured outputs like IP addresses, dates, etc. - + Example: (valid IP address) regex = r"((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)" - + Note: Computing the regex index can take some time, so it's recommended to reuse the same regex for multiple generations if possible. - + For more details, see: https://dottxt-ai.github.io/outlines/reference/generation/regex/ """ # noqa: E501 type_constraints: Optional[Union[type, str]] = None """Type constraints for structured generation. - + Restricts the output to valid Python types. Supported types include: int, float, bool, datetime.date, datetime.time, datetime.datetime. - + Example: type_constraints = int - + For more details, see: https://dottxt-ai.github.io/outlines/reference/generation/format/ """ json_schema: Optional[Union[Any, Dict, Callable]] = None """Pydantic model, JSON Schema, or callable (function signature) for structured JSON generation. - + Outlines can generate JSON output that follows a specified structure, which is useful for: 1. Parsing the answer (e.g., with Pydantic), storing it, or returning it to a user. @@ -163,13 +163,13 @@ class ChatOutlines(BaseChatModel): grammar: Optional[str] = None """Context-free grammar for structured generation. - + If provided, Outlines will generate text that adheres to the specified grammar. The grammar should be defined in EBNF format. - + This can be useful for generating structured outputs like mathematical expressions, programming languages, or custom domain-specific languages. - + Example: grammar = ''' ?start: expression @@ -178,10 +178,10 @@ class ChatOutlines(BaseChatModel): ?factor: NUMBER | "-" factor | "(" expression ")" %import common.NUMBER ''' - + Note: Grammar-based generation is currently experimental and may have performance limitations. It uses greedy generation to mitigate these issues. - + For more details and examples, see: https://dottxt-ai.github.io/outlines/reference/generation/cfg/ """ @@ -191,7 +191,7 @@ class ChatOutlines(BaseChatModel): model_kwargs: Dict[str, Any] = Field(default_factory=dict) """Additional parameters to pass to the underlying model. - + Example: model_kwargs = {"temperature": 0.8, "seed": 42} """ diff --git a/libs/community/langchain_community/chat_models/reka.py b/libs/community/langchain_community/chat_models/reka.py index 22c2b9183..5c9c445cb 100644 --- a/libs/community/langchain_community/chat_models/reka.py +++ b/libs/community/langchain_community/chat_models/reka.py @@ -145,8 +145,8 @@ def convert_to_reka_messages(messages: List[BaseMessage]) -> List[Dict[str, Any] class ChatReka(BaseChatModel): """Reka chat large language models.""" - client: Any = None #: :meta private: - async_client: Any = None #: :meta private: + client: Any = None + async_client: Any = None model: str = Field(default=DEFAULT_REKA_MODEL) max_tokens: int = Field(default=256) temperature: Optional[float] = None diff --git a/libs/community/langchain_community/chat_models/sparkllm.py b/libs/community/langchain_community/chat_models/sparkllm.py index d54368040..6756c5c2c 100644 --- a/libs/community/langchain_community/chat_models/sparkllm.py +++ b/libs/community/langchain_community/chat_models/sparkllm.py @@ -269,18 +269,18 @@ def lc_secrets(self) -> Dict[str, str]: "spark_llm_domain": "IFLYTEK_SPARK_LLM_DOMAIN", } - client: Any = None #: :meta private: + client: Any = None spark_app_id: Optional[str] = Field(default=None, alias="app_id") - """Automatically inferred from env var `IFLYTEK_SPARK_APP_ID` + """Automatically inferred from env var `IFLYTEK_SPARK_APP_ID` if not provided.""" spark_api_key: Optional[str] = Field(default=None, alias="api_key") - """Automatically inferred from env var `IFLYTEK_SPARK_API_KEY` + """Automatically inferred from env var `IFLYTEK_SPARK_API_KEY` if not provided.""" spark_api_secret: Optional[str] = Field(default=None, alias="api_secret") - """Automatically inferred from env var `IFLYTEK_SPARK_API_SECRET` + """Automatically inferred from env var `IFLYTEK_SPARK_API_SECRET` if not provided.""" spark_api_url: Optional[str] = Field(default=None, alias="api_url") - """Base URL path for API requests, leave blank if not using a proxy or service + """Base URL path for API requests, leave blank if not using a proxy or service emulator.""" spark_llm_domain: Optional[str] = Field(default=None, alias="model") """Model name to use.""" diff --git a/libs/community/langchain_community/chat_models/tongyi.py b/libs/community/langchain_community/chat_models/tongyi.py index 69354d298..2a24f5e92 100644 --- a/libs/community/langchain_community/chat_models/tongyi.py +++ b/libs/community/langchain_community/chat_models/tongyi.py @@ -445,7 +445,7 @@ class Joke(BaseModel): def lc_secrets(self) -> Dict[str, str]: return {"dashscope_api_key": "DASHSCOPE_API_KEY"} - client: Any = None #: :meta private: + client: Any = None model_name: str = Field(default="qwen-turbo", alias="model") """Model name to use. callable multimodal model: @@ -870,12 +870,19 @@ def with_structured_output( attributes will be validated, whereas with a dict they will not be. If `method` is "function_calling" and `schema` is a dict, then the dict must match the OpenAI function-calling spec. - include_raw: If False then only the parsed structured output is returned. If - an error occurs during model output parsing it will be raised. If True - then both the raw model response (a BaseMessage) and the parsed model - response will be returned. If an error occurs during output parsing it - will be caught and returned as well. The final output is always a dict - with keys "raw", "parsed", and "parsing_error". + include_raw: + If `False` then only the parsed structured output is returned. + + If an error occurs during model output parsing it will be raised. + + If `True` then both the raw model response (a `BaseMessage`) and the + parsed model response will be returned. + + If an error occurs during output parsing it will be caught and returned + as well. + + The final output is always a `dict` with keys `'raw'`, `'parsed'`, and + `'parsing_error'`. Returns: A Runnable that takes any ChatModel input and returns as output: diff --git a/libs/community/langchain_community/chat_models/writer.py b/libs/community/langchain_community/chat_models/writer.py index a4d5ca7e3..79570f8ba 100644 --- a/libs/community/langchain_community/chat_models/writer.py +++ b/libs/community/langchain_community/chat_models/writer.py @@ -66,8 +66,8 @@ class ChatWriter(BaseChatModel): ) """ - client: Any = Field(default=None, exclude=True) #: :meta private: - async_client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) + async_client: Any = Field(default=None, exclude=True) api_key: Optional[SecretStr] = Field(default=None) """Writer API key.""" diff --git a/libs/community/langchain_community/chat_models/yuan2.py b/libs/community/langchain_community/chat_models/yuan2.py index 14808e25a..503ddc5c8 100644 --- a/libs/community/langchain_community/chat_models/yuan2.py +++ b/libs/community/langchain_community/chat_models/yuan2.py @@ -76,8 +76,8 @@ class ChatYuan2(BaseChatModel): chat = ChatYuan2() """ - client: Any = None #: :meta private: - async_client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = None + async_client: Any = Field(default=None, exclude=True) model_name: str = Field(default="yuan2", alias="model") """Model name to use.""" diff --git a/libs/community/langchain_community/chat_models/zhipuai.py b/libs/community/langchain_community/chat_models/zhipuai.py index c48b16bee..3a6ca9248 100644 --- a/libs/community/langchain_community/chat_models/zhipuai.py +++ b/libs/community/langchain_community/chat_models/zhipuai.py @@ -760,12 +760,19 @@ def with_structured_output( or "json_mode". ZhipuAI only supports "function_calling" which converts the schema to a OpenAI function and the model will make use of the function-calling API. - include_raw: If False then only the parsed structured output is returned. If - an error occurs during model output parsing it will be raised. If True - then both the raw model response (a BaseMessage) and the parsed model - response will be returned. If an error occurs during output parsing it - will be caught and returned as well. The final output is always a dict - with keys "raw", "parsed", and "parsing_error". + include_raw: + If `False` then only the parsed structured output is returned. + + If an error occurs during model output parsing it will be raised. + + If `True` then both the raw model response (a `BaseMessage`) and the + parsed model response will be returned. + + If an error occurs during output parsing it will be caught and returned + as well. + + The final output is always a `dict` with keys `'raw'`, `'parsed'`, and + `'parsing_error'`. Returns: A Runnable that takes any ChatModel input and returns as output: diff --git a/libs/community/langchain_community/cross_encoders/huggingface.py b/libs/community/langchain_community/cross_encoders/huggingface.py index a0d1f68a1..dc755ff96 100644 --- a/libs/community/langchain_community/cross_encoders/huggingface.py +++ b/libs/community/langchain_community/cross_encoders/huggingface.py @@ -23,7 +23,7 @@ class HuggingFaceCrossEncoder(BaseModel, BaseCrossEncoder): ) """ - client: Any = None #: :meta private: + client: Any = None model_name: str = DEFAULT_MODEL_NAME """Model name to use.""" model_kwargs: Dict[str, Any] = Field(default_factory=dict) diff --git a/libs/community/langchain_community/cross_encoders/sagemaker_endpoint.py b/libs/community/langchain_community/cross_encoders/sagemaker_endpoint.py index 7b948ef77..2455d3870 100644 --- a/libs/community/langchain_community/cross_encoders/sagemaker_endpoint.py +++ b/libs/community/langchain_community/cross_encoders/sagemaker_endpoint.py @@ -61,7 +61,7 @@ class SagemakerEndpointCrossEncoder(BaseModel, BaseCrossEncoder): credentials_profile_name=credentials_profile_name ) """ - client: Any = None #: :meta private: + client: Any = None endpoint_name: str = "" """The name of the endpoint from the deployed Sagemaker model. diff --git a/libs/community/langchain_community/document_loaders/base_o365.py b/libs/community/langchain_community/document_loaders/base_o365.py index bbc07b504..d66a9f61f 100644 --- a/libs/community/langchain_community/document_loaders/base_o365.py +++ b/libs/community/langchain_community/document_loaders/base_o365.py @@ -92,15 +92,15 @@ class O365BaseLoader(BaseLoader, BaseModel): must be timezone aware.""" handlers: Optional[Dict[str, Any]] = {} """ - Provide custom handlers for MimeTypeBasedParser. + Provide custom handlers for `MimeTypeBasedParser`. - Pass a dictionary mapping either file extensions (like "doc", "pdf", etc.) - or MIME types (like "application/pdf", "text/plain", etc.) to parsers. - Note that you must use either file extensions or MIME types exclusively and + Pass a dictionary mapping either file extensions (like "doc", "pdf", etc.) + or MIME types (like "application/pdf", "text/plain", etc.) to parsers. + Note that you must use either file extensions or MIME types exclusively and cannot mix them. Do not include the leading dot for file extensions. - + Example using file extensions: ```python handlers = { @@ -109,7 +109,7 @@ class O365BaseLoader(BaseLoader, BaseModel): "txt": TextParser() } ``` - + Example using MIME types: ```python handlers = { diff --git a/libs/community/langchain_community/document_loaders/blob_loaders/cloud_blob_loader.py b/libs/community/langchain_community/document_loaders/blob_loaders/cloud_blob_loader.py index 8413c3108..28edc20f9 100644 --- a/libs/community/langchain_community/document_loaders/blob_loaders/cloud_blob_loader.py +++ b/libs/community/langchain_community/document_loaders/blob_loaders/cloud_blob_loader.py @@ -261,7 +261,7 @@ def from_path( If no scheme is provided, it is assumed to be a local file. encoding: Encoding to use if decoding the bytes into a string mime_type: if provided, will be set as the mime-type of the data - guess_type: If True, the mimetype will be guessed from the file extension, + guess_type: If True, the MIME type will be guessed from the file extension, if a mime-type was not provided metadata: Metadata to associate with the blob diff --git a/libs/community/langchain_community/embeddings/aleph_alpha.py b/libs/community/langchain_community/embeddings/aleph_alpha.py index 96426fdac..7cc9494a9 100644 --- a/libs/community/langchain_community/embeddings/aleph_alpha.py +++ b/libs/community/langchain_community/embeddings/aleph_alpha.py @@ -29,54 +29,54 @@ class AlephAlphaAsymmetricSemanticEmbedding(BaseModel, Embeddings): """ - client: Any #: :meta private: + client: Any # Embedding params model: str = "luminous-base" """Model name to use.""" compress_to_size: Optional[int] = None - """Should the returned embeddings come back as an original 5120-dim vector, + """Should the returned embeddings come back as an original 5120-dim vector, or should it be compressed to 128-dim.""" normalize: bool = False """Should returned embeddings be normalized""" contextual_control_threshold: Optional[int] = None - """Attention control parameters only apply to those tokens that have + """Attention control parameters only apply to those tokens that have explicitly been set in the request.""" control_log_additive: bool = True - """Apply controls on prompt items by adding the log(control_factor) + """Apply controls on prompt items by adding the log(control_factor) to attention scores.""" # Client params aleph_alpha_api_key: Optional[str] = None """API key for Aleph Alpha API.""" host: str = "https://api.aleph-alpha.com" - """The hostname of the API host. + """The hostname of the API host. The default one is "https://api.aleph-alpha.com")""" hosting: Optional[str] = None """Determines in which datacenters the request may be processed. You can either set the parameter to "aleph-alpha" or omit it (defaulting to None). - Not setting this value, or setting it to None, gives us maximal flexibility + Not setting this value, or setting it to None, gives us maximal flexibility in processing your request in our - own datacenters and on servers hosted with other providers. + own datacenters and on servers hosted with other providers. Choose this option for maximal availability. - Setting it to "aleph-alpha" allows us to only process the request + Setting it to "aleph-alpha" allows us to only process the request in our own datacenters. Choose this option for maximal data privacy.""" request_timeout_seconds: int = 305 - """Client timeout that will be set for HTTP requests in the + """Client timeout that will be set for HTTP requests in the `requests` library's API calls. Server will close all requests after 300 seconds with an internal server error.""" total_retries: int = 8 - """The number of retries made in case requests fail with certain retryable + """The number of retries made in case requests fail with certain retryable status codes. If the last - retry fails a corresponding exception is raised. Note, that between retries + retry fails a corresponding exception is raised. Note, that between retries an exponential backoff - is applied, starting with 0.5 s after the first retry and doubling for each + is applied, starting with 0.5 s after the first retry and doubling for each retry made. So with the - default setting of 8 retries a total wait time of 63.5 s is added between + default setting of 8 retries a total wait time of 63.5 s is added between the retries.""" nice: bool = False - """Setting this to True, will signal to the API that you intend to be + """Setting this to True, will signal to the API that you intend to be nice to other users by de-prioritizing your request below concurrent ones.""" diff --git a/libs/community/langchain_community/embeddings/awa.py b/libs/community/langchain_community/embeddings/awa.py index 27cb42242..85e49ed98 100644 --- a/libs/community/langchain_community/embeddings/awa.py +++ b/libs/community/langchain_community/embeddings/awa.py @@ -13,7 +13,7 @@ class AwaEmbeddings(BaseModel, Embeddings): Default is "all-mpnet-base-v2". """ - client: Any #: :meta private: + client: Any model: str = "all-mpnet-base-v2" @model_validator(mode="before") diff --git a/libs/community/langchain_community/embeddings/baichuan.py b/libs/community/langchain_community/embeddings/baichuan.py index c12aaa44f..b688affd3 100644 --- a/libs/community/langchain_community/embeddings/baichuan.py +++ b/libs/community/langchain_community/embeddings/baichuan.py @@ -59,7 +59,7 @@ class BaichuanTextEmbeddings(BaseModel, Embeddings): vectors = embeddings.embed_query(text) """ # noqa: E501 - session: Any = None #: :meta private: + session: Any = None model_name: str = Field(default="Baichuan-Text-Embedding", alias="model") """The model used to embed the documents.""" baichuan_api_key: SecretStr = Field( diff --git a/libs/community/langchain_community/embeddings/bedrock.py b/libs/community/langchain_community/embeddings/bedrock.py index 7fcfe707b..b030bd0c3 100644 --- a/libs/community/langchain_community/embeddings/bedrock.py +++ b/libs/community/langchain_community/embeddings/bedrock.py @@ -35,7 +35,7 @@ class BedrockEmbeddings(BaseModel, Embeddings): .. code-block:: python from langchain_community.bedrock_embeddings import BedrockEmbeddings - + region_name ="us-east-1" credentials_profile_name = "default" model_id = "amazon.titan-embed-text-v1" @@ -47,7 +47,7 @@ class BedrockEmbeddings(BaseModel, Embeddings): ) """ - client: Any = None #: :meta private: + client: Any = None """Bedrock client.""" region_name: Optional[str] = None """The aws region e.g., `us-west-2`. Fallsback to AWS_DEFAULT_REGION env variable diff --git a/libs/community/langchain_community/embeddings/clarifai.py b/libs/community/langchain_community/embeddings/clarifai.py index e460020be..73333fa5a 100644 --- a/libs/community/langchain_community/embeddings/clarifai.py +++ b/libs/community/langchain_community/embeddings/clarifai.py @@ -40,7 +40,7 @@ class ClarifaiEmbeddings(BaseModel, Embeddings): """Clarifai personal access token to use.""" token: Optional[str] = Field(default=None, exclude=True) """Clarifai session token to use.""" - model: Any = Field(default=None, exclude=True) #: :meta private: + model: Any = Field(default=None, exclude=True) api_base: str = "https://api.clarifai.com" model_config = ConfigDict(extra="forbid", protected_namespaces=()) diff --git a/libs/community/langchain_community/embeddings/cohere.py b/libs/community/langchain_community/embeddings/cohere.py index 504f68810..6c23a2525 100644 --- a/libs/community/langchain_community/embeddings/cohere.py +++ b/libs/community/langchain_community/embeddings/cohere.py @@ -30,9 +30,9 @@ class CohereEmbeddings(BaseModel, Embeddings): ) """ - client: Any = None #: :meta private: + client: Any = None """Cohere client.""" - async_client: Any = None #: :meta private: + async_client: Any = None """Cohere async client.""" model: str = "embed-english-v2.0" """Model name to use.""" diff --git a/libs/community/langchain_community/embeddings/dashscope.py b/libs/community/langchain_community/embeddings/dashscope.py index b3e30651c..23b693340 100644 --- a/libs/community/langchain_community/embeddings/dashscope.py +++ b/libs/community/langchain_community/embeddings/dashscope.py @@ -111,7 +111,7 @@ class DashScopeEmbeddings(BaseModel, Embeddings): """ - client: Any = None #: :meta private: + client: Any = None """The DashScope client.""" model: str = "text-embedding-v1" dashscope_api_key: Optional[str] = None diff --git a/libs/community/langchain_community/embeddings/fastembed.py b/libs/community/langchain_community/embeddings/fastembed.py index d46f92106..fdeb0dc33 100644 --- a/libs/community/langchain_community/embeddings/fastembed.py +++ b/libs/community/langchain_community/embeddings/fastembed.py @@ -73,7 +73,7 @@ class FastEmbedEmbeddings(BaseModel, Embeddings): Defaults to `None`. """ - model: Any = None # : :meta private: + model: Any = None model_config = ConfigDict(extra="allow", protected_namespaces=()) diff --git a/libs/community/langchain_community/embeddings/gpt4all.py b/libs/community/langchain_community/embeddings/gpt4all.py index 5183cbb08..fd88bcb14 100644 --- a/libs/community/langchain_community/embeddings/gpt4all.py +++ b/libs/community/langchain_community/embeddings/gpt4all.py @@ -26,7 +26,7 @@ class GPT4AllEmbeddings(BaseModel, Embeddings): n_threads: Optional[int] = None device: Optional[str] = "cpu" gpt4all_kwargs: Optional[dict] = {} - client: Any #: :meta private: + client: Any model_config = ConfigDict(protected_namespaces=()) diff --git a/libs/community/langchain_community/embeddings/gradient_ai.py b/libs/community/langchain_community/embeddings/gradient_ai.py index 697e7a30a..6badefbc9 100644 --- a/libs/community/langchain_community/embeddings/gradient_ai.py +++ b/libs/community/langchain_community/embeddings/gradient_ai.py @@ -47,7 +47,7 @@ class GradientEmbeddings(BaseModel, Embeddings): query_prompt_for_retrieval: Optional[str] = None """Query pre-prompt""" - client: Any = None #: :meta private: + client: Any = None """Gradient client.""" # LLM call kwargs @@ -161,7 +161,7 @@ async def aembed_query(self, text: str) -> List[float]: return embeddings[0] -class TinyAsyncGradientEmbeddingClient: #: :meta private: +class TinyAsyncGradientEmbeddingClient: """Deprecated, TinyAsyncGradientEmbeddingClient was removed. This class is just for backwards compatibility with older versions diff --git a/libs/community/langchain_community/embeddings/huggingface.py b/libs/community/langchain_community/embeddings/huggingface.py index 7afe57c9f..c917f5a71 100644 --- a/libs/community/langchain_community/embeddings/huggingface.py +++ b/libs/community/langchain_community/embeddings/huggingface.py @@ -44,11 +44,11 @@ class HuggingFaceEmbeddings(BaseModel, Embeddings): ) """ - client: Any = None #: :meta private: + client: Any = None model_name: str = DEFAULT_MODEL_NAME """Model name to use.""" cache_folder: Optional[str] = None - """Path to store models. + """Path to store models. Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable.""" model_kwargs: Dict[str, Any] = Field(default_factory=dict) """Keyword arguments to pass to the Sentence Transformer model, such as `device`, @@ -156,11 +156,11 @@ class HuggingFaceInstructEmbeddings(BaseModel, Embeddings): ) """ - client: Any = None #: :meta private: + client: Any = None model_name: str = DEFAULT_INSTRUCT_MODEL """Model name to use.""" cache_folder: Optional[str] = None - """Path to store models. + """Path to store models. Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable.""" model_kwargs: Dict[str, Any] = Field(default_factory=dict) """Keyword arguments to pass to the model.""" @@ -293,7 +293,7 @@ class HuggingFaceBgeEmbeddings(BaseModel, Embeddings): ) """ - client: Any = None #: :meta private: + client: Any = None model_name: str = DEFAULT_BGE_MODEL """Model name to use.""" cache_folder: Optional[str] = None diff --git a/libs/community/langchain_community/embeddings/huggingface_hub.py b/libs/community/langchain_community/embeddings/huggingface_hub.py index b1a1fac37..3b464c1c5 100644 --- a/libs/community/langchain_community/embeddings/huggingface_hub.py +++ b/libs/community/langchain_community/embeddings/huggingface_hub.py @@ -35,8 +35,8 @@ class HuggingFaceHubEmbeddings(BaseModel, Embeddings): ) """ - client: Any = None #: :meta private: - async_client: Any = None #: :meta private: + client: Any = None + async_client: Any = None model: Optional[str] = None """Model name to use.""" repo_id: Optional[str] = None diff --git a/libs/community/langchain_community/embeddings/infinity.py b/libs/community/langchain_community/embeddings/infinity.py index cc41250b5..ef2dfa11c 100644 --- a/libs/community/langchain_community/embeddings/infinity.py +++ b/libs/community/langchain_community/embeddings/infinity.py @@ -40,7 +40,7 @@ class InfinityEmbeddings(BaseModel, Embeddings): infinity_api_url: str = "http://localhost:7997" """Endpoint URL to use.""" - client: Any = None #: :meta private: + client: Any = None """Infinity client.""" # LLM call kwargs @@ -116,7 +116,7 @@ async def aembed_query(self, text: str) -> List[float]: return embeddings[0] -class TinyAsyncOpenAIInfinityEmbeddingClient: #: :meta private: +class TinyAsyncOpenAIInfinityEmbeddingClient: """Helper tool to embed Infinity. It is not a part of Langchain's stable API, diff --git a/libs/community/langchain_community/embeddings/infinity_local.py b/libs/community/langchain_community/embeddings/infinity_local.py index 22e15b017..cbe68c3e5 100644 --- a/libs/community/langchain_community/embeddings/infinity_local.py +++ b/libs/community/langchain_community/embeddings/infinity_local.py @@ -54,7 +54,7 @@ class InfinityEmbeddingsLocal(BaseModel, Embeddings): model_warmup: bool = True "Warmup the model with the max batch size." - engine: Any = None #: :meta private: + engine: Any = None """Infinity's AsyncEmbeddingEngine.""" # LLM call kwargs diff --git a/libs/community/langchain_community/embeddings/ipex_llm.py b/libs/community/langchain_community/embeddings/ipex_llm.py index 8022616f2..ba37ea088 100644 --- a/libs/community/langchain_community/embeddings/ipex_llm.py +++ b/libs/community/langchain_community/embeddings/ipex_llm.py @@ -49,7 +49,7 @@ class IpexLLMBgeEmbeddings(BaseModel, Embeddings): ) """ - client: Any = None #: :meta private: + client: Any = None model_name: str = DEFAULT_BGE_MODEL """Model name to use.""" cache_folder: Optional[str] = None diff --git a/libs/community/langchain_community/embeddings/jina.py b/libs/community/langchain_community/embeddings/jina.py index ad9ea9fd9..e020862aa 100644 --- a/libs/community/langchain_community/embeddings/jina.py +++ b/libs/community/langchain_community/embeddings/jina.py @@ -42,7 +42,7 @@ def get_bytes_str(file_path: str) -> str: class JinaEmbeddings(BaseModel, Embeddings): """Jina embedding models.""" - session: Any #: :meta private: + session: Any model_name: str = "jina-embeddings-v2-base-en" jina_api_key: Optional[SecretStr] = None diff --git a/libs/community/langchain_community/embeddings/laser.py b/libs/community/langchain_community/embeddings/laser.py index 088ffbb4d..487e551a2 100644 --- a/libs/community/langchain_community/embeddings/laser.py +++ b/libs/community/langchain_community/embeddings/laser.py @@ -35,7 +35,7 @@ class LaserEmbeddings(BaseModel, Embeddings): https://github.com/facebookresearch/flores/blob/main/flores200/README.md#languages-in-flores-200 """ - _encoder_pipeline: Any = None # : :meta private: + _encoder_pipeline: Any = None model_config = ConfigDict( extra="forbid", diff --git a/libs/community/langchain_community/embeddings/llamacpp.py b/libs/community/langchain_community/embeddings/llamacpp.py index e4ebe33b3..c7dc55e20 100644 --- a/libs/community/langchain_community/embeddings/llamacpp.py +++ b/libs/community/langchain_community/embeddings/llamacpp.py @@ -19,14 +19,14 @@ class LlamaCppEmbeddings(BaseModel, Embeddings): llama = LlamaCppEmbeddings(model_path="/path/to/model.bin") """ - client: Any = None #: :meta private: + client: Any = None model_path: str = Field(default="") n_ctx: int = Field(512, alias="n_ctx") """Token context window.""" n_parts: int = Field(-1, alias="n_parts") - """Number of parts to split the model into. + """Number of parts to split the model into. If -1, the number of parts is automatically determined.""" seed: int = Field(-1, alias="seed") @@ -45,7 +45,7 @@ class LlamaCppEmbeddings(BaseModel, Embeddings): """Force system to keep model in RAM.""" n_threads: Optional[int] = Field(None, alias="n_threads") - """Number of threads to use. If None, the number + """Number of threads to use. If None, the number of threads is automatically determined.""" n_batch: Optional[int] = Field(512, alias="n_batch") diff --git a/libs/community/langchain_community/embeddings/localai.py b/libs/community/langchain_community/embeddings/localai.py index 8c0457b39..9048abae4 100644 --- a/libs/community/langchain_community/embeddings/localai.py +++ b/libs/community/langchain_community/embeddings/localai.py @@ -141,7 +141,7 @@ class LocalAIEmbeddings(BaseModel, Embeddings): """ - client: Any = None #: :meta private: + client: Any = None model: str = "text-embedding-ada-002" deployment: str = model openai_api_version: Optional[str] = None diff --git a/libs/community/langchain_community/embeddings/naver.py b/libs/community/langchain_community/embeddings/naver.py index ce20130e5..efb4258dd 100644 --- a/libs/community/langchain_community/embeddings/naver.py +++ b/libs/community/langchain_community/embeddings/naver.py @@ -61,8 +61,8 @@ class ClovaXEmbeddings(BaseModel, Embeddings): output = embedding.embed_documents(documents) """ # noqa: E501 - client: Optional[httpx.Client] = Field(default=None) #: :meta private: - async_client: Optional[httpx.AsyncClient] = Field(default=None) #: :meta private: + client: Optional[httpx.Client] = Field(default=None) + async_client: Optional[httpx.AsyncClient] = Field(default=None) ncp_clovastudio_api_key: Optional[SecretStr] = Field(default=None, alias="api_key") """Automatically inferred from env are `NCP_CLOVASTUDIO_API_KEY` if not provided.""" diff --git a/libs/community/langchain_community/embeddings/nlpcloud.py b/libs/community/langchain_community/embeddings/nlpcloud.py index 7e13f9cbb..ab75e0ac4 100644 --- a/libs/community/langchain_community/embeddings/nlpcloud.py +++ b/libs/community/langchain_community/embeddings/nlpcloud.py @@ -20,7 +20,7 @@ class NLPCloudEmbeddings(BaseModel, Embeddings): model_name: str # Define model_name as a class attribute gpu: bool # Define gpu as a class attribute - client: Any #: :meta private: + client: Any model_config = ConfigDict(protected_namespaces=()) diff --git a/libs/community/langchain_community/embeddings/oci_generative_ai.py b/libs/community/langchain_community/embeddings/oci_generative_ai.py index 25966245c..c0aca3412 100644 --- a/libs/community/langchain_community/embeddings/oci_generative_ai.py +++ b/libs/community/langchain_community/embeddings/oci_generative_ai.py @@ -52,24 +52,24 @@ class OCIGenAIEmbeddings(BaseModel, Embeddings): ) """ - client: Any = None #: :meta private: + client: Any = None - service_models: Any = None #: :meta private: + service_models: Any = None auth_type: Optional[str] = "API_KEY" - """Authentication type, could be + """Authentication type, could be - API_KEY, - SECURITY_TOKEN, - INSTANCE_PRINCIPLE, + API_KEY, + SECURITY_TOKEN, + INSTANCE_PRINCIPLE, RESOURCE_PRINCIPLE - + If not specified, API_KEY will be used """ auth_profile: Optional[str] = "DEFAULT" """The name of the profile in ~/.oci/config - If not specified , DEFAULT will be used + If not specified , DEFAULT will be used """ auth_file_location: Optional[str] = "~/.oci/config" diff --git a/libs/community/langchain_community/embeddings/openai.py b/libs/community/langchain_community/embeddings/openai.py index a695ab72f..d482613c9 100644 --- a/libs/community/langchain_community/embeddings/openai.py +++ b/libs/community/langchain_community/embeddings/openai.py @@ -189,8 +189,8 @@ class OpenAIEmbeddings(BaseModel, Embeddings): """ - client: Any = Field(default=None, exclude=True) #: :meta private: - async_client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) + async_client: Any = Field(default=None, exclude=True) model: str = "text-embedding-ada-002" # to support Azure OpenAI Service custom deployment names deployment: Optional[str] = model @@ -199,7 +199,7 @@ class OpenAIEmbeddings(BaseModel, Embeddings): """Automatically inferred from env var `OPENAI_API_VERSION` if not provided.""" # to support Azure OpenAI Service custom endpoints openai_api_base: Optional[str] = Field(default=None, alias="base_url") - """Base URL path for API requests, leave blank if not using a proxy or service + """Base URL path for API requests, leave blank if not using a proxy or service emulator.""" # to support Azure OpenAI Service custom endpoints openai_api_type: Optional[str] = None @@ -220,21 +220,21 @@ class OpenAIEmbeddings(BaseModel, Embeddings): request_timeout: Optional[Union[float, Tuple[float, float], Any]] = Field( default=None, alias="timeout" ) - """Timeout for requests to OpenAI completion API. Can be float, httpx.Timeout or + """Timeout for requests to OpenAI completion API. Can be float, httpx.Timeout or None.""" headers: Any = None tiktoken_enabled: bool = True """Set this to False for non-OpenAI implementations of the embeddings API, e.g. the `--extensions openai` extension for `text-generation-webui`""" tiktoken_model_name: Optional[str] = None - """The model name to pass to tiktoken when using this class. - Tiktoken is used to count the number of tokens in documents to constrain - them to be under a certain limit. By default, when set to None, this will - be the same as the embedding model name. However, there are some cases - where you may want to use this Embedding class with a model name not - supported by tiktoken. This can include when using Azure embeddings or - when using one of the many model providers that expose an OpenAI-like - API but with different models. In those cases, in order to avoid erroring + """The model name to pass to tiktoken when using this class. + Tiktoken is used to count the number of tokens in documents to constrain + them to be under a certain limit. By default, when set to None, this will + be the same as the embedding model name. However, there are some cases + where you may want to use this Embedding class with a model name not + supported by tiktoken. This can include when using Azure embeddings or + when using one of the many model providers that expose an OpenAI-like + API but with different models. In those cases, in order to avoid erroring when tiktoken is called, you can specify a model name to use here.""" show_progress_bar: bool = False """Whether to show a progress bar when embedding.""" diff --git a/libs/community/langchain_community/embeddings/self_hosted_hugging_face.py b/libs/community/langchain_community/embeddings/self_hosted_hugging_face.py index d45a80249..c2d598434 100644 --- a/libs/community/langchain_community/embeddings/self_hosted_hugging_face.py +++ b/libs/community/langchain_community/embeddings/self_hosted_hugging_face.py @@ -76,7 +76,7 @@ class SelfHostedHuggingFaceEmbeddings(SelfHostedEmbeddings): hf = SelfHostedHuggingFaceEmbeddings(model_id=model_id, hardware=gpu) """ - client: Any #: :meta private: + client: Any model_id: str = DEFAULT_MODEL_NAME """Model name to use.""" model_reqs: List[str] = ["./", "sentence_transformers", "torch"] diff --git a/libs/community/langchain_community/embeddings/tensorflow_hub.py b/libs/community/langchain_community/embeddings/tensorflow_hub.py index 270c9f17c..9a98a48c2 100644 --- a/libs/community/langchain_community/embeddings/tensorflow_hub.py +++ b/libs/community/langchain_community/embeddings/tensorflow_hub.py @@ -19,7 +19,7 @@ class TensorflowHubEmbeddings(BaseModel, Embeddings): tf = TensorflowHubEmbeddings(model_url=url) """ - embed: Any = None #: :meta private: + embed: Any = None model_url: str = DEFAULT_MODEL_URL """Model name to use.""" diff --git a/libs/community/langchain_community/embeddings/vertexai.py b/libs/community/langchain_community/embeddings/vertexai.py index 06637385e..fa30b2191 100644 --- a/libs/community/langchain_community/embeddings/vertexai.py +++ b/libs/community/langchain_community/embeddings/vertexai.py @@ -29,7 +29,7 @@ class VertexAIEmbeddings(_VertexAICommon, Embeddings): """Google Cloud VertexAI embedding models.""" # Instance context - instance: Dict[str, Any] = {} #: :meta private: + instance: Dict[str, Any] = {} show_progress_bar: bool = False """Whether to show a tqdm progress bar. Must have `tqdm` installed.""" diff --git a/libs/community/langchain_community/embeddings/zhipuai.py b/libs/community/langchain_community/embeddings/zhipuai.py index 73ced5fa0..9a916af1c 100644 --- a/libs/community/langchain_community/embeddings/zhipuai.py +++ b/libs/community/langchain_community/embeddings/zhipuai.py @@ -65,7 +65,7 @@ class ZhipuAIEmbeddings(BaseModel, Embeddings): ] """ # noqa: E501 - client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) model: str = Field(default="embedding-2") """Model name""" api_key: str diff --git a/libs/community/langchain_community/llms/aleph_alpha.py b/libs/community/langchain_community/llms/aleph_alpha.py index d1cf2175e..7cbddc887 100644 --- a/libs/community/langchain_community/llms/aleph_alpha.py +++ b/libs/community/langchain_community/llms/aleph_alpha.py @@ -25,7 +25,7 @@ class AlephAlpha(LLM): aleph_alpha = AlephAlpha(aleph_alpha_api_key="my-api-key") """ - client: Any = None #: :meta private: + client: Any = None model: Optional[str] = "luminous-base" """Model name to use.""" @@ -132,33 +132,33 @@ class AlephAlpha(LLM): aleph_alpha_api_key: Optional[SecretStr] = None """API key for Aleph Alpha API.""" host: str = "https://api.aleph-alpha.com" - """The hostname of the API host. + """The hostname of the API host. The default one is "https://api.aleph-alpha.com")""" hosting: Optional[str] = None """Determines in which datacenters the request may be processed. You can either set the parameter to "aleph-alpha" or omit it (defaulting to None). - Not setting this value, or setting it to None, gives us maximal + Not setting this value, or setting it to None, gives us maximal flexibility in processing your request in our - own datacenters and on servers hosted with other providers. + own datacenters and on servers hosted with other providers. Choose this option for maximal availability. - Setting it to "aleph-alpha" allows us to only process the + Setting it to "aleph-alpha" allows us to only process the request in our own datacenters. Choose this option for maximal data privacy.""" request_timeout_seconds: int = 305 - """Client timeout that will be set for HTTP requests in the + """Client timeout that will be set for HTTP requests in the `requests` library's API calls. Server will close all requests after 300 seconds with an internal server error.""" total_retries: int = 8 - """The number of retries made in case requests fail with certain retryable + """The number of retries made in case requests fail with certain retryable status codes. If the last retry fails a corresponding exception is raised. Note, that between retries an exponential backoff is applied, starting with 0.5 s after the first retry and doubling for each retry made. So with the - default setting of 8 retries a total wait time of 63.5 s is added + default setting of 8 retries a total wait time of 63.5 s is added between the retries.""" nice: bool = False - """Setting this to True, will signal to the API that you intend to be + """Setting this to True, will signal to the API that you intend to be nice to other users by de-prioritizing your request below concurrent ones.""" diff --git a/libs/community/langchain_community/llms/anthropic.py b/libs/community/langchain_community/llms/anthropic.py index 0a6af6799..38f6f83b9 100644 --- a/libs/community/langchain_community/llms/anthropic.py +++ b/libs/community/langchain_community/llms/anthropic.py @@ -31,8 +31,8 @@ class _AnthropicCommon(BaseLanguageModel): - client: Any = None #: :meta private: - async_client: Any = None #: :meta private: + client: Any = None + async_client: Any = None model: str = Field(default="claude-2", alias="model_name") """Model name to use.""" diff --git a/libs/community/langchain_community/llms/aphrodite.py b/libs/community/langchain_community/llms/aphrodite.py index bcaeabe29..a82d4ef40 100644 --- a/libs/community/langchain_community/llms/aphrodite.py +++ b/libs/community/langchain_community/llms/aphrodite.py @@ -17,7 +17,7 @@ class Aphrodite(BaseLLM): """The number of GPUs to use for distributed execution with tensor parallelism.""" trust_remote_code: Optional[bool] = False - """Trust remote code (e.g., from HuggingFace) when downloading the model + """Trust remote code (e.g., from HuggingFace) when downloading the model and tokenizer.""" n: int = 1 @@ -30,12 +30,12 @@ class Aphrodite(BaseLLM): `use_beam_search` is True. By default, `best_of` is set to `n`.""" presence_penalty: float = 0.0 - """Float that penalizes new tokens based on whether they appear in the + """Float that penalizes new tokens based on whether they appear in the generated text so far. Values > 0 encourage the model to generate new tokens, while values < 0 encourage the model to repeat tokens.""" frequency_penalty: float = 0.0 - """Float that penalizes new tokens based on their frequency in the + """Float that penalizes new tokens based on their frequency in the generated text so far. Applied additively to the logits.""" repetition_penalty: float = 1.0 @@ -116,7 +116,7 @@ class Aphrodite(BaseLLM): are special tokens.""" ignore_eos: bool = False - """Whether to ignore the EOS token and continue generating tokens after + """Whether to ignore the EOS token and continue generating tokens after the EOS token is generated.""" max_tokens: int = 512 @@ -146,7 +146,7 @@ class Aphrodite(BaseLLM): """The data type for the model weights and activations.""" download_dir: Optional[str] = None - """Directory to download and load the weights. (Default to the default + """Directory to download and load the weights. (Default to the default cache dir of huggingface)""" quantization: Optional[str] = None @@ -156,7 +156,7 @@ class Aphrodite(BaseLLM): """Holds any model parameters valid for `aphrodite.LLM` call not explicitly specified.""" - client: Any = None #: :meta private: + client: Any = None @pre_init def validate_environment(cls, values: Dict) -> Dict: diff --git a/libs/community/langchain_community/llms/arcee.py b/libs/community/langchain_community/llms/arcee.py index 42fcef87b..d3b3e0a39 100644 --- a/libs/community/langchain_community/llms/arcee.py +++ b/libs/community/langchain_community/llms/arcee.py @@ -27,7 +27,7 @@ class Arcee(LLM): response = arcee("AI-driven music therapy") """ - _client: Optional[ArceeWrapper] = None #: :meta private: + _client: Optional[ArceeWrapper] = None """Arcee _client.""" arcee_api_key: Union[SecretStr, str, None] = None diff --git a/libs/community/langchain_community/llms/azureml_endpoint.py b/libs/community/langchain_community/llms/azureml_endpoint.py index cec2a9f25..e744031f6 100644 --- a/libs/community/langchain_community/llms/azureml_endpoint.py +++ b/libs/community/langchain_community/llms/azureml_endpoint.py @@ -35,7 +35,7 @@ def __init__( """Initialize the class.""" if not endpoint_api_key or not endpoint_url: raise ValueError( - """A key/token and REST endpoint should + """A key/token and REST endpoint should be provided to invoke the endpoint""" ) self.endpoint_url = endpoint_url @@ -89,25 +89,25 @@ class ContentFormatterBase: """ Example: .. code-block:: python - + class ContentFormatter(ContentFormatterBase): content_type = "application/json" accepts = "application/json" - + def format_request_payload( - self, - prompt: str, + self, + prompt: str, model_kwargs: Dict, api_type: AzureMLEndpointApiType, ) -> bytes: input_str = json.dumps( { - "inputs": {"input_string": [prompt]}, + "inputs": {"input_string": [prompt]}, "parameters": model_kwargs, } ) return str.encode(input_str) - + def format_response_payload( self, output: str, api_type: AzureMLEndpointApiType ) -> str: @@ -216,8 +216,8 @@ class OSSContentFormatter(GPT2ContentFormatter): def __init__(self) -> None: super().__init__() warnings.warn( - """`OSSContentFormatter` will be deprecated in the future. - Please use `GPT2ContentFormatter` instead. + """`OSSContentFormatter` will be deprecated in the future. + Please use `GPT2ContentFormatter` instead. """ ) @@ -356,8 +356,8 @@ class LlamaContentFormatter(CustomOpenAIContentFormatter): def __init__(self) -> None: super().__init__() warnings.warn( - """`LlamaContentFormatter` will be deprecated in the future. - Please use `CustomOpenAIContentFormatter` instead. + """`LlamaContentFormatter` will be deprecated in the future. + Please use `CustomOpenAIContentFormatter` instead. """ ) @@ -366,11 +366,11 @@ class AzureMLBaseEndpoint(BaseModel): """Azure ML Online Endpoint models.""" endpoint_url: str = "" - """URL of pre-existing Endpoint. Should be passed to constructor or specified as + """URL of pre-existing Endpoint. Should be passed to constructor or specified as env var `AZUREML_ENDPOINT_URL`.""" endpoint_api_type: AzureMLEndpointApiType = AzureMLEndpointApiType.dedicated - """Type of the endpoint being consumed. Possible values are `serverless` for + """Type of the endpoint being consumed. Possible values are `serverless` for pay-as-you-go and `dedicated` for dedicated endpoints. """ endpoint_api_key: SecretStr = convert_to_secret_str("") @@ -378,13 +378,13 @@ class AzureMLBaseEndpoint(BaseModel): env var `AZUREML_ENDPOINT_API_KEY`.""" deployment_name: str = "" - """Deployment Name for Endpoint. NOT REQUIRED to call endpoint. Should be passed + """Deployment Name for Endpoint. NOT REQUIRED to call endpoint. Should be passed to constructor or specified as env var `AZUREML_DEPLOYMENT_NAME`.""" timeout: int = DEFAULT_TIMEOUT """Request timeout for calls to the endpoint""" - http_client: Any = None #: :meta private: + http_client: Any = None max_retries: int = 1 diff --git a/libs/community/langchain_community/llms/bedrock.py b/libs/community/langchain_community/llms/bedrock.py index 079eb072b..8156fa304 100644 --- a/libs/community/langchain_community/llms/bedrock.py +++ b/libs/community/langchain_community/llms/bedrock.py @@ -297,7 +297,7 @@ class BedrockBase(BaseModel, ABC): model_config = ConfigDict(protected_namespaces=()) - client: Any = Field(exclude=True) #: :meta private: + client: Any = Field(exclude=True) region_name: Optional[str] = None """The aws region e.g., `us-west-2`. Fallsback to AWS_DEFAULT_REGION env variable @@ -317,7 +317,7 @@ class BedrockBase(BaseModel, ABC): provider: Optional[str] = None """The model provider, e.g., amazon, cohere, ai21, etc. When not supplied, provider - is extracted from the first part of the model_id e.g. 'amazon' in + is extracted from the first part of the model_id e.g. 'amazon' in 'amazon.titan-text-express-v1'. This value should be provided for model ids that do not have the provider in them, e.g., custom and provisioned models that have an ARN associated with them.""" diff --git a/libs/community/langchain_community/llms/clarifai.py b/libs/community/langchain_community/llms/clarifai.py index c7d6fcde6..223dfebde 100644 --- a/libs/community/langchain_community/llms/clarifai.py +++ b/libs/community/langchain_community/llms/clarifai.py @@ -42,11 +42,11 @@ class Clarifai(LLM): """Clarifai application id to use.""" user_id: Optional[str] = None """Clarifai user id to use.""" - pat: Optional[str] = Field(default=None, exclude=True) #: :meta private: + pat: Optional[str] = Field(default=None, exclude=True) """Clarifai personal access token to use.""" - token: Optional[str] = Field(default=None, exclude=True) #: :meta private: + token: Optional[str] = Field(default=None, exclude=True) """Clarifai session token to use.""" - model: Any = Field(default=None, exclude=True) #: :meta private: + model: Any = Field(default=None, exclude=True) api_base: str = "https://api.clarifai.com" model_config = ConfigDict( diff --git a/libs/community/langchain_community/llms/cohere.py b/libs/community/langchain_community/llms/cohere.py index dbe15e200..be50a9f07 100644 --- a/libs/community/langchain_community/llms/cohere.py +++ b/libs/community/langchain_community/llms/cohere.py @@ -76,8 +76,8 @@ async def _completion_with_retry(**kwargs: Any) -> Any: class BaseCohere(Serializable): """Base class for Cohere models.""" - client: Any = None #: :meta private: - async_client: Any = None #: :meta private: + client: Any = None + async_client: Any = None model: Optional[str] = Field(default=None) """Model name to use.""" diff --git a/libs/community/langchain_community/llms/ctransformers.py b/libs/community/langchain_community/llms/ctransformers.py index 612e6041d..552bcbe54 100644 --- a/libs/community/langchain_community/llms/ctransformers.py +++ b/libs/community/langchain_community/llms/ctransformers.py @@ -23,7 +23,7 @@ class CTransformers(LLM): llm = CTransformers(model="/path/to/ggml-gpt-2.bin", model_type="gpt2") """ - client: Any #: :meta private: + client: Any model: str """The path to a model file or directory or the name of a Hugging Face Hub diff --git a/libs/community/langchain_community/llms/ctranslate2.py b/libs/community/langchain_community/llms/ctranslate2.py index bc78c7e4a..0cd3e4007 100644 --- a/libs/community/langchain_community/llms/ctranslate2.py +++ b/libs/community/langchain_community/llms/ctranslate2.py @@ -41,13 +41,13 @@ class CTranslate2(BaseLLM): sampling_temperature: float = 1 """Sampling temperature to generate more random samples.""" - client: Any = None #: :meta private: + client: Any = None - tokenizer: Any = None #: :meta private: + tokenizer: Any = None ctranslate2_kwargs: Dict[str, Any] = Field(default_factory=dict) """ - Holds any model parameters valid for `ctranslate2.Generator` call not + Holds any model parameters valid for `ctranslate2.Generator` call not explicitly specified. """ diff --git a/libs/community/langchain_community/llms/deepsparse.py b/libs/community/langchain_community/llms/deepsparse.py index 6a743cd50..b6fc5ac6d 100644 --- a/libs/community/langchain_community/llms/deepsparse.py +++ b/libs/community/langchain_community/llms/deepsparse.py @@ -28,7 +28,7 @@ class DeepSparse(LLM): llm = DeepSparse(model="zoo:nlg/text_generation/codegen_mono-350m/pytorch/huggingface/bigpython_bigquery_thepile/base_quant-none") """ # noqa: E501 - pipeline: Any #: :meta private: + pipeline: Any model: str """The path to a model file or directory or the name of a SparseZoo model stub.""" diff --git a/libs/community/langchain_community/llms/google_palm.py b/libs/community/langchain_community/llms/google_palm.py index 1d1e62bf1..663790940 100644 --- a/libs/community/langchain_community/llms/google_palm.py +++ b/libs/community/langchain_community/llms/google_palm.py @@ -67,7 +67,7 @@ class GooglePalm(BaseLLM, BaseModel): Google PaLM models. """ - client: Any #: :meta private: + client: Any google_api_key: Optional[SecretStr] model_name: str = "models/text-bison-001" """Model name to use.""" diff --git a/libs/community/langchain_community/llms/gpt4all.py b/libs/community/langchain_community/llms/gpt4all.py index 85c47ac69..c8ed085e8 100644 --- a/libs/community/langchain_community/llms/gpt4all.py +++ b/libs/community/langchain_community/llms/gpt4all.py @@ -34,7 +34,7 @@ class GPT4All(LLM): """Token context window.""" n_parts: int = Field(-1, alias="n_parts") - """Number of parts to split the model into. + """Number of parts to split the model into. If -1, the number of parts is automatically determined.""" seed: int = Field(0, alias="seed") @@ -94,7 +94,7 @@ class GPT4All(LLM): device: Optional[str] = Field("cpu", alias="device") """Device name: cpu, gpu, nvidia, intel, amd or DeviceName.""" - client: Any = None #: :meta private: + client: Any = None model_config = ConfigDict( extra="forbid", diff --git a/libs/community/langchain_community/llms/gradient_ai.py b/libs/community/langchain_community/llms/gradient_ai.py index ee088808e..32cb77011 100644 --- a/libs/community/langchain_community/llms/gradient_ai.py +++ b/libs/community/langchain_community/llms/gradient_ai.py @@ -70,7 +70,7 @@ class GradientLLM(BaseLLM): gradient_api_url: str = "https://api.gradient.ai/api" """Endpoint URL to use.""" - aiosession: Optional[aiohttp.ClientSession] = None #: :meta private: + aiosession: Optional[aiohttp.ClientSession] = None """ClientSession, private, subject to change in upcoming releases.""" # LLM call kwargs diff --git a/libs/community/langchain_community/llms/huggingface_hub.py b/libs/community/langchain_community/llms/huggingface_hub.py index 95e8d8f0d..e459b97a4 100644 --- a/libs/community/langchain_community/llms/huggingface_hub.py +++ b/libs/community/langchain_community/llms/huggingface_hub.py @@ -43,13 +43,13 @@ class HuggingFaceHub(LLM): hf = HuggingFaceHub(repo_id="gpt2", huggingfacehub_api_token="my-api-key") """ - client: Any = None #: :meta private: + client: Any = None repo_id: Optional[str] = None - """Model name to use. + """Model name to use. If not provided, the default model for the chosen task will be used.""" task: Optional[str] = None """Task to call the model with. - Should be a task that returns `generated_text`, `summary_text`, + Should be a task that returns `generated_text`, `summary_text`, or `translation_text`.""" model_kwargs: Optional[dict] = None """Keyword arguments to pass to the model.""" diff --git a/libs/community/langchain_community/llms/huggingface_pipeline.py b/libs/community/langchain_community/llms/huggingface_pipeline.py index 185405645..38f30f845 100644 --- a/libs/community/langchain_community/llms/huggingface_pipeline.py +++ b/libs/community/langchain_community/llms/huggingface_pipeline.py @@ -60,7 +60,7 @@ class HuggingFacePipeline(BaseLLM): hf = HuggingFacePipeline(pipeline=pipe) """ - pipeline: Any = None #: :meta private: + pipeline: Any = None model_id: str = DEFAULT_MODEL_ID """Model name to use.""" model_kwargs: Optional[dict] = None diff --git a/libs/community/langchain_community/llms/ipex_llm.py b/libs/community/langchain_community/llms/ipex_llm.py index 0432b6aec..7967e5322 100644 --- a/libs/community/langchain_community/llms/ipex_llm.py +++ b/libs/community/langchain_community/llms/ipex_llm.py @@ -25,9 +25,9 @@ class IpexLLM(LLM): """Model name or model path to use.""" model_kwargs: Optional[dict] = None """Keyword arguments passed to the model.""" - model: Any = None #: :meta private: + model: Any = None """IpexLLM model.""" - tokenizer: Any = None #: :meta private: + tokenizer: Any = None """Huggingface tokenizer model.""" streaming: bool = True """Whether to stream the results, token by token.""" diff --git a/libs/community/langchain_community/llms/layerup_security.py b/libs/community/langchain_community/llms/layerup_security.py index c15626eff..eda6d4163 100644 --- a/libs/community/langchain_community/llms/layerup_security.py +++ b/libs/community/langchain_community/llms/layerup_security.py @@ -45,7 +45,7 @@ class LayerupSecurity(LLM): handle_response_guardrail_violation: Callable[[dict], str] = ( default_guardrail_violation_handler ) - client: Any #: :meta private: + client: Any @model_validator(mode="before") @classmethod diff --git a/libs/community/langchain_community/llms/llamacpp.py b/libs/community/langchain_community/llms/llamacpp.py index a045878fd..9e5dc87a3 100644 --- a/libs/community/langchain_community/llms/llamacpp.py +++ b/libs/community/langchain_community/llms/llamacpp.py @@ -28,7 +28,7 @@ class LlamaCpp(LLM): llm = LlamaCpp(model_path="/path/to/llama/model") """ - client: Any = None #: :meta private: + client: Any = None model_path: str """The path to the Llama model file.""" @@ -125,8 +125,8 @@ class LlamaCpp(LLM): """ grammar: Optional[Union[str, Any]] = None """ - grammar: formal grammar for constraining model outputs. For instance, the grammar - can be used to force the model to generate valid JSON or to speak exclusively in + grammar: formal grammar for constraining model outputs. For instance, the grammar + can be used to force the model to generate valid JSON or to speak exclusively in emojis. At most one of grammar_path and grammar should be passed in. """ diff --git a/libs/community/langchain_community/llms/manifest.py b/libs/community/langchain_community/llms/manifest.py index 966933d5f..f458725a1 100644 --- a/libs/community/langchain_community/llms/manifest.py +++ b/libs/community/langchain_community/llms/manifest.py @@ -9,7 +9,7 @@ class ManifestWrapper(LLM): """HazyResearch's Manifest library.""" - client: Any = None #: :meta private: + client: Any = None llm_kwargs: Optional[Dict] = None model_config = ConfigDict( diff --git a/libs/community/langchain_community/llms/mlx_pipeline.py b/libs/community/langchain_community/llms/mlx_pipeline.py index 8bc25f34a..3617c78cf 100644 --- a/libs/community/langchain_community/llms/mlx_pipeline.py +++ b/libs/community/langchain_community/llms/mlx_pipeline.py @@ -38,9 +38,9 @@ class MLXPipeline(LLM): model_id: str = DEFAULT_MODEL_ID """Model name to use.""" - model: Any = None #: :meta private: + model: Any = None """Model.""" - tokenizer: Any = None #: :meta private: + tokenizer: Any = None """Tokenizer.""" tokenizer_config: Optional[dict] = None """ diff --git a/libs/community/langchain_community/llms/nlpcloud.py b/libs/community/langchain_community/llms/nlpcloud.py index 774122a38..40b9b3593 100644 --- a/libs/community/langchain_community/llms/nlpcloud.py +++ b/libs/community/langchain_community/llms/nlpcloud.py @@ -19,7 +19,7 @@ class NLPCloud(LLM): nlpcloud = NLPCloud(model="finetuned-gpt-neox-20b") """ - client: Any = None #: :meta private: + client: Any = None model_name: str = "finetuned-gpt-neox-20b" """Model name to use.""" gpu: bool = True diff --git a/libs/community/langchain_community/llms/oci_generative_ai.py b/libs/community/langchain_community/llms/oci_generative_ai.py index c6b4dc8d6..00acd9390 100644 --- a/libs/community/langchain_community/llms/oci_generative_ai.py +++ b/libs/community/langchain_community/llms/oci_generative_ai.py @@ -61,14 +61,14 @@ class OCIAuthType(Enum): class OCIGenAIBase(BaseModel, ABC): """Base class for OCI GenAI models""" - client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) auth_type: Optional[str] = "API_KEY" - """Authentication type, could be - - API_KEY, - SECURITY_TOKEN, - INSTANCE_PRINCIPAL, + """Authentication type, could be + + API_KEY, + SECURITY_TOKEN, + INSTANCE_PRINCIPAL, RESOURCE_PRINCIPAL If not specified, API_KEY will be used @@ -76,7 +76,7 @@ class OCIGenAIBase(BaseModel, ABC): auth_profile: Optional[str] = "DEFAULT" """The name of the profile in ~/.oci/config - If not specified , DEFAULT will be used + If not specified , DEFAULT will be used """ auth_file_location: Optional[str] = "~/.oci/config" @@ -88,7 +88,7 @@ class OCIGenAIBase(BaseModel, ABC): """Id of the model to call, e.g., cohere.command""" provider: Optional[str] = None - """Provider name of the model. Default to None, + """Provider name of the model. Default to None, will try to be derived from the model_id otherwise, requires user input """ @@ -181,7 +181,7 @@ def make_security_token_signer( except Exception as e: raise ValueError( """Could not authenticate with OCI client. - If INSTANCE_PRINCIPAL or RESOURCE_PRINCIPAL is used, + If INSTANCE_PRINCIPAL or RESOURCE_PRINCIPAL is used, please check the specified auth_profile, auth_file_location and auth_type are valid.""", e, diff --git a/libs/community/langchain_community/llms/openai.py b/libs/community/langchain_community/llms/openai.py index 41ef199b5..804364d60 100644 --- a/libs/community/langchain_community/llms/openai.py +++ b/libs/community/langchain_community/llms/openai.py @@ -178,8 +178,8 @@ def lc_attributes(self) -> Dict[str, Any]: def is_lc_serializable(cls) -> bool: return True - client: Any = Field(default=None, exclude=True) #: :meta private: - async_client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) + async_client: Any = Field(default=None, exclude=True) model_name: str = Field(default="gpt-3.5-turbo-instruct", alias="model") """Model name to use.""" temperature: float = 0.7 @@ -206,7 +206,7 @@ def is_lc_serializable(cls) -> bool: openai_api_key: Optional[str] = Field(default=None, alias="api_key") """Automatically inferred from env var `OPENAI_API_KEY` if not provided.""" openai_api_base: Optional[str] = Field(default=None, alias="base_url") - """Base URL path for API requests, leave blank if not using a proxy or service + """Base URL path for API requests, leave blank if not using a proxy or service emulator.""" openai_organization: Optional[str] = Field(default=None, alias="organization") """Automatically inferred from env var `OPENAI_ORG_ID` if not provided.""" @@ -217,7 +217,7 @@ def is_lc_serializable(cls) -> bool: request_timeout: Union[float, Tuple[float, float], Any, None] = Field( default=None, alias="timeout" ) - """Timeout for requests to OpenAI completion API. Can be float, httpx.Timeout or + """Timeout for requests to OpenAI completion API. Can be float, httpx.Timeout or None.""" logit_bias: Optional[Dict[str, float]] = Field(default_factory=dict) """Adjust the probability of specific tokens being generated.""" @@ -230,14 +230,14 @@ def is_lc_serializable(cls) -> bool: disallowed_special: Union[Literal["all"], Collection[str]] = "all" """Set of special tokens that are not allowed。""" tiktoken_model_name: Optional[str] = None - """The model name to pass to tiktoken when using this class. - Tiktoken is used to count the number of tokens in documents to constrain - them to be under a certain limit. By default, when set to None, this will - be the same as the embedding model name. However, there are some cases - where you may want to use this Embedding class with a model name not - supported by tiktoken. This can include when using Azure embeddings or - when using one of the many model providers that expose an OpenAI-like - API but with different models. In those cases, in order to avoid erroring + """The model name to pass to tiktoken when using this class. + Tiktoken is used to count the number of tokens in documents to constrain + them to be under a certain limit. By default, when set to None, this will + be the same as the embedding model name. However, there are some cases + where you may want to use this Embedding class with a model name not + supported by tiktoken. This can include when using Azure embeddings or + when using one of the many model providers that expose an OpenAI-like + API but with different models. In those cases, in order to avoid erroring when tiktoken is called, you can specify a model name to use here.""" default_headers: Union[Mapping[str, str], None] = None default_query: Union[Mapping[str, object], None] = None @@ -785,7 +785,7 @@ class AzureOpenAI(BaseOpenAI): Example: `https://example-resource.azure.openai.com/` """ deployment_name: Union[str, None] = Field(default=None, alias="azure_deployment") - """A model deployment. + """A model deployment. If given sets the base client URL to include `/deployments/{azure_deployment}`. Note: this means you won't be able to use non-deployment endpoints. @@ -799,7 +799,7 @@ class AzureOpenAI(BaseOpenAI): Automatically inferred from env var `AZURE_OPENAI_AD_TOKEN` if not provided. - For more: + For more: https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id. """ azure_ad_token_provider: Union[Callable[[], str], None] = None @@ -816,7 +816,7 @@ class AzureOpenAI(BaseOpenAI): openai_api_type: str = "" """Legacy, for openai<1.0.0 support.""" validate_base_url: bool = True - """For backwards compatibility. If legacy val openai_api_base is passed in, try to + """For backwards compatibility. If legacy val openai_api_base is passed in, try to infer if it is a base_url or azure_endpoint and update accordingly. """ @@ -1000,8 +1000,8 @@ class OpenAIChat(BaseLLM): openaichat = OpenAIChat(model_name="gpt-3.5-turbo") """ - client: Any = Field(default=None, exclude=True) #: :meta private: - async_client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) + async_client: Any = Field(default=None, exclude=True) model_name: str = "gpt-3.5-turbo" """Model name to use.""" model_kwargs: Dict[str, Any] = Field(default_factory=dict) @@ -1012,7 +1012,7 @@ class OpenAIChat(BaseLLM): openai_api_key: Optional[str] = Field(default=None, alias="api_key") """Automatically inferred from env var `OPENAI_API_KEY` if not provided.""" openai_api_base: Optional[str] = Field(default=None, alias="base_url") - """Base URL path for API requests, leave blank if not using a proxy or service + """Base URL path for API requests, leave blank if not using a proxy or service emulator.""" # to support explicit proxy for OpenAI openai_proxy: Optional[str] = None diff --git a/libs/community/langchain_community/llms/outlines.py b/libs/community/langchain_community/llms/outlines.py index 25be8dcb4..2382e36ec 100644 --- a/libs/community/langchain_community/llms/outlines.py +++ b/libs/community/langchain_community/llms/outlines.py @@ -16,17 +16,17 @@ class Outlines(LLM): """LLM wrapper for the Outlines library.""" - client: Any = None # :meta private: + client: Any = None model: str """Identifier for the model to use with Outlines. - + The model identifier should be a string specifying: - A Hugging Face model name (e.g., "meta-llama/Llama-2-7b-chat-hf") - A local path to a model - For GGUF models, the format is "repo_id/file_name" (e.g., "TheBloke/Llama-2-7B-Chat-GGUF/llama-2-7b-chat.Q4_K_M.gguf") - + Examples: - "TheBloke/Llama-2-7B-Chat-GGUF/llama-2-7b-chat.Q4_K_M.gguf" - "meta-llama/Llama-2-7b-chat-hf" @@ -36,14 +36,14 @@ class Outlines(LLM): "llamacpp", "transformers", "transformers_vision", "vllm", "mlxlm" ] = "transformers" """Specifies the backend to use for the model. - + Supported backends are: - "llamacpp": For GGUF models using llama.cpp - "transformers": For Hugging Face Transformers models (default) - "transformers_vision": For vision-language models (e.g., LLaVA) - "vllm": For models using the vLLM library - "mlxlm": For models using the MLX framework - + Note: Ensure you have the necessary dependencies installed for the chosen backend. The system will attempt to import required packages and may raise an ImportError if they are not available. @@ -60,35 +60,35 @@ class Outlines(LLM): regex: Optional[str] = None r"""Regular expression for structured generation. - + If provided, Outlines will guarantee that the generated text matches this regex. This can be useful for generating structured outputs like IP addresses, dates, etc. - + Example: (valid IP address) regex = r"((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)" - + Note: Computing the regex index can take some time, so it's recommended to reuse the same regex for multiple generations if possible. - + For more details, see: https://dottxt-ai.github.io/outlines/reference/generation/regex/ """ type_constraints: Optional[Union[type, str]] = None """Type constraints for structured generation. - + Restricts the output to valid Python types. Supported types include: int, float, bool, datetime.date, datetime.time, datetime.datetime. - + Example: type_constraints = int - + For more details, see: https://dottxt-ai.github.io/outlines/reference/generation/format/ """ json_schema: Optional[Union[BaseModel, Dict, Callable]] = None """Pydantic model, JSON Schema, or callable (function signature) for structured JSON generation. - + Outlines can generate JSON output that follows a specified structure, which is useful for: 1. Parsing the answer (e.g., with Pydantic), storing it, or returning it to a user. @@ -106,13 +106,13 @@ class Outlines(LLM): grammar: Optional[str] = None """Context-free grammar for structured generation. - + If provided, Outlines will generate text that adheres to the specified grammar. The grammar should be defined in EBNF format. - + This can be useful for generating structured outputs like mathematical expressions, programming languages, or custom domain-specific languages. - + Example: grammar = ''' ?start: expression @@ -121,10 +121,10 @@ class Outlines(LLM): ?factor: NUMBER | "-" factor | "(" expression ")" %import common.NUMBER ''' - + Note: Grammar-based generation is currently experimental and may have performance limitations. It uses greedy generation to mitigate these issues. - + For more details and examples, see: https://dottxt-ai.github.io/outlines/reference/generation/cfg/ """ @@ -134,7 +134,7 @@ class Outlines(LLM): model_kwargs: Dict[str, Any] = Field(default_factory=dict) """Additional parameters to pass to the underlying model. - + Example: model_kwargs = {"temperature": 0.8, "seed": 42} """ diff --git a/libs/community/langchain_community/llms/predictionguard.py b/libs/community/langchain_community/llms/predictionguard.py index 01edbfa16..1d0cfd85b 100644 --- a/libs/community/langchain_community/llms/predictionguard.py +++ b/libs/community/langchain_community/llms/predictionguard.py @@ -33,7 +33,7 @@ class PredictionGuard(LLM): ) """ - client: Any = None #: :meta private: + client: Any = None model: Optional[str] = "Hermes-3-Llama-3.1-8B" """Model name to use.""" diff --git a/libs/community/langchain_community/llms/rwkv.py b/libs/community/langchain_community/llms/rwkv.py index 9273467c7..081fbf279 100644 --- a/libs/community/langchain_community/llms/rwkv.py +++ b/libs/community/langchain_community/llms/rwkv.py @@ -64,15 +64,15 @@ class RWKV(LLM, BaseModel): max_tokens_per_generation: int = 256 """Maximum number of tokens to generate.""" - client: Any = None #: :meta private: + client: Any = None - tokenizer: Any = None #: :meta private: + tokenizer: Any = None - pipeline: Any = None #: :meta private: + pipeline: Any = None - model_tokens: Any = None #: :meta private: + model_tokens: Any = None - model_state: Any = None #: :meta private: + model_state: Any = None model_config = ConfigDict( extra="forbid", diff --git a/libs/community/langchain_community/llms/sambanova.py b/libs/community/langchain_community/llms/sambanova.py index 18f281026..bfdaea1d1 100644 --- a/libs/community/langchain_community/llms/sambanova.py +++ b/libs/community/langchain_community/llms/sambanova.py @@ -195,8 +195,10 @@ def _get_tuning_params(self, stop: Optional[List[str]] = None) -> Dict[str, Any] Get the tuning parameters to use when calling the LLM. Args: - stop: Stop words to use when generating. Model output is cut off at the - first occurrence of any of the stop substrings. + stop: Stop words to use when generating. + + Model output is cut off at the first occurrence of any of these + substrings. Returns: The tuning parameters in the format required by api to use diff --git a/libs/community/langchain_community/llms/self_hosted.py b/libs/community/langchain_community/llms/self_hosted.py index 700986857..e77c44783 100644 --- a/libs/community/langchain_community/llms/self_hosted.py +++ b/libs/community/langchain_community/llms/self_hosted.py @@ -126,9 +126,9 @@ def inference_fn(pipeline, prompt, stop = None): ) """ - pipeline_ref: Any = None #: :meta private: - client: Any = None #: :meta private: - inference_fn: Callable = _generate_text #: :meta private: + pipeline_ref: Any = None + client: Any = None + inference_fn: Callable = _generate_text """Inference function to send to the remote hardware.""" hardware: Any = None """Remote hardware to send the inference function to.""" @@ -140,7 +140,7 @@ def inference_fn(pipeline, prompt, stop = None): """Requirements to install on hardware to inference the model.""" allow_dangerous_deserialization: bool = False - """Allow deserialization using pickle which can be dangerous if + """Allow deserialization using pickle which can be dangerous if loading compromised data. """ diff --git a/libs/community/langchain_community/llms/self_hosted_hugging_face.py b/libs/community/langchain_community/llms/self_hosted_hugging_face.py index e43ca9e31..4263b71bc 100644 --- a/libs/community/langchain_community/llms/self_hosted_hugging_face.py +++ b/libs/community/langchain_community/llms/self_hosted_hugging_face.py @@ -165,7 +165,7 @@ def get_pipeline(): """Requirements to install on hardware to inference the model.""" model_load_fn: Callable = _load_transformer """Function to load the model remotely on the server.""" - inference_fn: Callable = _generate_text #: :meta private: + inference_fn: Callable = _generate_text """Inference function to send to the remote hardware.""" model_config = ConfigDict( diff --git a/libs/community/langchain_community/llms/sparkllm.py b/libs/community/langchain_community/llms/sparkllm.py index 8f0ead4d2..136783083 100644 --- a/libs/community/langchain_community/llms/sparkllm.py +++ b/libs/community/langchain_community/llms/sparkllm.py @@ -112,18 +112,18 @@ class SparkLLM(LLM): """ # noqa: E501 - client: Any = None #: :meta private: + client: Any = None spark_app_id: Optional[str] = Field(default=None, alias="app_id") - """Automatically inferred from env var `IFLYTEK_SPARK_APP_ID` + """Automatically inferred from env var `IFLYTEK_SPARK_APP_ID` if not provided.""" spark_api_key: Optional[str] = Field(default=None, alias="api_key") - """IFLYTEK SPARK API KEY. If not passed in will be read from + """IFLYTEK SPARK API KEY. If not passed in will be read from env var IFLYTEK_SPARK_API_KEY.""" spark_api_secret: Optional[str] = Field(default=None, alias="api_secret") - """IFLYTEK SPARK API SECRET. If not passed in will be read from + """IFLYTEK SPARK API SECRET. If not passed in will be read from env var IFLYTEK_SPARK_API_SECRET.""" spark_api_url: Optional[str] = Field(default=None, alias="api_url") - """Base URL path for API requests, leave blank if not using a proxy or service + """Base URL path for API requests, leave blank if not using a proxy or service emulator.""" spark_llm_domain: Optional[str] = Field(default=None, alias="model") """Model name to use.""" diff --git a/libs/community/langchain_community/llms/tongyi.py b/libs/community/langchain_community/llms/tongyi.py index ade4d502a..a6af4b87d 100644 --- a/libs/community/langchain_community/llms/tongyi.py +++ b/libs/community/langchain_community/llms/tongyi.py @@ -239,7 +239,7 @@ class Tongyi(BaseLLM): def lc_secrets(self) -> Dict[str, str]: return {"dashscope_api_key": "DASHSCOPE_API_KEY"} - client: Any = None #: :meta private: + client: Any = None model_name: str = Field(default="qwen-plus", alias="model") """Model name to use.""" diff --git a/libs/community/langchain_community/llms/vertexai.py b/libs/community/langchain_community/llms/vertexai.py index 74ec9374a..eeee26189 100644 --- a/libs/community/langchain_community/llms/vertexai.py +++ b/libs/community/langchain_community/llms/vertexai.py @@ -125,8 +125,8 @@ def _get_task_executor(cls, request_parallelism: int = 5) -> Executor: class _VertexAICommon(_VertexAIBase): - client: "_LanguageModel" = None #: :meta private: - client_preview: "_LanguageModel" = None #: :meta private: + client: "_LanguageModel" = None + client_preview: "_LanguageModel" = None model_name: str "Underlying model name." temperature: float = 0.0 @@ -401,12 +401,8 @@ def _stream( class VertexAIModelGarden(_VertexAIBase, BaseLLM): """Vertex AI Model Garden large language models.""" - client: "PredictionServiceClient" = ( - None #: :meta private: # type: ignore[assignment] - ) - async_client: "PredictionServiceAsyncClient" = ( - None #: :meta private: # type: ignore[assignment] - ) + client: "PredictionServiceClient" = None + async_client: "PredictionServiceAsyncClient" = None endpoint_id: str "A name of an endpoint where the model has been deployed." allowed_model_args: Optional[List[str]] = None diff --git a/libs/community/langchain_community/llms/vllm.py b/libs/community/langchain_community/llms/vllm.py index 66a0f1775..c2018ba0a 100644 --- a/libs/community/langchain_community/llms/vllm.py +++ b/libs/community/langchain_community/llms/vllm.py @@ -20,7 +20,7 @@ class VLLM(BaseLLM): """The number of GPUs to use for distributed execution with tensor parallelism.""" trust_remote_code: Optional[bool] = False - """Trust remote code (e.g., from HuggingFace) when downloading the model + """Trust remote code (e.g., from HuggingFace) when downloading the model and tokenizer.""" n: int = 1 @@ -30,11 +30,11 @@ class VLLM(BaseLLM): """Number of output sequences that are generated from the prompt.""" presence_penalty: float = 0.0 - """Float that penalizes new tokens based on whether they appear in the + """Float that penalizes new tokens based on whether they appear in the generated text so far""" frequency_penalty: float = 0.0 - """Float that penalizes new tokens based on their frequency in the + """Float that penalizes new tokens based on their frequency in the generated text so far""" temperature: float = 1.0 @@ -53,7 +53,7 @@ class VLLM(BaseLLM): """List of strings that stop the generation when they are generated.""" ignore_eos: bool = False - """Whether to ignore the EOS token and continue generating tokens after + """Whether to ignore the EOS token and continue generating tokens after the EOS token is generated.""" max_new_tokens: int = 512 @@ -66,13 +66,13 @@ class VLLM(BaseLLM): """The data type for the model weights and activations.""" download_dir: Optional[str] = None - """Directory to download and load the weights. (Default to the default + """Directory to download and load the weights. (Default to the default cache dir of huggingface)""" vllm_kwargs: Dict[str, Any] = Field(default_factory=dict) """Holds any model parameters valid for `vllm.LLM` call not explicitly specified.""" - client: Any = None #: :meta private: + client: Any = None @pre_init def validate_environment(cls, values: Dict) -> Dict: diff --git a/libs/community/langchain_community/llms/weight_only_quantization.py b/libs/community/langchain_community/llms/weight_only_quantization.py index 916734414..69e238f3d 100644 --- a/libs/community/langchain_community/llms/weight_only_quantization.py +++ b/libs/community/langchain_community/llms/weight_only_quantization.py @@ -62,7 +62,7 @@ class WeightOnlyQuantPipeline(LLM): hf = WeightOnlyQuantPipeline(pipeline=pipe) """ - pipeline: Any = None #: :meta private: + pipeline: Any = None model_id: str = DEFAULT_MODEL_ID """Model name or local path to use.""" diff --git a/libs/community/langchain_community/llms/writer.py b/libs/community/langchain_community/llms/writer.py index e68909d06..14fb958cc 100644 --- a/libs/community/langchain_community/llms/writer.py +++ b/libs/community/langchain_community/llms/writer.py @@ -31,8 +31,8 @@ class Writer(LLM): ) """ - client: Any = Field(default=None, exclude=True) #: :meta private: - async_client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = Field(default=None, exclude=True) + async_client: Any = Field(default=None, exclude=True) api_key: Optional[SecretStr] = Field(default=None) """Writer API key.""" @@ -44,17 +44,17 @@ class Writer(LLM): """The maximum number of tokens that the model can generate in the response.""" temperature: Optional[float] = 0.7 - """Controls the randomness of the model's outputs. Higher values lead to more + """Controls the randomness of the model's outputs. Higher values lead to more random outputs, while lower values make the model more deterministic.""" top_p: Optional[float] = None """Used to control the nucleus sampling, where only the most probable tokens - with a cumulative probability of top_p are considered for sampling, providing + with a cumulative probability of top_p are considered for sampling, providing a way to fine-tune the randomness of predictions.""" stop: Optional[List[str]] = None """Specifies stopping conditions for the model's output generation. This can - be an array of strings or a single string that the model will look for as a + be an array of strings or a single string that the model will look for as a signal to stop generating further tokens.""" best_of: Optional[int] = None diff --git a/libs/community/langchain_community/memory/kg.py b/libs/community/langchain_community/memory/kg.py index 149e61451..6a1be87c2 100644 --- a/libs/community/langchain_community/memory/kg.py +++ b/libs/community/langchain_community/memory/kg.py @@ -39,7 +39,7 @@ class ConversationKGMemory(BaseChatMemory): llm: BaseLanguageModel summary_message_cls: Type[BaseMessage] = SystemMessage """Number of previous utterances to include in the context.""" - memory_key: str = "history" #: :meta private: + memory_key: str = "history" def load_memory_variables(self, inputs: Dict[str, Any]) -> Dict[str, Any]: """Return history buffer.""" @@ -65,10 +65,7 @@ def load_memory_variables(self, inputs: Dict[str, Any]) -> Dict[str, Any]: @property def memory_variables(self) -> List[str]: - """Will always return list of memory variables. - - :meta private: - """ + """Will always return list of memory variables.""" return [self.memory_key] def _get_prompt_input_key(self, inputs: Dict[str, Any]) -> str: diff --git a/libs/community/langchain_community/retrievers/arcee.py b/libs/community/langchain_community/retrievers/arcee.py index ebdc8301c..60854563f 100644 --- a/libs/community/langchain_community/retrievers/arcee.py +++ b/libs/community/langchain_community/retrievers/arcee.py @@ -28,7 +28,7 @@ class ArceeRetriever(BaseRetriever): documents = retriever.invoke("AI-driven music therapy") """ - _client: Optional[ArceeWrapper] = None #: :meta private: + _client: Optional[ArceeWrapper] = None """Arcee client.""" arcee_api_key: SecretStr diff --git a/libs/community/langchain_community/retrievers/google_cloud_documentai_warehouse.py b/libs/community/langchain_community/retrievers/google_cloud_documentai_warehouse.py index 869602229..8a238fda3 100644 --- a/libs/community/langchain_community/retrievers/google_cloud_documentai_warehouse.py +++ b/libs/community/langchain_community/retrievers/google_cloud_documentai_warehouse.py @@ -45,7 +45,7 @@ class GoogleDocumentAIWarehouseRetriever(BaseRetriever): If nothing is provided, all documents in the project will be searched.""" qa_size_limit: int = 5 """The limit on the number of documents returned.""" - client: "DocumentServiceClient" = None #: :meta private: + client: "DocumentServiceClient" = None @pre_init def validate_environment(cls, values: Dict) -> Dict: diff --git a/libs/community/langchain_community/retrievers/thirdai_neuraldb.py b/libs/community/langchain_community/retrievers/thirdai_neuraldb.py index 2fde6d73d..b56abef4f 100644 --- a/libs/community/langchain_community/retrievers/thirdai_neuraldb.py +++ b/libs/community/langchain_community/retrievers/thirdai_neuraldb.py @@ -18,7 +18,7 @@ class NeuralDBRetriever(BaseRetriever): thirdai_key: SecretStr """ThirdAI API Key""" - db: Any = None #: :meta private: + db: Any = None """NeuralDB instance""" model_config = ConfigDict( diff --git a/libs/community/langchain_community/tools/azure_ai_services/document_intelligence.py b/libs/community/langchain_community/tools/azure_ai_services/document_intelligence.py index cd0ac2501..e685140c1 100644 --- a/libs/community/langchain_community/tools/azure_ai_services/document_intelligence.py +++ b/libs/community/langchain_community/tools/azure_ai_services/document_intelligence.py @@ -22,9 +22,9 @@ class AzureAiServicesDocumentIntelligenceTool(BaseTool): https://learn.microsoft.com/en-us/azure/ai-services/document-intelligence/quickstarts/get-started-sdks-rest-api?view=doc-intel-4.0.0&pivots=programming-language-python """ - azure_ai_services_key: str = "" #: :meta private: - azure_ai_services_endpoint: str = "" #: :meta private: - doc_analysis_client: Any #: :meta private: + azure_ai_services_key: str = "" + azure_ai_services_endpoint: str = "" + doc_analysis_client: Any name: str = "azure_ai_services_document_intelligence" description: str = ( diff --git a/libs/community/langchain_community/tools/azure_ai_services/image_analysis.py b/libs/community/langchain_community/tools/azure_ai_services/image_analysis.py index c3292cff6..07173325a 100644 --- a/libs/community/langchain_community/tools/azure_ai_services/image_analysis.py +++ b/libs/community/langchain_community/tools/azure_ai_services/image_analysis.py @@ -34,10 +34,10 @@ class AzureAiServicesImageAnalysisTool(BaseTool): including its purpose and expected input. """ - azure_ai_services_key: Optional[str] = None #: :meta private: - azure_ai_services_endpoint: Optional[str] = None #: :meta private: + azure_ai_services_key: Optional[str] = None + azure_ai_services_endpoint: Optional[str] = None visual_features: Any = None - image_analysis_client: Any = None #: :meta private: + image_analysis_client: Any = None name: str = "azure_ai_services_image_analysis" description: str = ( diff --git a/libs/community/langchain_community/tools/azure_ai_services/speech_to_text.py b/libs/community/langchain_community/tools/azure_ai_services/speech_to_text.py index 15e08d272..5a6b8486a 100644 --- a/libs/community/langchain_community/tools/azure_ai_services/speech_to_text.py +++ b/libs/community/langchain_community/tools/azure_ai_services/speech_to_text.py @@ -24,10 +24,10 @@ class AzureAiServicesSpeechToTextTool(BaseTool): https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-speech-to-text?pivots=programming-language-python """ - azure_ai_services_key: str = "" #: :meta private: - azure_ai_services_region: str = "" #: :meta private: - speech_language: str = "en-US" #: :meta private: - speech_config: Any #: :meta private: + azure_ai_services_key: str = "" + azure_ai_services_region: str = "" + speech_language: str = "en-US" + speech_config: Any name: str = "azure_ai_services_speech_to_text" description: str = ( diff --git a/libs/community/langchain_community/tools/azure_ai_services/text_analytics_for_health.py b/libs/community/langchain_community/tools/azure_ai_services/text_analytics_for_health.py index 6df15788f..3b8a79df2 100644 --- a/libs/community/langchain_community/tools/azure_ai_services/text_analytics_for_health.py +++ b/libs/community/langchain_community/tools/azure_ai_services/text_analytics_for_health.py @@ -18,9 +18,9 @@ class AzureAiServicesTextAnalyticsForHealthTool(BaseTool): https://learn.microsoft.com/en-us/azure/ai-services/language-service/text-analytics-for-health/quickstart?pivots=programming-language-python """ - azure_ai_services_key: str = "" #: :meta private: - azure_ai_services_endpoint: str = "" #: :meta private: - text_analytics_client: Any #: :meta private: + azure_ai_services_key: str = "" + azure_ai_services_endpoint: str = "" + text_analytics_client: Any name: str = "azure_ai_services_text_analytics_for_health" description: str = ( diff --git a/libs/community/langchain_community/tools/azure_ai_services/text_to_speech.py b/libs/community/langchain_community/tools/azure_ai_services/text_to_speech.py index 1291e2dac..f12c43243 100644 --- a/libs/community/langchain_community/tools/azure_ai_services/text_to_speech.py +++ b/libs/community/langchain_community/tools/azure_ai_services/text_to_speech.py @@ -26,10 +26,10 @@ class AzureAiServicesTextToSpeechTool(BaseTool): ) return_direct: bool = True - azure_ai_services_key: str = "" #: :meta private: - azure_ai_services_region: str = "" #: :meta private: - speech_language: str = "en-US" #: :meta private: - speech_config: Any #: :meta private: + azure_ai_services_key: str = "" + azure_ai_services_region: str = "" + speech_language: str = "en-US" + speech_config: Any @model_validator(mode="before") @classmethod diff --git a/libs/community/langchain_community/tools/azure_cognitive_services/form_recognizer.py b/libs/community/langchain_community/tools/azure_cognitive_services/form_recognizer.py index 937b1fc79..372fbe64e 100644 --- a/libs/community/langchain_community/tools/azure_cognitive_services/form_recognizer.py +++ b/libs/community/langchain_community/tools/azure_cognitive_services/form_recognizer.py @@ -22,9 +22,9 @@ class AzureCogsFormRecognizerTool(BaseTool): https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/quickstarts/get-started-sdks-rest-api?view=form-recog-3.0.0&pivots=programming-language-python """ - azure_cogs_key: str = "" #: :meta private: - azure_cogs_endpoint: str = "" #: :meta private: - doc_analysis_client: Any #: :meta private: + azure_cogs_key: str = "" + azure_cogs_endpoint: str = "" + doc_analysis_client: Any name: str = "azure_cognitive_services_form_recognizer" description: str = ( diff --git a/libs/community/langchain_community/tools/azure_cognitive_services/image_analysis.py b/libs/community/langchain_community/tools/azure_cognitive_services/image_analysis.py index ce076243a..c0d456503 100644 --- a/libs/community/langchain_community/tools/azure_cognitive_services/image_analysis.py +++ b/libs/community/langchain_community/tools/azure_cognitive_services/image_analysis.py @@ -22,10 +22,10 @@ class AzureCogsImageAnalysisTool(BaseTool): https://learn.microsoft.com/en-us/azure/cognitive-services/computer-vision/quickstarts-sdk/image-analysis-client-library-40 """ - azure_cogs_key: str = "" #: :meta private: - azure_cogs_endpoint: str = "" #: :meta private: - vision_service: Any #: :meta private: - analysis_options: Any #: :meta private: + azure_cogs_key: str = "" + azure_cogs_endpoint: str = "" + vision_service: Any + analysis_options: Any name: str = "azure_cognitive_services_image_analysis" description: str = ( diff --git a/libs/community/langchain_community/tools/azure_cognitive_services/speech2text.py b/libs/community/langchain_community/tools/azure_cognitive_services/speech2text.py index 125c910df..20b92e6fd 100644 --- a/libs/community/langchain_community/tools/azure_cognitive_services/speech2text.py +++ b/libs/community/langchain_community/tools/azure_cognitive_services/speech2text.py @@ -24,10 +24,10 @@ class AzureCogsSpeech2TextTool(BaseTool): https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-speech-to-text?pivots=programming-language-python """ - azure_cogs_key: str = "" #: :meta private: - azure_cogs_region: str = "" #: :meta private: - speech_language: str = "en-US" #: :meta private: - speech_config: Any #: :meta private: + azure_cogs_key: str = "" + azure_cogs_region: str = "" + speech_language: str = "en-US" + speech_config: Any name: str = "azure_cognitive_services_speech2text" description: str = ( diff --git a/libs/community/langchain_community/tools/azure_cognitive_services/text2speech.py b/libs/community/langchain_community/tools/azure_cognitive_services/text2speech.py index 343653fe9..75148b63a 100644 --- a/libs/community/langchain_community/tools/azure_cognitive_services/text2speech.py +++ b/libs/community/langchain_community/tools/azure_cognitive_services/text2speech.py @@ -19,10 +19,10 @@ class AzureCogsText2SpeechTool(BaseTool): https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/get-started-text-to-speech?pivots=programming-language-python """ - azure_cogs_key: str = "" #: :meta private: - azure_cogs_region: str = "" #: :meta private: - speech_language: str = "en-US" #: :meta private: - speech_config: Any #: :meta private: + azure_cogs_key: str = "" + azure_cogs_region: str = "" + speech_language: str = "en-US" + speech_config: Any name: str = "azure_cognitive_services_text2speech" description: str = ( diff --git a/libs/community/langchain_community/tools/azure_cognitive_services/text_analytics_health.py b/libs/community/langchain_community/tools/azure_cognitive_services/text_analytics_health.py index 26864a838..6a086c5a2 100644 --- a/libs/community/langchain_community/tools/azure_cognitive_services/text_analytics_health.py +++ b/libs/community/langchain_community/tools/azure_cognitive_services/text_analytics_health.py @@ -18,9 +18,9 @@ class AzureCogsTextAnalyticsHealthTool(BaseTool): https://learn.microsoft.com/en-us/azure/ai-services/language-service/text-analytics-for-health/quickstart?tabs=windows&pivots=programming-language-python """ - azure_cogs_key: str = "" #: :meta private: - azure_cogs_endpoint: str = "" #: :meta private: - text_analytics_client: Any #: :meta private: + azure_cogs_key: str = "" + azure_cogs_endpoint: str = "" + text_analytics_client: Any name: str = "azure_cognitive_services_text_analyics_health" description: str = ( diff --git a/libs/community/langchain_community/utilities/arxiv.py b/libs/community/langchain_community/utilities/arxiv.py index 5ed5c7636..e07801ac7 100644 --- a/libs/community/langchain_community/utilities/arxiv.py +++ b/libs/community/langchain_community/utilities/arxiv.py @@ -52,8 +52,8 @@ class ArxivAPIWrapper(BaseModel): arxiv.run("tree of thought llm") """ - arxiv_search: Any #: :meta private: - arxiv_exceptions: Any # :meta private: + arxiv_search: Any + arxiv_exceptions: Any top_k_results: int = 3 ARXIV_MAX_QUERY_LENGTH: int = 300 continue_on_failure: bool = False diff --git a/libs/community/langchain_community/utilities/asknews.py b/libs/community/langchain_community/utilities/asknews.py index 5a3eaa234..da8e2a9bb 100644 --- a/libs/community/langchain_community/utilities/asknews.py +++ b/libs/community/langchain_community/utilities/asknews.py @@ -12,8 +12,8 @@ class AskNewsAPIWrapper(BaseModel): """Wrapper for AskNews API.""" - asknews_sync: Any = None #: :meta private: - asknews_async: Any = None #: :meta private: + asknews_sync: Any = None + asknews_async: Any = None asknews_client_id: Optional[str] = None """Client ID for the AskNews API.""" asknews_client_secret: Optional[str] = None diff --git a/libs/community/langchain_community/utilities/awslambda.py b/libs/community/langchain_community/utilities/awslambda.py index 72e584d4c..d978c1bef 100644 --- a/libs/community/langchain_community/utilities/awslambda.py +++ b/libs/community/langchain_community/utilities/awslambda.py @@ -21,7 +21,7 @@ class LambdaWrapper(BaseModel): """ - lambda_client: Any = None #: :meta private: + lambda_client: Any = None """The configured boto3 client""" function_name: Optional[str] = None """The name of your lambda function""" diff --git a/libs/community/langchain_community/utilities/dalle_image_generator.py b/libs/community/langchain_community/utilities/dalle_image_generator.py index 9b74a4fa8..dfa668eff 100644 --- a/libs/community/langchain_community/utilities/dalle_image_generator.py +++ b/libs/community/langchain_community/utilities/dalle_image_generator.py @@ -27,8 +27,8 @@ class DallEAPIWrapper(BaseModel): 2. save your OPENAI_API_KEY in an environment variable """ - client: Any = None #: :meta private: - async_client: Any = Field(default=None, exclude=True) #: :meta private: + client: Any = None + async_client: Any = Field(default=None, exclude=True) model_name: str = Field(default="dall-e-2", alias="model") model_kwargs: Dict[str, Any] = Field(default_factory=dict) openai_api_key: Optional[SecretStr] = Field( @@ -42,7 +42,7 @@ class DallEAPIWrapper(BaseModel): openai_api_base: Optional[str] = Field( alias="base_url", default_factory=from_env("OPENAI_API_BASE", default=None) ) - """Base URL path for API requests, leave blank if not using a proxy or service + """Base URL path for API requests, leave blank if not using a proxy or service emulator.""" openai_organization: Optional[str] = Field( alias="organization", diff --git a/libs/community/langchain_community/utilities/dataherald.py b/libs/community/langchain_community/utilities/dataherald.py index 84ad9d831..efa02c328 100644 --- a/libs/community/langchain_community/utilities/dataherald.py +++ b/libs/community/langchain_community/utilities/dataherald.py @@ -18,7 +18,7 @@ class DataheraldAPIWrapper(BaseModel): """ - dataherald_client: Any = None #: :meta private: + dataherald_client: Any = None db_connection_id: str dataherald_api_key: Optional[str] = None diff --git a/libs/community/langchain_community/utilities/github.py b/libs/community/langchain_community/utilities/github.py index 22a21e73c..6f707707f 100644 --- a/libs/community/langchain_community/utilities/github.py +++ b/libs/community/langchain_community/utilities/github.py @@ -28,8 +28,8 @@ def _import_tiktoken() -> Any: class GitHubAPIWrapper(BaseModel): """Wrapper for GitHub API.""" - github: Any = None #: :meta private: - github_repo_instance: Any = None #: :meta private: + github: Any = None + github_repo_instance: Any = None github_repository: Optional[str] = None github_app_id: Optional[str] = None github_app_private_key: Optional[str] = None diff --git a/libs/community/langchain_community/utilities/gitlab.py b/libs/community/langchain_community/utilities/gitlab.py index 78fb9ff46..e336b8ce1 100644 --- a/libs/community/langchain_community/utilities/gitlab.py +++ b/libs/community/langchain_community/utilities/gitlab.py @@ -15,21 +15,27 @@ class GitLabAPIWrapper(BaseModel): """Wrapper for GitLab API.""" - gitlab: Any = None #: :meta private: - gitlab_repo_instance: Any = None #: :meta private: + gitlab: Any = None + + gitlab_repo_instance: Any = None + gitlab_url: Optional[str] = None """The url of the GitLab instance.""" + gitlab_repository: Optional[str] = None """The name of the GitLab repository, in the form {username}/{repo-name}.""" + gitlab_personal_access_token: Optional[str] = None """Personal access token for the GitLab service, used for authentication.""" + gitlab_branch: Optional[str] = None """The specific branch in the GitLab repository where the bot will make - its commits. Defaults to 'main'. + its commits. Defaults to `'main'`. """ + gitlab_base_branch: Optional[str] = None """The base branch in the GitLab repository, used for comparisons. - Usually 'main' or 'master'. Defaults to 'main'. + Usually `'main'` or `'master'`. Defaults to `'main'`. """ model_config = ConfigDict( diff --git a/libs/community/langchain_community/utilities/google_search.py b/libs/community/langchain_community/utilities/google_search.py index 2037b34c8..f6a5960fc 100644 --- a/libs/community/langchain_community/utilities/google_search.py +++ b/libs/community/langchain_community/utilities/google_search.py @@ -47,14 +47,18 @@ class GoogleSearchAPIWrapper(BaseModel): - Create a custom search engine here: https://programmablesearchengine.google.com/. - In `What to search` to search, pick the `Search the entire Web` option. After search engine is created, you can click on it and find `Search engine ID` - on the Overview page. + on the Overview page. """ - search_engine: Any = None #: :meta private: + search_engine: Any = None + google_api_key: Optional[str] = None + google_cse_id: Optional[str] = None + k: int = 10 + siterestrict: bool = False model_config = ConfigDict( diff --git a/libs/community/langchain_community/utilities/graphql.py b/libs/community/langchain_community/utilities/graphql.py index efe9a3581..b40eb36dc 100644 --- a/libs/community/langchain_community/utilities/graphql.py +++ b/libs/community/langchain_community/utilities/graphql.py @@ -12,10 +12,14 @@ class GraphQLAPIWrapper(BaseModel): """ custom_headers: Optional[Dict[str, str]] = None + fetch_schema_from_transport: Optional[bool] = None + graphql_endpoint: str - gql_client: Any = None #: :meta private: - gql_function: Callable[[str], Any] #: :meta private: + + gql_client: Any = None + + gql_function: Callable[[str], Any] model_config = ConfigDict( extra="forbid", diff --git a/libs/community/langchain_community/utilities/jira.py b/libs/community/langchain_community/utilities/jira.py index fb8fdc11c..7fb0588a1 100644 --- a/libs/community/langchain_community/utilities/jira.py +++ b/libs/community/langchain_community/utilities/jira.py @@ -39,14 +39,20 @@ class JiraAPIWrapper(BaseModel): {"access_token": "your_access_token","token_type": "bearer"}}' """ - jira: Any = None #: :meta private: + jira: Any = None + confluence: Any = None + jira_username: Optional[str] = None + jira_api_token: Optional[str] = None """Jira API token when you choose to connect to Jira with api token.""" + jira_oauth2: Optional[Union[JiraOauth2, str]] = None """Jira OAuth2 token when you choose to connect to Jira with oauth2.""" + jira_instance_url: Optional[str] = None + jira_cloud: Optional[bool] = None model_config = ConfigDict( diff --git a/libs/community/langchain_community/utilities/pubmed.py b/libs/community/langchain_community/utilities/pubmed.py index 1200cdec8..a84ef8bc2 100644 --- a/libs/community/langchain_community/utilities/pubmed.py +++ b/libs/community/langchain_community/utilities/pubmed.py @@ -23,31 +23,38 @@ class PubMedAPIWrapper(BaseModel): Parameters: top_k_results: number of the top-scored document used for the PubMed tool MAX_QUERY_LENGTH: maximum length of the query. - Default is 300 characters. + Default is 300 characters. doc_content_chars_max: maximum length of the document content. - Content will be truncated if it exceeds this length. - Default is 2000 characters. + Content will be truncated if it exceeds this length. + Default is 2000 characters. max_retry: maximum number of retries for a request. Default is 5. sleep_time: time to wait between retries. - Default is 0.2 seconds. + Default is 0.2 seconds. email: email address to be used for the PubMed API. api_key: API key to be used for the PubMed API. """ - parse: Any #: :meta private: + parse: Any base_url_esearch: str = ( "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?" ) + base_url_efetch: str = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?" + max_retry: int = 5 + sleep_time: float = 0.2 # Default values for the parameters top_k_results: int = 3 + MAX_QUERY_LENGTH: int = 300 + doc_content_chars_max: int = 2000 + email: str = "your_email@example.com" + api_key: str = "" @model_validator(mode="before") diff --git a/libs/community/langchain_community/utilities/searx_search.py b/libs/community/langchain_community/utilities/searx_search.py index 7fdd54b52..2ee028e8a 100644 --- a/libs/community/langchain_community/utilities/searx_search.py +++ b/libs/community/langchain_community/utilities/searx_search.py @@ -163,10 +163,7 @@ def __str__(self) -> str: @property def results(self) -> Any: - """Silence mypy for accessing this field. - - :meta private: - """ + """Silence mypy for accessing this field.""" return self.get("results") @property diff --git a/libs/community/langchain_community/utilities/semanticscholar.py b/libs/community/langchain_community/utilities/semanticscholar.py index 896b0e599..0c12c405e 100644 --- a/libs/community/langchain_community/utilities/semanticscholar.py +++ b/libs/community/langchain_community/utilities/semanticscholar.py @@ -34,11 +34,16 @@ class SemanticScholarAPIWrapper(BaseModel): ss.run("biases in large language models") """ - semanticscholar_search: Any #: :meta private: + semanticscholar_search: Any + top_k_results: int = 5 + S2_MAX_QUERY_LENGTH: int = 300 + load_max_docs: int = 100 + doc_content_chars_max: Optional[int] = 4000 + returned_fields: List[str] = [ "title", "abstract", diff --git a/libs/community/langchain_community/utilities/serpapi.py b/libs/community/langchain_community/utilities/serpapi.py index 1b5c22089..cc990f5a9 100644 --- a/libs/community/langchain_community/utilities/serpapi.py +++ b/libs/community/langchain_community/utilities/serpapi.py @@ -34,13 +34,14 @@ class SerpAPIWrapper(BaseModel): `serpapi_api_key` as a named parameter to the constructor. Example: - .. code-block:: python - - from langchain_community.utilities import SerpAPIWrapper - serpapi = SerpAPIWrapper() + ```python + from langchain_community.utilities import SerpAPIWrapper + serpapi = SerpAPIWrapper() + ``` """ - search_engine: Any = None #: :meta private: + search_engine: Any = None + params: dict = Field( default={ "engine": "google", @@ -49,7 +50,9 @@ class SerpAPIWrapper(BaseModel): "hl": "en", } ) + serpapi_api_key: Optional[str] = None + aiosession: Optional[aiohttp.ClientSession] = None model_config = ConfigDict( diff --git a/libs/community/langchain_community/utilities/stackexchange.py b/libs/community/langchain_community/utilities/stackexchange.py index 80288a676..60b9ef98b 100644 --- a/libs/community/langchain_community/utilities/stackexchange.py +++ b/libs/community/langchain_community/utilities/stackexchange.py @@ -7,15 +7,19 @@ class StackExchangeAPIWrapper(BaseModel): """Wrapper for Stack Exchange API.""" - client: Any = None #: :meta private: + client: Any = None + max_results: int = 3 """Max number of results to include in output.""" + query_type: Literal["all", "title", "body"] = "all" - """Which part of StackOverflows items to match against. One of 'all', 'title', - 'body'. Defaults to 'all'. + """Which part of StackOverflows items to match against. One of 'all', 'title', + 'body'. Defaults to 'all'. """ + fetch_params: Dict[str, Any] = Field(default_factory=dict) """Additional params to pass to StackApi.fetch.""" + result_separator: str = "\n\n" """Separator between question,answer pairs.""" diff --git a/libs/community/langchain_community/utilities/tensorflow_datasets.py b/libs/community/langchain_community/utilities/tensorflow_datasets.py index 6fe5abefc..3f305dd97 100644 --- a/libs/community/langchain_community/utilities/tensorflow_datasets.py +++ b/libs/community/langchain_community/utilities/tensorflow_datasets.py @@ -55,10 +55,14 @@ def mlqaen_example_to_document(example: dict) -> Document: """ dataset_name: str = "" + split_name: str = "train" + load_max_docs: int = 100 + sample_to_document_function: Optional[Callable[[Dict], Document]] = None - dataset: Any #: :meta private: + + dataset: Any @model_validator(mode="before") @classmethod diff --git a/libs/community/langchain_community/utilities/twilio.py b/libs/community/langchain_community/utilities/twilio.py index c9ed0b23d..c56413a7d 100644 --- a/libs/community/langchain_community/utilities/twilio.py +++ b/libs/community/langchain_community/utilities/twilio.py @@ -26,20 +26,23 @@ class TwilioAPIWrapper(BaseModel): twilio.run('test', '+12484345508') """ - client: Any = None #: :meta private: + client: Any = None + account_sid: Optional[str] = None """Twilio account string identifier.""" + auth_token: Optional[str] = None """Twilio auth token.""" + from_number: Optional[str] = None - """A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) - format, an - [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), - or a [Channel Endpoint address](https://www.twilio.com/docs/sms/channels#channel-addresses) - that is enabled for the type of message you want to send. Phone numbers or - [short codes](https://www.twilio.com/docs/sms/api/short-code) purchased from - Twilio also work here. You cannot, for example, spoof messages from a private - cell phone number. If you are using `messaging_service_sid`, this parameter + """A Twilio phone number in [E.164](https://www.twilio.com/docs/glossary/what-e164) + format, an + [alphanumeric sender ID](https://www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), + or a [Channel Endpoint address](https://www.twilio.com/docs/sms/channels#channel-addresses) + that is enabled for the type of message you want to send. Phone numbers or + [short codes](https://www.twilio.com/docs/sms/api/short-code) purchased from + Twilio also work here. You cannot, for example, spoof messages from a private + cell phone number. If you are using `messaging_service_sid`, this parameter must be empty. """ diff --git a/libs/community/langchain_community/utilities/wikidata.py b/libs/community/langchain_community/utilities/wikidata.py index f341826d5..f65fe9c64 100644 --- a/libs/community/langchain_community/utilities/wikidata.py +++ b/libs/community/langchain_community/utilities/wikidata.py @@ -84,12 +84,18 @@ class WikidataAPIWrapper(BaseModel): It limits the Document content by doc_content_chars_max. """ - wikidata_mw: Any #: :meta private: - wikidata_rest: Any # : :meta private: + wikidata_mw: Any + + wikidata_rest: Any + top_k_results: int = 2 + load_all_available_meta: bool = False + doc_content_chars_max: int = 4000 + wikidata_props: List[str] = DEFAULT_PROPERTIES + lang: str = DEFAULT_LANG_CODE @model_validator(mode="before") diff --git a/libs/community/langchain_community/utilities/wikipedia.py b/libs/community/langchain_community/utilities/wikipedia.py index 271a165eb..be6fd9dbc 100644 --- a/libs/community/langchain_community/utilities/wikipedia.py +++ b/libs/community/langchain_community/utilities/wikipedia.py @@ -21,10 +21,14 @@ class WikipediaAPIWrapper(BaseModel): It limits the Document content by doc_content_chars_max. """ - wiki_client: Any #: :meta private: + wiki_client: Any + top_k_results: int = 3 + lang: str = "en" + load_all_available_meta: bool = False + doc_content_chars_max: int = 4000 @model_validator(mode="before") diff --git a/libs/community/langchain_community/utilities/wolfram_alpha.py b/libs/community/langchain_community/utilities/wolfram_alpha.py index 5565f6c28..f15c30f5e 100644 --- a/libs/community/langchain_community/utilities/wolfram_alpha.py +++ b/libs/community/langchain_community/utilities/wolfram_alpha.py @@ -18,7 +18,8 @@ class WolframAlphaAPIWrapper(BaseModel): """ - wolfram_client: Any = None #: :meta private: + wolfram_client: Any = None + wolfram_alpha_appid: Optional[str] = None model_config = ConfigDict( diff --git a/libs/community/langchain_community/vectorstores/thirdai_neuraldb.py b/libs/community/langchain_community/vectorstores/thirdai_neuraldb.py index e4a2cced8..3ed10d035 100644 --- a/libs/community/langchain_community/vectorstores/thirdai_neuraldb.py +++ b/libs/community/langchain_community/vectorstores/thirdai_neuraldb.py @@ -32,7 +32,7 @@ class NeuralDBVectorStore(VectorStore): def __init__(self, db: "ndb.NeuralDB") -> None: self.db = db - db: "ndb.NeuralDB" = None #: :meta private: + db: "ndb.NeuralDB" = None """NeuralDB instance""" model_config = ConfigDict( @@ -334,7 +334,7 @@ class NeuralDBClientVectorStore(VectorStore): def __init__(self, db: "ndb.NeuralDBClient") -> None: self.db = db - db: "ndb.NeuralDBClient" = None #: :meta private: + db: "ndb.NeuralDBClient" = None """NeuralDB Client instance""" model_config = ConfigDict( diff --git a/libs/community/pyproject.toml b/libs/community/pyproject.toml index 3931459bf..a8f47cc84 100644 --- a/libs/community/pyproject.toml +++ b/libs/community/pyproject.toml @@ -3,8 +3,13 @@ requires = ["hatchling"] build-backend = "hatchling.build" [project] -authors = [] +name = "langchain-community" +description = "Community contributed LangChain integrations." license = { text = "MIT" } +readme = "README.md" +authors = [] + +version = "0.4.1" requires-python = ">=3.10.0,<4.0.0" dependencies = [ "langchain-core>=1.0.1,<2.0.0", @@ -20,10 +25,6 @@ dependencies = [ "numpy>=1.26.2; python_version<'3.13'", "numpy>=2.1.0; python_version>='3.13'", ] -name = "langchain-community" -version = "0.4.1" -description = "Community contributed LangChain integrations." -readme = "README.md" [project.urls] Homepage = "https://docs.langchain.com/" From ce6a5cf4cbd73a583aa3109194573d8414f179ec Mon Sep 17 00:00:00 2001 From: Yashovardhan Dhanania Date: Mon, 10 Nov 2025 08:07:43 +0530 Subject: [PATCH 09/14] fix(azure): Fix key assignment logic (#418) Fixes inconsistent behaviour across `add_embeddings` and `aadd_embeddings` for Azure Search. Fixes #417 --- .../langchain_community/vectorstores/azuresearch.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py index e3465f0cf..ea27a9b46 100644 --- a/libs/community/langchain_community/vectorstores/azuresearch.py +++ b/libs/community/langchain_community/vectorstores/azuresearch.py @@ -677,9 +677,13 @@ async def aadd_embeddings( data = [] for i, (text, embedding) in enumerate(text_embeddings): # Use provided key otherwise use default key - key = keys[i] if keys else str(uuid.uuid4()) - # Encoding key for Azure Search valid characters - key = base64.urlsafe_b64encode(bytes(key, "utf-8")).decode("ascii") + if keys: + key = keys[i] + else: + key = str(uuid.uuid4()) + # Encoding key for Azure Search valid characters + key = base64.urlsafe_b64encode(bytes(key, "utf-8")).decode("ascii") + metadata = metadatas[i] if metadatas else {} # Add data to index # Additional metadata to fields mapping From cde3d06f5ad0c80b7748140a26ca065b75c8729c Mon Sep 17 00:00:00 2001 From: Yuki Harada <117978472+yukiharada1228@users.noreply.github.com> Date: Mon, 10 Nov 2025 11:38:42 +0900 Subject: [PATCH 10/14] feat(vectorstores): add routing support for hybrid search (#416) # feat(vectorstores): add routing support for hybrid search ## Summary This PR adds routing parameter support for hybrid search (`HYBRID_SEARCH`) in the `similarity_search_with_score` method of the `OpenSearchVectorSearch` class. ## Changes ### Modified Files - `libs/community/langchain_community/vectorstores/opensearch_vector_search.py` ### Change Details Modified the hybrid search processing within the `similarity_search_with_score` method to add the `routing` parameter to the request parameters when `self.routing` is set. **Before:** ```python response = self.client.transport.perform_request( method="GET", url=path, body=payload ) ``` **After:** ```python request_args: Dict[str, Any] = { "method": "GET", "url": path, "body": payload, } if self.routing: request_args["params"] = {"routing": self.routing} response = self.client.transport.perform_request(**request_args) ``` ## Background OpenSearch's routing feature is used to route requests to specific shards, which helps optimize performance and improve data locality. In the existing code, routing was already supported for `APPROXIMATE_SEARCH`, `SCRIPT_SCORING_SEARCH`, and `PAINLESS_SCRIPTING_SEARCH` search types (lines 1320-1322), but it was not supported for hybrid search (`HYBRID_SEARCH`). This change ensures that routing functionality is consistently available across all search types. ## Compatibility - **Backward Compatibility**: No impact on existing APIs. When the `routing` parameter is not set, the behavior remains unchanged. - **Breaking Changes**: None --- .../vectorstores/opensearch_vector_search.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/opensearch_vector_search.py b/libs/community/langchain_community/vectorstores/opensearch_vector_search.py index 795ae7271..d19dd771e 100644 --- a/libs/community/langchain_community/vectorstores/opensearch_vector_search.py +++ b/libs/community/langchain_community/vectorstores/opensearch_vector_search.py @@ -1302,9 +1302,15 @@ def _raw_similarity_search_with_score_by_vector( # hybrid search without post filter payload = _default_hybrid_search_query(query_text, embeded_query, k) - response = self.client.transport.perform_request( - method="GET", url=path, body=payload - ) + request_args: Dict[str, Any] = { + "method": "GET", + "url": path, + "body": payload, + } + if self.routing: + request_args["params"] = {"routing": self.routing} + + response = self.client.transport.perform_request(**request_args) return [hit for hit in response["hits"]["hits"]] From 55adf50fc908859585c5ba812d17116813b6ddf1 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Sun, 9 Nov 2025 22:07:26 -0500 Subject: [PATCH 11/14] nit: use american english (#419) --- .../tests/integration_tests/vectorstores/test_astradb.py | 6 +++--- .../tests/integration_tests/vectorstores/test_cassandra.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/community/tests/integration_tests/vectorstores/test_astradb.py b/libs/community/tests/integration_tests/vectorstores/test_astradb.py index 7bc4cbe03..22ce8fad0 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_astradb.py +++ b/libs/community/tests/integration_tests/vectorstores/test_astradb.py @@ -316,7 +316,7 @@ async def test_astradb_vectorstore_from_x_async(self) -> None: await v_store_2.adelete_collection() def test_astradb_vectorstore_crud(self, store_someemb: AstraDB) -> None: - """Basic add/delete/update behaviour.""" + """Basic add/delete/update behavior.""" res0 = store_someemb.similarity_search("Abc", k=2) assert res0 == [] # write and check again @@ -374,7 +374,7 @@ def test_astradb_vectorstore_crud(self, store_someemb: AstraDB) -> None: assert res4[0].metadata["ord"] == 205 async def test_astradb_vectorstore_crud_async(self, store_someemb: AstraDB) -> None: - """Basic add/delete/update behaviour.""" + """Basic add/delete/update behavior.""" res0 = await store_someemb.asimilarity_search("Abc", k=2) assert res0 == [] # write and check again @@ -597,7 +597,7 @@ def test_astradb_vectorstore_massive_delete(self, store_someemb: AstraDB) -> Non assert store_someemb.similarity_search("x", k=2 * M) == [] def test_astradb_vectorstore_drop(self) -> None: - """behaviour of 'delete_collection'.""" + """Behavior of `delete_collection`.""" collection_name = "lc_test_d" emb = SomeEmbeddings(dimension=2) v_store = AstraDB( diff --git a/libs/community/tests/integration_tests/vectorstores/test_cassandra.py b/libs/community/tests/integration_tests/vectorstores/test_cassandra.py index 70158f1fc..3aa079904 100644 --- a/libs/community/tests/integration_tests/vectorstores/test_cassandra.py +++ b/libs/community/tests/integration_tests/vectorstores/test_cassandra.py @@ -823,7 +823,7 @@ def test_cassandra_vectorstore_crud_sync( self, vector_store_d2: Cassandra, ) -> None: - """Add/delete/update behaviour.""" + """Add/delete/update behavior.""" vstore = vector_store_d2 res0 = vstore.similarity_search("[-1,-1]", k=2) @@ -907,7 +907,7 @@ async def test_cassandra_vectorstore_crud_async( self, vector_store_d2: Cassandra, ) -> None: - """Add/delete/update behaviour, async version.""" + """Add/delete/update behavior, async version.""" vstore = vector_store_d2 res0 = await vstore.asimilarity_search("[-1,-1]", k=2) From 683f6a4aa528de298352b51ae535e3eef1f2b95a Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 10 Nov 2025 11:52:46 -0500 Subject: [PATCH 12/14] chore(infra): clarify allowed scopes section in PR linting workflow (#420) --- .github/workflows/pr_lint.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_lint.yml b/.github/workflows/pr_lint.yml index 3e6b20092..8aaec24a8 100644 --- a/.github/workflows/pr_lint.yml +++ b/.github/workflows/pr_lint.yml @@ -26,7 +26,7 @@ # * revert — reverts a previous commit # * release — prepare a new release # -# Allowed Scopes (optional): +# Allowed Scope(s) (optional): # adapters, agent_toolkits, agents, callbacks, chains, chat_loaders, # chat_message_histories, chat_models, cross_encoders, docstore, document_compressors, # document_loaders, document_transformers, embeddings, example_selectors, @@ -34,6 +34,8 @@ # query_constructors, retrievers, storage, tools, utilities, utils, vectorstores, # cache, infra # +# Multiple scopes can be used by separating them with a comma. +# # Rules: # 1. The 'Type' must start with a lowercase letter. # 2. Breaking changes: append "!" after type/scope (e.g., feat!: drop x support) From 6918499040898cc47e1ca393dc0607828c789d6b Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Mon, 10 Nov 2025 22:51:21 -0500 Subject: [PATCH 13/14] chore: update `README.md` (#422) --- libs/community/README.md | 2 +- libs/community/langchain_community/vectorstores/azuresearch.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/community/README.md b/libs/community/README.md index b65eb0074..145f01088 100644 --- a/libs/community/README.md +++ b/libs/community/README.md @@ -22,7 +22,7 @@ LangChain Community contains third-party integrations that implement the base in ## 📖 Documentation -For full documentation, see the [API reference](https://reference.langchain.com/python/langchain_community/). +For full documentation, see the [API reference](https://reference.langchain.com/python/langchain_community/). For conceptual guides, tutorials, and examples on using LangChain, see the [LangChain Docs](https://docs.langchain.com/oss/python/langchain/overview). ## 📕 Releases & Versioning diff --git a/libs/community/langchain_community/vectorstores/azuresearch.py b/libs/community/langchain_community/vectorstores/azuresearch.py index ea27a9b46..210d427f2 100644 --- a/libs/community/langchain_community/vectorstores/azuresearch.py +++ b/libs/community/langchain_community/vectorstores/azuresearch.py @@ -683,7 +683,7 @@ async def aadd_embeddings( key = str(uuid.uuid4()) # Encoding key for Azure Search valid characters key = base64.urlsafe_b64encode(bytes(key, "utf-8")).decode("ascii") - + metadata = metadatas[i] if metadatas else {} # Add data to index # Additional metadata to fields mapping From 23dda6c6f1dbdeec35bf66b9067ce88588ced4b2 Mon Sep 17 00:00:00 2001 From: markshao Date: Sat, 22 Nov 2025 23:28:34 +0800 Subject: [PATCH 14/14] fix lint issues --- libs/community/langchain_community/llms/moonshot.py | 2 +- .../tests/integration_tests/chat_models/test_moonshot.py | 2 +- libs/community/tests/unit_tests/chat_models/test_moonshot.py | 5 +++-- libs/community/tests/unit_tests/llms/test_moonshot.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libs/community/langchain_community/llms/moonshot.py b/libs/community/langchain_community/llms/moonshot.py index 7f204fa69..c9ffc978d 100644 --- a/libs/community/langchain_community/llms/moonshot.py +++ b/libs/community/langchain_community/llms/moonshot.py @@ -39,7 +39,7 @@ def completion(self, request: Any) -> Any: class MoonshotCommon(BaseModel): """Common parameters for Moonshot LLMs.""" - client: Any + client: Any = Field(default=None) base_url: str = MOONSHOT_SERVICE_URL_BASE moonshot_api_key: Optional[SecretStr] = Field(default=None, alias="api_key") """Moonshot API key. Get it here: https://platform.moonshot.cn/console/api-keys""" diff --git a/libs/community/tests/integration_tests/chat_models/test_moonshot.py b/libs/community/tests/integration_tests/chat_models/test_moonshot.py index de4725cfa..29a31ca93 100644 --- a/libs/community/tests/integration_tests/chat_models/test_moonshot.py +++ b/libs/community/tests/integration_tests/chat_models/test_moonshot.py @@ -27,5 +27,5 @@ def test_usage_metadata(self, model: BaseChatModel) -> None: def test_chat_moonshot_instantiate_with_alias() -> None: """Test MoonshotChat instantiate when using alias.""" api_key = "your-api-key" - chat = MoonshotChat(api_key=api_key) # type: ignore[call-arg] + chat = MoonshotChat(api_key=api_key) assert cast(SecretStr, chat.moonshot_api_key).get_secret_value() == api_key diff --git a/libs/community/tests/unit_tests/chat_models/test_moonshot.py b/libs/community/tests/unit_tests/chat_models/test_moonshot.py index 531d8c179..6938fc570 100644 --- a/libs/community/tests/unit_tests/chat_models/test_moonshot.py +++ b/libs/community/tests/unit_tests/chat_models/test_moonshot.py @@ -1,5 +1,6 @@ +from typing import Any + import pytest -from langchain_core.runnables import Runnable from langchain_community.chat_models.moonshot import MoonshotChat @@ -9,5 +10,5 @@ @pytest.mark.requires("openai") def test_moonshot_bind_tools() -> None: llm = MoonshotChat(name="moonshot") - ret: Runnable = llm.bind_tools(mock_tool_list) + ret: Any = llm.bind_tools(mock_tool_list) assert len(ret.kwargs["tools"]) == 3 diff --git a/libs/community/tests/unit_tests/llms/test_moonshot.py b/libs/community/tests/unit_tests/llms/test_moonshot.py index fda1a5298..116abe998 100644 --- a/libs/community/tests/unit_tests/llms/test_moonshot.py +++ b/libs/community/tests/unit_tests/llms/test_moonshot.py @@ -9,7 +9,7 @@ @pytest.mark.requires("openai") def test_moonshot_model_param() -> None: - llm = Moonshot(model="foo") # type: ignore[call-arg] + llm = Moonshot(model="foo") assert llm.model_name == "foo" llm = Moonshot(model_name="bar") # type: ignore[call-arg] assert llm.model_name == "bar"