社区
如何添加社区集成(不推荐)
危险
我们建议遵循主集成指南来添加新的集成。
如果您遵循本指南,我们很有可能会在没有太多讨论的情况下,关闭您的拉取请求(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