patch chat
This commit is contained in:
parent
54e4d3542e
commit
6f8bc0e762
17
app/core/http_client.py
Normal file
17
app/core/http_client.py
Normal file
@ -0,0 +1,17 @@
|
||||
import ssl
|
||||
import httpx
|
||||
|
||||
ssl_transport = httpx.AsyncHTTPTransport(http2=True)
|
||||
|
||||
# Ограничения пула соединений
|
||||
limits = httpx.Limits(max_connections=200, max_keepalive_connections=50)
|
||||
|
||||
# Таймауты
|
||||
timeout = httpx.Timeout(connect=5.0, read=10.0, write=5.0, pool=5.0)
|
||||
|
||||
# Глобальный клиент
|
||||
client = httpx.AsyncClient(
|
||||
transport=ssl_transport,
|
||||
limits=limits,
|
||||
timeout=timeout,
|
||||
)
|
||||
@ -32,7 +32,8 @@ async def get_private_chats(token: str, offset: int = 0, limit: int = 20):
|
||||
if data.get("status") == "fine":
|
||||
# Используем Pydantic модель для парсинга ответа
|
||||
response_model = PrivateChatListResponse(**data)
|
||||
print("response_model.data", response_model.data)
|
||||
# print("response_model.data", response_model.data)
|
||||
print("data", data)
|
||||
return True, response_model.data
|
||||
else:
|
||||
return False, data.get("detail", localizer.translate("Неизвестная ошибка ответа"))
|
||||
|
||||
Reference in New Issue
Block a user