From 2901fa20cc89246e2d28a34fab454ce3d134854f Mon Sep 17 00:00:00 2001 From: Mikelarg Date: Thu, 21 Nov 2024 00:03:47 +0300 Subject: [PATCH] community: Add deprecation warning for GigaChat integration in langchain-community (#28022) - **Description:** We have released the [langchain-gigachat](https://github.com/ai-forever/langchain-gigachat?tab=readme-ov-file) with new GigaChat integration that support's function/tool calling. This PR deprecated legacy GigaChat class in community package. --------- Co-authored-by: Erick Friis --- docs/docs/integrations/chat/gigachat.ipynb | 10 +++++----- .../integrations/providers/salute_devices.mdx | 6 +++--- .../text_embedding/gigachat.ipynb | 19 ++++++++----------- .../chat_models/gigachat.py | 6 ++++++ .../embeddings/gigachat.py | 6 ++++++ 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/docs/docs/integrations/chat/gigachat.ipynb b/docs/docs/integrations/chat/gigachat.ipynb index 3fbb13ce419c0..548b5c2df7d3c 100644 --- a/docs/docs/integrations/chat/gigachat.ipynb +++ b/docs/docs/integrations/chat/gigachat.ipynb @@ -8,7 +8,7 @@ "source": [ "# GigaChat\n", "This notebook shows how to use LangChain with [GigaChat](https://developers.sber.ru/portal/products/gigachat).\n", - "To use you need to install ```gigachat``` python package." + "To use you need to install ```langchain_gigachat``` python package." ] }, { @@ -22,7 +22,7 @@ }, "outputs": [], "source": [ - "%pip install --upgrade --quiet gigachat" + "%pip install --upgrade --quiet langchain-gigachat" ] }, { @@ -53,20 +53,20 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ - "from langchain_community.chat_models import GigaChat\n", + "from langchain_gigachat import GigaChat\n", "\n", "chat = GigaChat(verify_ssl_certs=False, scope=\"GIGACHAT_API_PERS\")" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": { "collapsed": false }, diff --git a/docs/docs/integrations/providers/salute_devices.mdx b/docs/docs/integrations/providers/salute_devices.mdx index 2651090acc07c..b0566e9d76d89 100644 --- a/docs/docs/integrations/providers/salute_devices.mdx +++ b/docs/docs/integrations/providers/salute_devices.mdx @@ -9,7 +9,7 @@ For more info how to get access to GigaChat [follow here](https://developers.sbe GigaChat package can be installed via pip from PyPI: ```bash -pip install gigachat +pip install langchain-gigachat ``` ## LLMs @@ -25,7 +25,7 @@ from langchain_community.llms import GigaChat See a [usage example](/docs/integrations/chat/gigachat). ```python -from langchain_community.chat_models import GigaChat +from langchain_gigachat.chat_models import GigaChat ``` ## Embeddings @@ -33,5 +33,5 @@ from langchain_community.chat_models import GigaChat See a [usage example](/docs/integrations/text_embedding/gigachat). ```python -from langchain_community.embeddings import GigaChatEmbeddings +from langchain_gigachat.embeddings import GigaChatEmbeddings ``` \ No newline at end of file diff --git a/docs/docs/integrations/text_embedding/gigachat.ipynb b/docs/docs/integrations/text_embedding/gigachat.ipynb index 1f98f3f4f7411..2f4d0749fa9be 100644 --- a/docs/docs/integrations/text_embedding/gigachat.ipynb +++ b/docs/docs/integrations/text_embedding/gigachat.ipynb @@ -15,11 +15,14 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": false + "collapsed": false, + "pycharm": { + "is_executing": true + } }, "outputs": [], "source": [ - "%pip install --upgrade --quiet gigachat" + "%pip install --upgrade --quiet langchain-gigachat" ] }, { @@ -50,13 +53,13 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ - "from langchain_community.embeddings import GigaChatEmbeddings\n", + "from langchain_gigachat import GigaChatEmbeddings\n", "\n", "embeddings = GigaChatEmbeddings(verify_ssl_certs=False, scope=\"GIGACHAT_API_PERS\")" ] @@ -81,13 +84,7 @@ "outputs": [ { "data": { - "text/plain": [ - "[0.8398333191871643,\n", - " -0.14180311560630798,\n", - " -0.6161925792694092,\n", - " -0.17103666067123413,\n", - " 1.2884578704833984]" - ] + "text/plain": "[0.8398333191871643,\n -0.14180311560630798,\n -0.6161925792694092,\n -0.17103666067123413,\n 1.2884578704833984]" }, "execution_count": 8, "metadata": {}, diff --git a/libs/community/langchain_community/chat_models/gigachat.py b/libs/community/langchain_community/chat_models/gigachat.py index 62285c9886838..7f453bcd10264 100644 --- a/libs/community/langchain_community/chat_models/gigachat.py +++ b/libs/community/langchain_community/chat_models/gigachat.py @@ -13,6 +13,7 @@ Type, ) +from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, @@ -113,6 +114,11 @@ def _convert_delta_to_message_chunk( return default_class(content=content) # type: ignore[call-arg] +@deprecated( + since="0.3.5", + removal="1.0", + alternative_import="langchain_gigachat.GigaChat", +) class GigaChat(_BaseGigaChat, BaseChatModel): """`GigaChat` large language models API. diff --git a/libs/community/langchain_community/embeddings/gigachat.py b/libs/community/langchain_community/embeddings/gigachat.py index eea276e2444b1..359addfd4f81b 100644 --- a/libs/community/langchain_community/embeddings/gigachat.py +++ b/libs/community/langchain_community/embeddings/gigachat.py @@ -4,6 +4,7 @@ from functools import cached_property from typing import Any, Dict, List, Optional +from langchain_core._api.deprecation import deprecated from langchain_core.embeddings import Embeddings from langchain_core.utils import pre_init from langchain_core.utils.pydantic import get_fields @@ -15,6 +16,11 @@ MAX_BATCH_SIZE_PARTS = 90 +@deprecated( + since="0.3.5", + removal="1.0", + alternative_import="langchain_gigachat.GigaChatEmbeddings", +) class GigaChatEmbeddings(BaseModel, Embeddings): """GigaChat Embeddings models.