Change parse_obj calls to use model_validate per new pydantic specification

This commit is contained in:
sabaimran
2023-11-18 12:10:36 -08:00
parent ebdb423d3e
commit 5de2ab6098
3 changed files with 3 additions and 3 deletions

View File

@@ -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)

View File

@@ -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,

View File

@@ -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):