✨ 增加自定义User-Agent支持,允许在请求API时设置User-Agent
Some checks failed
Pyright Lint / Pyright Lint (push) Has been cancelled
Ruff Lint / Ruff Lint (push) Has been cancelled

This commit is contained in:
FuQuan233 2026-08-24 11:23:53 +08:00
parent 3320758cf9
commit 0f33591f4d
3 changed files with 4 additions and 0 deletions

View file

@ -67,6 +67,8 @@ class ConversationService:
"api_key": preset.api_key,
"timeout": self.config.request_timeout,
}
if preset.user_agent:
options["default_headers"] = {"User-Agent": preset.user_agent}
if preset.proxy:
options["http_client"] = httpx.AsyncClient(proxy=preset.proxy)
return AsyncOpenAI(**options)