社区
如何添加社区集成(不推荐)
危险
我们建议遵循主要的集成指南来添加新的集成。
如果您遵循本指南,我们很可能会关闭您的 PR,并链接上述指南,而不会进行太多讨论。
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
包依赖于手动安装的依赖包,因此如果您尝试导入未安装的包,您将看到错误。在我们的虚构示例中,如果您尝试导入 ParrotLinkLLM
而不安装 parrot-link-sdk
,当您尝试使用它时,您将看到一个 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):
"""ChatParrotLink chat model.
Example:
.. code-block:: python
from langchain_community.chat_models import ChatParrotLink
model = ChatParrotLink()
"""
...
API 参考: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