From a02c23894cf4a7b1914d6211207403eb894b8446 Mon Sep 17 00:00:00 2001 From: "jinli.yl" Date: Tue, 17 Jun 2025 20:27:02 +0800 Subject: [PATCH] modify http client --- experiencemaker/utils/http_client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/experiencemaker/utils/http_client.py b/experiencemaker/utils/http_client.py index 245781df..4a84d485 100644 --- a/experiencemaker/utils/http_client.py +++ b/experiencemaker/utils/http_client.py @@ -4,7 +4,7 @@ from typing import Any import requests from loguru import logger -from pydantic import BaseModel, Field, PrivateAttr +from pydantic import BaseModel, Field, PrivateAttr, model_validator from experiencemaker.enumeration.http_enum import HttpEnum @@ -24,9 +24,10 @@ class HttpClient(BaseModel): _client: Any = PrivateAttr() - def __init__(self, **kwargs): - super().__init__(**kwargs) + @model_validator(mode="after") + def init_client(self): self._client = requests.Session() if self.keep_alive else requests + return self def __enter__(self): return self