mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-12 21:11:43 +00:00
multiple: pydantic 2 compatibility, v0.3 (#26443)
Signed-off-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com> Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com> Co-authored-by: Dan O'Donovan <dan.odonovan@gmail.com> Co-authored-by: Tom Daniel Grande <tomdgrande@gmail.com> Co-authored-by: Grande <Tom.Daniel.Grande@statsbygg.no> Co-authored-by: Bagatur <baskaryan@gmail.com> Co-authored-by: ccurme <chester.curme@gmail.com> Co-authored-by: Harrison Chase <hw.chase.17@gmail.com> Co-authored-by: Tomaz Bratanic <bratanic.tomaz@gmail.com> Co-authored-by: ZhangShenao <15201440436@163.com> Co-authored-by: Friso H. Kingma <fhkingma@gmail.com> Co-authored-by: ChengZi <chen.zhang@zilliz.com> Co-authored-by: Nuno Campos <nuno@langchain.dev> Co-authored-by: Morgante Pell <morgantep@google.com>
This commit is contained in:
@@ -26,7 +26,7 @@ from langchain_core.messages import (
|
||||
)
|
||||
from langchain_core.output_parsers.transform import BaseOutputParser
|
||||
from langchain_core.outputs import ChatGeneration, ChatResult, Generation
|
||||
from langchain_core.pydantic_v1 import BaseModel, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@@ -416,7 +416,7 @@ class ChatKinetica(BaseChatModel):
|
||||
|
||||
# convert the prompt to messages
|
||||
# request = SuggestRequest.model_validate(prompt_json) # pydantic v2
|
||||
request = _KdtoSuggestRequest.parse_obj(prompt_json)
|
||||
request = _KdtoSuggestRequest.model_validate(prompt_json)
|
||||
payload = request.payload
|
||||
|
||||
dict_messages = []
|
||||
@@ -448,7 +448,7 @@ class ChatKinetica(BaseChatModel):
|
||||
|
||||
data = response_json["data"]
|
||||
# response = CompletionResponse.model_validate(data) # pydantic v2
|
||||
response = _KdtCompletionResponse.parse_obj(data)
|
||||
response = _KdtCompletionResponse.model_validate(data)
|
||||
if response.status != "OK":
|
||||
raise ValueError("SQL Generation failed")
|
||||
return response.data
|
||||
@@ -543,8 +543,9 @@ class KineticaSqlResponse(BaseModel):
|
||||
dataframe: Any = Field(default=None)
|
||||
"""The Pandas dataframe containing the fetched data."""
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
model_config = ConfigDict(
|
||||
arbitrary_types_allowed=True,
|
||||
)
|
||||
|
||||
|
||||
class KineticaSqlOutputParser(BaseOutputParser[KineticaSqlResponse]):
|
||||
@@ -582,8 +583,9 @@ class KineticaSqlOutputParser(BaseOutputParser[KineticaSqlResponse]):
|
||||
kdbc: Any = Field(exclude=True)
|
||||
""" Kinetica DB connection. """
|
||||
|
||||
class Config:
|
||||
arbitrary_types_allowed = True
|
||||
model_config = ConfigDict(
|
||||
arbitrary_types_allowed=True,
|
||||
)
|
||||
|
||||
def parse(self, text: str) -> KineticaSqlResponse:
|
||||
df = self.kdbc.to_df(text)
|
||||
|
Reference in New Issue
Block a user