mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
refactor: rename llm variables for clarity and consistency in agent initialization
This commit is contained in:
+10
-8
@@ -397,12 +397,14 @@ class MoviePilotAgent:
|
|||||||
system_prompt = prompt_manager.get_agent_prompt(channel=self.channel)
|
system_prompt = prompt_manager.get_agent_prompt(channel=self.channel)
|
||||||
|
|
||||||
# LLM 模型(用于 agent 执行)
|
# LLM 模型(用于 agent 执行)
|
||||||
model = await self._initialize_llm(streaming=streaming)
|
agent_model = await self._initialize_llm(streaming=streaming)
|
||||||
self._sync_model_profile(model)
|
self._sync_model_profile(agent_model)
|
||||||
|
|
||||||
# 为中间件内部模型调用准备非流式 LLM,避免与用户流式回复复用同一实例。
|
# 为内部模型调用准备非流式 LLM,避免与用户流式回复复用同一实例。
|
||||||
non_streaming_llm = (
|
non_streaming_model = (
|
||||||
llm if not streaming else await self._initialize_llm(streaming=False)
|
agent_model
|
||||||
|
if not streaming
|
||||||
|
else await self._initialize_llm(streaming=False)
|
||||||
)
|
)
|
||||||
|
|
||||||
# 工具列表
|
# 工具列表
|
||||||
@@ -435,7 +437,7 @@ class MoviePilotAgent:
|
|||||||
UsageMiddleware(on_usage=self._record_usage),
|
UsageMiddleware(on_usage=self._record_usage),
|
||||||
# 上下文压缩
|
# 上下文压缩
|
||||||
SummarizationMiddleware(
|
SummarizationMiddleware(
|
||||||
model=non_streaming_llm, trigger=("fraction", 0.85)
|
model=non_streaming_model, trigger=("fraction", 0.85)
|
||||||
),
|
),
|
||||||
# 错误工具调用修复
|
# 错误工具调用修复
|
||||||
PatchToolCallsMiddleware(),
|
PatchToolCallsMiddleware(),
|
||||||
@@ -445,14 +447,14 @@ class MoviePilotAgent:
|
|||||||
if max_tools > 0:
|
if max_tools > 0:
|
||||||
middlewares.append(
|
middlewares.append(
|
||||||
MoviePilotToolSelectorMiddleware(
|
MoviePilotToolSelectorMiddleware(
|
||||||
model=non_streaming_llm,
|
model=non_streaming_model,
|
||||||
max_tools=max_tools,
|
max_tools=max_tools,
|
||||||
always_include=always_include_tools,
|
always_include=always_include_tools,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return create_agent(
|
return create_agent(
|
||||||
model=llm,
|
model=agent_model,
|
||||||
tools=tools,
|
tools=tools,
|
||||||
system_prompt=system_prompt,
|
system_prompt=system_prompt,
|
||||||
middleware=middlewares,
|
middleware=middlewares,
|
||||||
|
|||||||
Reference in New Issue
Block a user