mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 17:08:47 +00:00
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__`
This commit is contained in:
parent
2c076bebc9
commit
8a3b74fe1f
@ -1,11 +1,8 @@
|
|||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import warnings
|
import warnings
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
from typing import (
|
from typing import (
|
||||||
TYPE_CHECKING,
|
|
||||||
Any,
|
Any,
|
||||||
AsyncGenerator,
|
AsyncGenerator,
|
||||||
AsyncIterator,
|
AsyncIterator,
|
||||||
@ -31,9 +28,6 @@ from langchain_community.utilities.anthropic import (
|
|||||||
get_token_ids_anthropic,
|
get_token_ids_anthropic,
|
||||||
)
|
)
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from botocore.config import Config
|
|
||||||
|
|
||||||
AMAZON_BEDROCK_TRACE_KEY = "amazon-bedrock-trace"
|
AMAZON_BEDROCK_TRACE_KEY = "amazon-bedrock-trace"
|
||||||
GUARDRAILS_BODY_KEY = "amazon-bedrock-guardrailAssessment"
|
GUARDRAILS_BODY_KEY = "amazon-bedrock-guardrailAssessment"
|
||||||
HUMAN_PROMPT = "\n\nHuman:"
|
HUMAN_PROMPT = "\n\nHuman:"
|
||||||
@ -226,7 +220,7 @@ class BedrockBase(BaseModel, ABC):
|
|||||||
See: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
|
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."""
|
"""An optional botocore.config.Config instance to pass to the client."""
|
||||||
|
|
||||||
provider: Optional[str] = None
|
provider: Optional[str] = None
|
||||||
|
Loading…
Reference in New Issue
Block a user