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
|
|
@ -159,6 +159,7 @@ _✨ 支持多API预设、MCP协议、内置工具、联网搜索、视觉模型
|
||||||
| max_tokens | 否 | 2048 | 最大响应token数 |
|
| max_tokens | 否 | 2048 | 最大响应token数 |
|
||||||
| temperature | 否 | 0.7 | 生成温度 |
|
| temperature | 否 | 0.7 | 生成温度 |
|
||||||
| proxy | 否 | 无 | 请求API时使用的HTTP代理 |
|
| proxy | 否 | 无 | 请求API时使用的HTTP代理 |
|
||||||
|
| user_agent | 否 | 无 | 请求API时使用的自定义User-Agent |
|
||||||
| support_mcp | 否 | False | 是否支持MCP协议 |
|
| support_mcp | 否 | False | 是否支持MCP协议 |
|
||||||
| support_image | 否 | False | 是否支持图片输入 |
|
| support_image | 否 | False | 是否支持图片输入 |
|
||||||
| stream | 否 | False | 是否启用流式响应;普通行完成后立即发送,三反引号内容框闭合后整体发送 |
|
| stream | 否 | False | 是否启用流式响应;普通行完成后立即发送,三反引号内容框闭合后整体发送 |
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ class PresetConfig(BaseModel):
|
||||||
max_tokens: int = Field(default=2048, description="最大响应token数")
|
max_tokens: int = Field(default=2048, description="最大响应token数")
|
||||||
temperature: float = Field(default=0.7, description="生成温度(0-2]")
|
temperature: float = Field(default=0.7, description="生成温度(0-2]")
|
||||||
proxy: str = Field(default="", description="HTTP代理服务器")
|
proxy: str = Field(default="", description="HTTP代理服务器")
|
||||||
|
user_agent: str = Field(default="", description="请求API时使用的自定义User-Agent")
|
||||||
support_mcp: bool = Field(default=False, description="是否支持MCP")
|
support_mcp: bool = Field(default=False, description="是否支持MCP")
|
||||||
support_image: bool = Field(default=False, description="是否支持图片输入")
|
support_image: bool = Field(default=False, description="是否支持图片输入")
|
||||||
stream: bool = Field(default=False, description="是否使用流式响应")
|
stream: bool = Field(default=False, description="是否使用流式响应")
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ class ConversationService:
|
||||||
"api_key": preset.api_key,
|
"api_key": preset.api_key,
|
||||||
"timeout": self.config.request_timeout,
|
"timeout": self.config.request_timeout,
|
||||||
}
|
}
|
||||||
|
if preset.user_agent:
|
||||||
|
options["default_headers"] = {"User-Agent": preset.user_agent}
|
||||||
if preset.proxy:
|
if preset.proxy:
|
||||||
options["http_client"] = httpx.AsyncClient(proxy=preset.proxy)
|
options["http_client"] = httpx.AsyncClient(proxy=preset.proxy)
|
||||||
return AsyncOpenAI(**options)
|
return AsyncOpenAI(**options)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue