From 8a3b74fe1f030f1219b90c44a81178c96b1c7e4f Mon Sep 17 00:00:00 2001 From: Nat Noordanus Date: Wed, 14 Feb 2024 01:15:55 +0100 Subject: [PATCH] community[patch]: Fix pydantic ForwardRef error in BedrockBase (#17416) - **Description:** Fixes a type annotation issue in the definition of BedrockBase. This issue was that the annotation for the `config` attribute includes a ForwardRef to `botocore.client.Config` which is only imported when `TYPE_CHECKING`. This can cause pydantic to raise an error like `pydantic.errors.ConfigError: field "config" not yet prepared so type is still a ForwardRef, ...`. - **Issue:** N/A - **Dependencies:** N/A - **Twitter handle:** `@__nat_n__` --- libs/community/langchain_community/llms/bedrock.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libs/community/langchain_community/llms/bedrock.py b/libs/community/langchain_community/llms/bedrock.py index d3264703c7..f4d7b1d69e 100644 --- a/libs/community/langchain_community/llms/bedrock.py +++ b/libs/community/langchain_community/llms/bedrock.py @@ -1,11 +1,8 @@ -from __future__ import annotations - import asyncio import json import warnings from abc import ABC from typing import ( - TYPE_CHECKING, Any, AsyncGenerator, AsyncIterator, @@ -31,9 +28,6 @@ from langchain_community.utilities.anthropic import ( get_token_ids_anthropic, ) -if TYPE_CHECKING: - from botocore.config import Config - AMAZON_BEDROCK_TRACE_KEY = "amazon-bedrock-trace" GUARDRAILS_BODY_KEY = "amazon-bedrock-guardrailAssessment" HUMAN_PROMPT = "\n\nHuman:" @@ -226,7 +220,7 @@ class BedrockBase(BaseModel, ABC): See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html """ - config: Optional[Config] = None + config: Any = None """An optional botocore.config.Config instance to pass to the client.""" provider: Optional[str] = None