mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-28 15:00:23 +00:00
experimental[major]: upgrade pydantic (#26228)
This commit is contained in:
@@ -14,8 +14,7 @@ from langchain_community.utilities.sql_database import SQLDatabase
|
||||
from langchain_core.callbacks.manager import CallbackManagerForChainRun
|
||||
from langchain_core.language_models import BaseLanguageModel
|
||||
from langchain_core.prompts.prompt import PromptTemplate
|
||||
|
||||
from langchain_experimental.pydantic_v1 import Field, root_validator
|
||||
from pydantic import ConfigDict, Field, model_validator
|
||||
|
||||
INTERMEDIATE_STEPS_KEY = "intermediate_steps"
|
||||
SQL_QUERY = "SQLQuery:"
|
||||
@@ -66,12 +65,14 @@ class SQLDatabaseChain(Chain):
|
||||
query_checker_prompt: Optional[BasePromptTemplate] = None
|
||||
"""The prompt template that should be used by the query checker"""
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
extra = "forbid"
|
||||
model_config = ConfigDict(
|
||||
arbitrary_types_allowed=True,
|
||||
extra="forbid",
|
||||
)
|
||||
|
||||
@root_validator(pre=True)
|
||||
def raise_deprecation(cls, values: Dict) -> Dict:
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def raise_deprecation(cls, values: Dict) -> Any:
|
||||
if "llm" in values:
|
||||
warnings.warn(
|
||||
"Directly instantiating an SQLDatabaseChain with an llm is deprecated. "
|
||||
|
@@ -14,6 +14,7 @@ from langchain_core.language_models import BaseLanguageModel
|
||||
from langchain_core.output_parsers import BaseOutputParser
|
||||
from langchain_core.prompts import BasePromptTemplate
|
||||
from langchain_core.prompts.prompt import PromptTemplate
|
||||
from pydantic import ConfigDict
|
||||
|
||||
from langchain_experimental.sql.base import INTERMEDIATE_STEPS_KEY, SQLDatabaseChain
|
||||
|
||||
@@ -30,8 +31,9 @@ class VectorSQLOutputParser(BaseOutputParser[str]):
|
||||
distance_func_name: str = "distance"
|
||||
"""Distance name for Vector SQL"""
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = 1
|
||||
model_config = ConfigDict(
|
||||
arbitrary_types_allowed=True,
|
||||
)
|
||||
|
||||
@property
|
||||
def _type(self) -> str:
|
||||
|
Reference in New Issue
Block a user