mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-28 15:00:23 +00:00
langchain-community[major]: Upgrade community to pydantic 2 (#26011)
This PR upgrades langchain-community to pydantic 2.
* Most of this PR was auto-generated using code mods with gritql
(https://github.com/eyurtsev/migrate-pydantic/tree/main)
* Subsequently, some code was fixed manually due to accommodate
differences between pydantic 1 and 2
Breaking Changes:
- Use TEXTEMBED_API_KEY and TEXTEMBEB_API_URL for env variables for text
embed integrations:
cbea780492
Other changes:
- Added pydantic_settings as a required dependency for community. This
may be removed if we have enough time to convert the dependency into an
optional one.
---------
Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
@@ -6,8 +6,8 @@ from typing import Any, Dict, List, Optional
|
||||
from langchain_core.callbacks import CallbackManagerForRetrieverRun
|
||||
from langchain_core.documents import Document
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.pydantic_v1 import root_validator
|
||||
from langchain_core.retrievers import BaseRetriever
|
||||
from pydantic import model_validator
|
||||
|
||||
from langchain_community.vectorstores.milvus import Milvus
|
||||
|
||||
@@ -93,8 +93,9 @@ class MilvusRetriever(BaseRetriever):
|
||||
store: Milvus
|
||||
retriever: BaseRetriever
|
||||
|
||||
@root_validator(pre=True)
|
||||
def create_retriever(cls, values: Dict) -> Dict:
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def create_retriever(cls, values: Dict) -> Any:
|
||||
"""Create the Milvus store and retriever."""
|
||||
values["store"] = Milvus(
|
||||
values["embedding_function"],
|
||||
|
Reference in New Issue
Block a user