Spaces:
Runtime error
Runtime error
Download backend/agents/llm_client.py from SangDinhVan/Sang-DocAI: direct link, hf CLI and curl.
- Browser
- Download file 578 Bytes
-
https://huggingface.co/spaces/SangDinhVan/Sang-DocAI/resolve/main/backend/agents/llm_client.py
- Command line
-
hf download hf://spaces/SangDinhVan/Sang-DocAI/backend/agents/llm_client.py
-
curl -L -o llm_client.py https://huggingface.co/spaces/SangDinhVan/Sang-DocAI/resolve/main/backend/agents/llm_client.py
578 Bytes
| """ | |
| LLM client: OpenAI-compatible, truyền key và model linh hoạt. | |
| """ | |
| from __future__ import annotations | |
| from openai import OpenAI, AsyncOpenAI | |
| from backend.core.config import get_settings | |
| def get_sync_client(api_key: str | None = None) -> OpenAI: | |
| s = get_settings() | |
| return OpenAI( | |
| base_url=s.llm_base_url, | |
| api_key=api_key or s.llm_api_key, | |
| ) | |
| def get_async_client(api_key: str | None = None) -> AsyncOpenAI: | |
| s = get_settings() | |
| return AsyncOpenAI( | |
| base_url=s.llm_base_url, | |
| api_key=api_key or s.llm_api_key, | |
| ) |