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__`
pull/17291/head
Nat Noordanus 5 months ago committed by GitHub
parent 2c076bebc9
commit 8a3b74fe1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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

Loading…
Cancel
Save