refactor: tighten backend, flows, frontend, tests; push flows to Langflow
This commit is contained in:
parent
6688fb08c6
commit
06ab25fb47
31 changed files with 783 additions and 358 deletions
27
backend/app/flows/base_client.py
Normal file
27
backend/app/flows/base_client.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""Shared base for LFX + Langflow async HTTP clients.
|
||||
|
||||
Consolidates base_url stripping, header building, per-request client
|
||||
construction, and HTTPError → domain-error mapping. Subclasses only
|
||||
declare their error types and endpoint calls.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import httpx
|
||||
|
||||
|
||||
class BaseApiClient:
|
||||
"""Thin wrapper around httpx.AsyncClient construction."""
|
||||
|
||||
def __init__(self, base_url: str, timeout: float = 60.0, api_key: str | None = None) -> None:
|
||||
self.base_url = base_url.rstrip("/")
|
||||
self.timeout = timeout
|
||||
self.api_key = api_key or ""
|
||||
|
||||
def _headers(self) -> dict[str, str]:
|
||||
return {"x-api-key": self.api_key} if self.api_key else {}
|
||||
|
||||
def _client(self) -> httpx.AsyncClient:
|
||||
return httpx.AsyncClient(
|
||||
base_url=self.base_url, timeout=self.timeout, headers=self._headers()
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue