Skip to content

The agent engineering platform.

community[patch]: fix agenerate return value (#14815)

Dmitry Tyumentsev78ae276df713
diff --git a/docs/docs/integrations/chat/yandex.ipynb b/docs/docs/integrations/chat/yandex.ipynb
index 6d3a14b4ee..8e9d81462e 100644
--- a/docs/docs/integrations/chat/yandex.ipynb
+++ b/docs/docs/integrations/chat/yandex.ipynb
@@ -46,8 +46,6 @@
"- [API key](https://cloud.yandex.com/en/docs/iam/operations/api-key/create)\n",
" You can specify the key in a constructor parameter `api_key` or in an environment variable `YC_API_KEY`.\n",
"\n",
- "In the `model_uri` parameter, specify the model used, see [the documentation](https://cloud.yandex.com/en/docs/yandexgpt/concepts/models#yandexgpt-generation) for more details.\n",
- "\n",
"To specify the model you can use `model_uri` parameter, see [the documentation](https://cloud.yandex.com/en/docs/yandexgpt/concepts/models#yandexgpt-generation) for more details.\n",
"\n",
"By default, the latest version of `yandexgpt-lite` is used from the folder specified in the parameter `folder_id` or `YC_FOLDER_ID` environment variable."
diff --git a/docs/docs/integrations/llms/yandex.ipynb b/docs/docs/integrations/llms/yandex.ipynb
index 019cb608a5..adddce4d8b 100644
--- a/docs/docs/integrations/llms/yandex.ipynb
+++ b/docs/docs/integrations/llms/yandex.ipynb
@@ -33,8 +33,6 @@
"- [API key](https://cloud.yandex.com/en/docs/iam/operations/api-key/create)\n",
" You can specify the key in a constructor parameter `api_key` or in an environment variable `YC_API_KEY`.\n",
"\n",
- "In the `model_uri` parameter, specify the model used, see [the documentation](https://cloud.yandex.com/en/docs/yandexgpt/concepts/models#yandexgpt-generation) for more details.\n",
- "\n",
"To specify the model you can use `model_uri` parameter, see [the documentation](https://cloud.yandex.com/en/docs/yandexgpt/concepts/models#yandexgpt-generation) for more details.\n",
"\n",
"By default, the latest version of `yandexgpt-lite` is used from the folder specified in the parameter `folder_id` or `YC_FOLDER_ID` environment variable."
diff --git a/libs/community/langchain_community/chat_models/yandex.py b/libs/community/langchain_community/chat_models/yandex.py
index 9dc6ede9e1..6a8dc556ff 100644
--- a/libs/community/langchain_community/chat_models/yandex.py
+++ b/libs/community/langchain_community/chat_models/yandex.py
@@ -192,9 +192,9 @@ class ChatYandexGPT(_BaseYandexGPT, BaseChatModel):
operation_request, metadata=self._grpc_metadata
)
- instruct_response = CompletionResponse()
- operation.response.Unpack(instruct_response)
- text = instruct_response.alternatives[0].message.text
- if stop is not None:
- text = enforce_stop_tokens(text, stop)
- return text
+ completion_response = CompletionResponse()
+ operation.response.Unpack(completion_response)
+ text = completion_response.alternatives[0].message.text
+ text = text if stop is None else enforce_stop_tokens(text, stop)
+ message = AIMessage(content=text)
+ return ChatResult(generations=[ChatGeneration(message=message)])
diff --git a/libs/community/langchain_community/llms/yandex.py b/libs/community/langchain_community/llms/yandex.py
index 3f6d59c770..9691868ddf 100644
--- a/libs/community/langchain_community/llms/yandex.py
+++ b/libs/community/langchain_community/llms/yandex.py
@@ -232,9 +232,9 @@ class YandexGPT(_BaseYandexGPT, LLM):
operation_request, metadata=self._grpc_metadata
)
- instruct_response = CompletionResponse()
- operation.response.Unpack(instruct_response)
- text = instruct_response.alternatives[0].message.text
+ completion_response = CompletionResponse()
+ operation.response.Unpack(completion_response)
+ text = completion_response.alternatives[0].message.text
if stop is not None:
text = enforce_stop_tokens(text, stop)
return text