mirror of
https://github.com/FuQuan233/nonebot-plugin-llmchat.git
synced 2026-09-29 01:19:28 +00:00
✨ 增加自定义User-Agent支持,允许在请求API时设置User-Agent
This commit is contained in:
parent
3320758cf9
commit
0f33591f4d
3 changed files with 4 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ class PresetConfig(BaseModel):
|
|||
max_tokens: int = Field(default=2048, description="最大响应token数")
|
||||
temperature: float = Field(default=0.7, description="生成温度(0-2]")
|
||||
proxy: str = Field(default="", description="HTTP代理服务器")
|
||||
user_agent: str = Field(default="", description="请求API时使用的自定义User-Agent")
|
||||
support_mcp: bool = Field(default=False, description="是否支持MCP")
|
||||
support_image: bool = Field(default=False, description="是否支持图片输入")
|
||||
stream: bool = Field(default=False, description="是否使用流式响应")
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue