mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-12 01:04:35 +08:00
feat: 增加 MoviePilot 选项 (#6212)
This commit is contained in:
@@ -45,3 +45,42 @@ def test_resolve_llm_runtime_config_prefers_plugin_thinking_level(monkeypatch) -
|
||||
runtime_config = asyncio.run(agent._resolve_llm_runtime_config())
|
||||
|
||||
assert runtime_config["thinking_level"] == "high"
|
||||
|
||||
|
||||
def test_resolve_llm_runtime_config_uses_system_api_protocol(monkeypatch) -> None:
|
||||
"""插件未提供 API 协议时应使用系统配置。"""
|
||||
monkeypatch.setattr(settings, "LLM_API_PROTOCOL", "responses")
|
||||
agent = MoviePilotAgent(session_id="api-protocol-default", user_id="user-1")
|
||||
|
||||
async def return_empty_config(event_type, event_data):
|
||||
"""模拟插件未返回有效运行时配置。"""
|
||||
assert event_type == ChainEventType.AgentLLMProvider
|
||||
assert event_data.api_protocol == "responses"
|
||||
return SimpleNamespace(event_data=AgentLLMProviderEventData())
|
||||
|
||||
with patch(
|
||||
"app.agent.eventmanager.async_send_event",
|
||||
new=AsyncMock(side_effect=return_empty_config),
|
||||
):
|
||||
runtime_config = asyncio.run(agent._resolve_llm_runtime_config())
|
||||
|
||||
assert runtime_config["api_protocol"] == "responses"
|
||||
|
||||
|
||||
def test_resolve_llm_runtime_config_prefers_plugin_api_protocol(monkeypatch) -> None:
|
||||
"""插件显式覆盖 API 协议时应优先使用插件值。"""
|
||||
monkeypatch.setattr(settings, "LLM_API_PROTOCOL", "responses")
|
||||
agent = MoviePilotAgent(session_id="api-protocol-plugin", user_id="user-1")
|
||||
|
||||
async def override_api_protocol(_event_type, event_data):
|
||||
"""模拟插件覆盖 API 协议。"""
|
||||
event_data.api_protocol = "chat_completions"
|
||||
return SimpleNamespace(event_data=event_data)
|
||||
|
||||
with patch(
|
||||
"app.agent.eventmanager.async_send_event",
|
||||
new=AsyncMock(side_effect=override_api_protocol),
|
||||
):
|
||||
runtime_config = asyncio.run(agent._resolve_llm_runtime_config())
|
||||
|
||||
assert runtime_config["api_protocol"] == "chat_completions"
|
||||
|
||||
Reference in New Issue
Block a user