Skip to content

Commit 24c9857

Browse files
committed
test onboarding 4
1 parent f6389cb commit 24c9857

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

app/api/v1/endpoints/ai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@router.get("/health", summary="AI service availability check")
1010
async def ai_health():
1111
try:
12-
async with httpx.AsyncClient(verify=settings.CA_CERT_PATH, timeout=10.0) as client:
12+
async with httpx.AsyncClient(verify=settings.httpx_verify, timeout=10.0) as client:
1313
response = await client.get(f"{settings.AI_SERVICE_URL}/health")
1414
response.raise_for_status()
1515
data = response.json()

app/api/v1/endpoints/chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def send_message(request: ChatRequest) -> ChatResponse:
6464

6565
# AI LLM отвечает до 60 сек — таймаут 90 с запасом
6666
try:
67-
async with httpx.AsyncClient(verify=settings.CA_CERT_PATH, timeout=90.0) as client:
67+
async with httpx.AsyncClient(verify=settings.httpx_verify, timeout=90.0) as client:
6868
response = await client.post(
6969
f"{settings.AI_SERVICE_URL}/ai/process", json=payload
7070
)

app/api/v1/endpoints/onboarding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def onboarding_step(request: OnboardingRequest) -> OnboardingResponse:
7171
)
7272

7373
try:
74-
async with httpx.AsyncClient(verify=settings.CA_CERT_PATH, timeout=60.0) as client:
74+
async with httpx.AsyncClient(verify=settings.httpx_verify, timeout=60.0) as client:
7575
response = await client.post(
7676
f"{settings.AI_SERVICE_URL}/ai/onboarding",
7777
json={
@@ -106,7 +106,7 @@ async def onboarding_step(request: OnboardingRequest) -> OnboardingResponse:
106106

107107
async def _save_profile(db, login: str, ai_user_id: str) -> None:
108108
try:
109-
async with httpx.AsyncClient(verify=settings.CA_CERT_PATH, timeout=5.0) as client:
109+
async with httpx.AsyncClient(verify=settings.httpx_verify, timeout=5.0) as client:
110110
response = await client.get(
111111
f"{settings.AI_SERVICE_URL}/ai/onboarding/{ai_user_id}/status"
112112
)

app/core/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from pathlib import Path
2+
13
from pydantic_settings import BaseSettings, SettingsConfigDict
24

35

@@ -16,5 +18,10 @@ class Settings(BaseSettings):
1618
MONGODB_URI: str = "mongodb://localhost:27017"
1719
MONGODB_DB_NAME: str = "hackathon"
1820

21+
@property
22+
def httpx_verify(self) -> str | bool:
23+
path = Path(self.CA_CERT_PATH)
24+
return str(path) if path.exists() else False
25+
1926

2027
settings = Settings()

0 commit comments

Comments
 (0)