From 5de2ab60988add3fdda0d6aa9f56907fac4f00cb Mon Sep 17 00:00:00 2001 From: sabaimran Date: Sat, 18 Nov 2023 12:10:36 -0800 Subject: [PATCH] Change parse_obj calls to use model_validate per new pydantic specification --- src/khoj/routers/api.py | 2 +- src/khoj/search_type/text_search.py | 2 +- src/khoj/utils/yaml.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index b384d8a3..dd2a2837 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -122,7 +122,7 @@ async def map_config_to_db(config: FullConfig, user: KhojUser): def _initialize_config(): if state.config is None: state.config = FullConfig() - state.config.search_type = SearchConfig.parse_obj(constants.default_config["search-type"]) + state.config.search_type = SearchConfig.model_validate(constants.default_config["search-type"]) @api.get("/config/data", response_model=FullConfig) diff --git a/src/khoj/search_type/text_search.py b/src/khoj/search_type/text_search.py index f07eb580..7e295903 100644 --- a/src/khoj/search_type/text_search.py +++ b/src/khoj/search_type/text_search.py @@ -163,7 +163,7 @@ def deduplicated_search_responses(hits: List[SearchResponse]): else: hit_ids.add(hit.corpus_id) - yield SearchResponse.parse_obj( + yield SearchResponse.model_validate( { "entry": hit.entry, "score": hit.score, diff --git a/src/khoj/utils/yaml.py b/src/khoj/utils/yaml.py index abfe270a..36546688 100644 --- a/src/khoj/utils/yaml.py +++ b/src/khoj/utils/yaml.py @@ -39,7 +39,7 @@ def load_config_from_file(yaml_config_file: Path) -> dict: def parse_config_from_string(yaml_config: dict) -> FullConfig: "Parse and validate config in YML string" - return FullConfig.parse_obj(yaml_config) + return FullConfig.model_validate(yaml_config) def parse_config_from_file(yaml_config_file):