mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-18 18:53:10 +00:00
community[patch]: YandexGPT Use recent yandexcloud sdk version (#19341)
Fixed inability to work with [yandexcloud SDK](https://pypi.org/project/yandexcloud/) version higher 0.265.0
This commit is contained in:
parent
f1313339ac
commit
08b769d539
@ -90,7 +90,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"answer = chat_model(\n",
|
"answer = chat_model.invoke(\n",
|
||||||
" [\n",
|
" [\n",
|
||||||
" SystemMessage(\n",
|
" SystemMessage(\n",
|
||||||
" content=\"You are a helpful assistant that translates English to French.\"\n",
|
" content=\"You are a helpful assistant that translates English to French.\"\n",
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"country = \"Russia\"\n",
|
"country = \"Russia\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"llm_chain.run(country)"
|
"llm_chain.invoke(country)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -127,16 +127,29 @@ def _make_request(
|
|||||||
try:
|
try:
|
||||||
import grpc
|
import grpc
|
||||||
from google.protobuf.wrappers_pb2 import DoubleValue, Int64Value
|
from google.protobuf.wrappers_pb2 import DoubleValue, Int64Value
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_pb2 import (
|
|
||||||
CompletionOptions,
|
try:
|
||||||
Message,
|
from yandex.cloud.ai.foundation_models.v1.text_common_pb2 import (
|
||||||
)
|
CompletionOptions,
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
Message,
|
||||||
CompletionRequest,
|
)
|
||||||
)
|
from yandex.cloud.ai.foundation_models.v1.text_generation.text_generation_service_pb2 import ( # noqa: E501
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
CompletionRequest,
|
||||||
TextGenerationServiceStub,
|
)
|
||||||
)
|
from yandex.cloud.ai.foundation_models.v1.text_generation.text_generation_service_pb2_grpc import ( # noqa: E501
|
||||||
|
TextGenerationServiceStub,
|
||||||
|
)
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_pb2 import (
|
||||||
|
CompletionOptions,
|
||||||
|
Message,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
||||||
|
CompletionRequest,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
||||||
|
TextGenerationServiceStub,
|
||||||
|
)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Please install YandexCloud SDK with `pip install yandexcloud` \
|
"Please install YandexCloud SDK with `pip install yandexcloud` \
|
||||||
@ -166,17 +179,31 @@ async def _amake_request(self: ChatYandexGPT, messages: List[BaseMessage]) -> st
|
|||||||
|
|
||||||
import grpc
|
import grpc
|
||||||
from google.protobuf.wrappers_pb2 import DoubleValue, Int64Value
|
from google.protobuf.wrappers_pb2 import DoubleValue, Int64Value
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_pb2 import (
|
|
||||||
CompletionOptions,
|
try:
|
||||||
Message,
|
from yandex.cloud.ai.foundation_models.v1.text_common_pb2 import (
|
||||||
)
|
CompletionOptions,
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
Message,
|
||||||
CompletionRequest,
|
)
|
||||||
CompletionResponse,
|
from yandex.cloud.ai.foundation_models.v1.text_generation.text_generation_service_pb2 import ( # noqa: E501
|
||||||
)
|
CompletionRequest,
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
CompletionResponse,
|
||||||
TextGenerationAsyncServiceStub,
|
)
|
||||||
)
|
from yandex.cloud.ai.foundation_models.v1.text_generation.text_generation_service_pb2_grpc import ( # noqa: E501
|
||||||
|
TextGenerationAsyncServiceStub,
|
||||||
|
)
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_pb2 import (
|
||||||
|
CompletionOptions,
|
||||||
|
Message,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
||||||
|
CompletionRequest,
|
||||||
|
CompletionResponse,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
||||||
|
TextGenerationAsyncServiceStub,
|
||||||
|
)
|
||||||
from yandex.cloud.operation.operation_service_pb2 import GetOperationRequest
|
from yandex.cloud.operation.operation_service_pb2 import GetOperationRequest
|
||||||
from yandex.cloud.operation.operation_service_pb2_grpc import (
|
from yandex.cloud.operation.operation_service_pb2_grpc import (
|
||||||
OperationServiceStub,
|
OperationServiceStub,
|
||||||
|
@ -80,6 +80,7 @@ _module_lookup = {
|
|||||||
"VolcanoEmbeddings": "langchain_community.embeddings.volcengine",
|
"VolcanoEmbeddings": "langchain_community.embeddings.volcengine",
|
||||||
"VoyageEmbeddings": "langchain_community.embeddings.voyageai",
|
"VoyageEmbeddings": "langchain_community.embeddings.voyageai",
|
||||||
"XinferenceEmbeddings": "langchain_community.embeddings.xinference",
|
"XinferenceEmbeddings": "langchain_community.embeddings.xinference",
|
||||||
|
"YandexGPTEmbeddings": "langchain_community.embeddings.yandex",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,12 +149,21 @@ def _embed_with_retry(llm: YandexGPTEmbeddings, **kwargs: Any) -> Any:
|
|||||||
def _make_request(self: YandexGPTEmbeddings, texts: List[str]): # type: ignore[no-untyped-def]
|
def _make_request(self: YandexGPTEmbeddings, texts: List[str]): # type: ignore[no-untyped-def]
|
||||||
try:
|
try:
|
||||||
import grpc
|
import grpc
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
|
||||||
TextEmbeddingRequest,
|
try:
|
||||||
)
|
from yandex.cloud.ai.foundation_models.v1.embedding.embedding_service_pb2 import ( # noqa: E501
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
TextEmbeddingRequest,
|
||||||
EmbeddingsServiceStub,
|
)
|
||||||
)
|
from yandex.cloud.ai.foundation_models.v1.embedding.embedding_service_pb2_grpc import ( # noqa: E501
|
||||||
|
EmbeddingsServiceStub,
|
||||||
|
)
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
||||||
|
TextEmbeddingRequest,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
||||||
|
EmbeddingsServiceStub,
|
||||||
|
)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Please install YandexCloud SDK with `pip install yandexcloud` \
|
"Please install YandexCloud SDK with `pip install yandexcloud` \
|
||||||
|
@ -186,16 +186,29 @@ def _make_request(
|
|||||||
try:
|
try:
|
||||||
import grpc
|
import grpc
|
||||||
from google.protobuf.wrappers_pb2 import DoubleValue, Int64Value
|
from google.protobuf.wrappers_pb2 import DoubleValue, Int64Value
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_pb2 import (
|
|
||||||
CompletionOptions,
|
try:
|
||||||
Message,
|
from yandex.cloud.ai.foundation_models.v1.text_common_pb2 import (
|
||||||
)
|
CompletionOptions,
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
Message,
|
||||||
CompletionRequest,
|
)
|
||||||
)
|
from yandex.cloud.ai.foundation_models.v1.text_generation.text_generation_service_pb2 import ( # noqa: E501
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
CompletionRequest,
|
||||||
TextGenerationServiceStub,
|
)
|
||||||
)
|
from yandex.cloud.ai.foundation_models.v1.text_generation.text_generation_service_pb2_grpc import ( # noqa: E501
|
||||||
|
TextGenerationServiceStub,
|
||||||
|
)
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_pb2 import (
|
||||||
|
CompletionOptions,
|
||||||
|
Message,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
||||||
|
CompletionRequest,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
||||||
|
TextGenerationServiceStub,
|
||||||
|
)
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"Please install YandexCloud SDK with `pip install yandexcloud` \
|
"Please install YandexCloud SDK with `pip install yandexcloud` \
|
||||||
@ -222,17 +235,31 @@ async def _amake_request(self: YandexGPT, prompt: str) -> str:
|
|||||||
|
|
||||||
import grpc
|
import grpc
|
||||||
from google.protobuf.wrappers_pb2 import DoubleValue, Int64Value
|
from google.protobuf.wrappers_pb2 import DoubleValue, Int64Value
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_pb2 import (
|
|
||||||
CompletionOptions,
|
try:
|
||||||
Message,
|
from yandex.cloud.ai.foundation_models.v1.text_common_pb2 import (
|
||||||
)
|
CompletionOptions,
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
Message,
|
||||||
CompletionRequest,
|
)
|
||||||
CompletionResponse,
|
from yandex.cloud.ai.foundation_models.v1.text_generation.text_generation_service_pb2 import ( # noqa: E501
|
||||||
)
|
CompletionRequest,
|
||||||
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
CompletionResponse,
|
||||||
TextGenerationAsyncServiceStub,
|
)
|
||||||
)
|
from yandex.cloud.ai.foundation_models.v1.text_generation.text_generation_service_pb2_grpc import ( # noqa: E501
|
||||||
|
TextGenerationAsyncServiceStub,
|
||||||
|
)
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_pb2 import (
|
||||||
|
CompletionOptions,
|
||||||
|
Message,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2 import ( # noqa: E501
|
||||||
|
CompletionRequest,
|
||||||
|
CompletionResponse,
|
||||||
|
)
|
||||||
|
from yandex.cloud.ai.foundation_models.v1.foundation_models_service_pb2_grpc import ( # noqa: E501
|
||||||
|
TextGenerationAsyncServiceStub,
|
||||||
|
)
|
||||||
from yandex.cloud.operation.operation_service_pb2 import GetOperationRequest
|
from yandex.cloud.operation.operation_service_pb2 import GetOperationRequest
|
||||||
from yandex.cloud.operation.operation_service_pb2_grpc import (
|
from yandex.cloud.operation.operation_service_pb2_grpc import (
|
||||||
OperationServiceStub,
|
OperationServiceStub,
|
||||||
|
@ -65,6 +65,7 @@ EXPECTED_ALL = [
|
|||||||
"QuantizedBiEncoderEmbeddings",
|
"QuantizedBiEncoderEmbeddings",
|
||||||
"NeMoEmbeddings",
|
"NeMoEmbeddings",
|
||||||
"SparkLLMTextEmbeddings",
|
"SparkLLMTextEmbeddings",
|
||||||
|
"YandexGPTEmbeddings",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user