Skip to content

Commit 05fc959

Browse files
committed
refactor: Simplify defaults dictionary construction in MainAgentBuildConfig
1 parent 30952c0 commit 05fc959

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

astrbot/core/astr_main_agent.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -157,39 +157,39 @@ def from_provider_settings(
157157
proactive_cfg = ps.get("proactive_capability", {})
158158
file_extract_cfg = ps.get("file_extract", {})
159159

160-
defaults: dict = dict(
161-
tool_call_timeout=int(ps.get("tool_call_timeout", 60)),
162-
tool_schema_mode=str(ps.get("tool_schema_mode", "full")),
163-
streaming_response=bool(
160+
defaults: dict = {
161+
"tool_call_timeout": int(ps.get("tool_call_timeout", 60)),
162+
"tool_schema_mode": str(ps.get("tool_schema_mode", "full")),
163+
"streaming_response": bool(
164164
ps.get("streaming_response", ps.get("stream", False))
165165
),
166-
sanitize_context_by_modalities=bool(
166+
"sanitize_context_by_modalities": bool(
167167
ps.get("sanitize_context_by_modalities", False)
168168
),
169-
kb_agentic_mode=bool(cfg.get("kb_agentic_mode", False)),
170-
file_extract_enabled=bool(file_extract_cfg.get("enable", False)),
171-
file_extract_prov=str(file_extract_cfg.get("provider", "moonshotai")),
172-
file_extract_msh_api_key=str(
169+
"kb_agentic_mode": bool(cfg.get("kb_agentic_mode", False)),
170+
"file_extract_enabled": bool(file_extract_cfg.get("enable", False)),
171+
"file_extract_prov": str(file_extract_cfg.get("provider", "moonshotai")),
172+
"file_extract_msh_api_key": str(
173173
file_extract_cfg.get("moonshotai_api_key", "")
174174
),
175-
context_limit_reached_strategy=str(
175+
"context_limit_reached_strategy": str(
176176
ps.get("context_limit_reached_strategy", "truncate_by_turns")
177177
),
178-
llm_compress_instruction=str(ps.get("llm_compress_instruction", "")),
179-
llm_compress_keep_recent=int(ps.get("llm_compress_keep_recent", 6)),
180-
llm_compress_provider_id=str(ps.get("llm_compress_provider_id", "")),
181-
max_context_length=int(ps.get("max_context_length", -1)),
182-
dequeue_context_length=int(ps.get("dequeue_context_length", 1)),
183-
llm_safety_mode=bool(ps.get("llm_safety_mode", True)),
184-
safety_mode_strategy=str(ps.get("safety_mode_strategy", "system_prompt")),
185-
computer_use_runtime=str(ps.get("computer_use_runtime", "local")),
186-
sandbox_cfg=dict(ps.get("sandbox", {}) or {}),
187-
add_cron_tools=bool(proactive_cfg.get("add_cron_tools", True)),
188-
provider_settings=ps,
189-
subagent_orchestrator=dict(cfg.get("subagent_orchestrator", {}) or {}),
190-
timezone=cfg.get("timezone"),
191-
max_quoted_fallback_images=int(ps.get("max_quoted_fallback_images", 20)),
192-
)
178+
"llm_compress_instruction": str(ps.get("llm_compress_instruction", "")),
179+
"llm_compress_keep_recent": int(ps.get("llm_compress_keep_recent", 6)),
180+
"llm_compress_provider_id": str(ps.get("llm_compress_provider_id", "")),
181+
"max_context_length": int(ps.get("max_context_length", -1)),
182+
"dequeue_context_length": int(ps.get("dequeue_context_length", 1)),
183+
"llm_safety_mode": bool(ps.get("llm_safety_mode", True)),
184+
"safety_mode_strategy": str(ps.get("safety_mode_strategy", "system_prompt")),
185+
"computer_use_runtime": str(ps.get("computer_use_runtime", "local")),
186+
"sandbox_cfg": ps.get("sandbox", {}) or {},
187+
"add_cron_tools": bool(proactive_cfg.get("add_cron_tools", True)),
188+
"provider_settings": ps,
189+
"subagent_orchestrator": cfg.get("subagent_orchestrator", {}) or {},
190+
"timezone": cfg.get("timezone"),
191+
"max_quoted_fallback_images": int(ps.get("max_quoted_fallback_images", 20)),
192+
}
193193
defaults.update(overrides)
194194
return cls(**defaults)
195195

0 commit comments

Comments
 (0)