diff --git a/backend/app/services/embedding.py b/backend/app/services/embedding.py index fc790bd..5a1409d 100644 --- a/backend/app/services/embedding.py +++ b/backend/app/services/embedding.py @@ -16,14 +16,22 @@ _client: httpx.AsyncClient | None = None def get_client() -> httpx.AsyncClient: global _client if _client is None: - _client = httpx.AsyncClient( - base_url=OPENROUTER_BASE, - headers={ + kwargs: dict = { + "base_url": OPENROUTER_BASE, + "headers": { "Authorization": f"Bearer {settings.openrouter_api_key}", "Content-Type": "application/json", }, - timeout=30, - ) + "timeout": 30, + } + if settings.proxy_url: + proxy = settings.proxy_url + if not proxy.startswith(("http://", "https://")): + proxy = "http://" + proxy + if settings.proxy_login and settings.proxy_pass: + proxy = proxy.replace("://", f"://{settings.proxy_login}:{settings.proxy_pass}@") + kwargs["proxy"] = proxy + _client = httpx.AsyncClient(**kwargs) return _client diff --git a/docs/API.md b/docs/API.md index 38920c5..b30ffea 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1,6 +1,6 @@ # API -Базовый URL: `http:///api/v1` +Базовый URL: `http://sovet.itoservice.ru/api/v1` Авторизация: `Authorization: Bearer `