Skip to main content
Open on GitHub

community

如何添加社区集成(不推荐)

danger

我们建议遵循主集成指南来添加新集成。

如果遵循本指南,我们很有可能会在不作太多讨论的情况下关闭您的拉取请求,并附上上述指南的链接。

langchain-community 包位于 libs/community

可以使用 pip install langchain-community 进行安装,并且可以像下面这样的代码导入导出的成员

from langchain_community.chat_models import ChatParrotLink
from langchain_community.llms import ParrotLinkLLM
from langchain_community.vectorstores import ParrotLinkVectorStore

community 包依赖于手动安装的依赖包,因此如果您尝试导入未安装的包,将会看到错误。在我们虚构的例子中,如果您尝试在未安装 parrot-link-sdk 的情况下导入 ParrotLinkLLM,当您尝试使用它时,会看到一个 ImportError,提示您安装它。

假设我们想为 Parrot Link AI 实现一个聊天模型。我们将在 libs/community/langchain_community/chat_models/parrot_link.py 中创建一个新文件,其中包含以下代码:

from langchain_core.language_models.chat_models import BaseChatModel

class ChatParrotLink(BaseChatModel):
"""ParrotLink 聊天模型。

示例:
.. code-block:: python

from langchain_community.chat_models import ChatParrotLink

model = ChatParrotLink()
"""

...
API Reference:BaseChatModel

我们将在以下位置编写测试:

  • 单元测试:libs/community/tests/unit_tests/chat_models/test_parrot_link.py
  • 集成测试:libs/community/tests/integration_tests/chat_models/test_parrot_link.py

并将文档添加到:

  • docs/docs/integrations/chat/parrot_link.ipynb