mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
Update internal.py
This commit is contained in:
@@ -86,23 +86,19 @@ class InternalAgentSubStage(Stage):
|
||||
self.file_extract_enabled: bool = file_extract_conf.get("enable", False)
|
||||
self.file_extract_prov: str = file_extract_conf.get("provider", "moonshotai")
|
||||
self.file_extract_msh_api_key: str = file_extract_conf.get(
|
||||
"moonshotai_api_key",
|
||||
"",
|
||||
"moonshotai_api_key", ""
|
||||
)
|
||||
|
||||
# 上下文管理相关
|
||||
self.context_limit_reached_strategy: str = settings.get(
|
||||
"context_limit_reached_strategy",
|
||||
"truncate_by_turns",
|
||||
"context_limit_reached_strategy", "truncate_by_turns"
|
||||
)
|
||||
self.llm_compress_instruction: str = settings.get(
|
||||
"llm_compress_instruction",
|
||||
"",
|
||||
"llm_compress_instruction", ""
|
||||
)
|
||||
self.llm_compress_keep_recent: int = settings.get("llm_compress_keep_recent", 4)
|
||||
self.llm_compress_provider_id: str = settings.get(
|
||||
"llm_compress_provider_id",
|
||||
"",
|
||||
"llm_compress_provider_id", ""
|
||||
)
|
||||
self.max_context_length = settings["max_context_length"] # int
|
||||
self.dequeue_context_length: int = min(
|
||||
@@ -114,8 +110,7 @@ class InternalAgentSubStage(Stage):
|
||||
|
||||
self.llm_safety_mode = settings.get("llm_safety_mode", True)
|
||||
self.safety_mode_strategy = settings.get(
|
||||
"safety_mode_strategy",
|
||||
"system_prompt",
|
||||
"safety_mode_strategy", "system_prompt"
|
||||
)
|
||||
|
||||
self.computer_use_runtime = settings.get("computer_use_runtime")
|
||||
@@ -153,9 +148,7 @@ class InternalAgentSubStage(Stage):
|
||||
)
|
||||
|
||||
async def process(
|
||||
self,
|
||||
event: AstrMessageEvent,
|
||||
provider_wake_prefix: str,
|
||||
self, event: AstrMessageEvent, provider_wake_prefix: str
|
||||
) -> AsyncGenerator[None, None]:
|
||||
follow_up_capture: FollowUpCapture | None = None
|
||||
follow_up_consumed_marked = False
|
||||
@@ -275,13 +268,13 @@ class InternalAgentSubStage(Stage):
|
||||
# 获取 TTS Provider
|
||||
tts_provider = (
|
||||
self.ctx.plugin_manager.context.get_using_tts_provider(
|
||||
event.unified_msg_origin,
|
||||
event.unified_msg_origin
|
||||
)
|
||||
)
|
||||
|
||||
if not tts_provider:
|
||||
logger.warning(
|
||||
"[Live Mode] TTS Provider 未配置,将使用普通流式模式",
|
||||
"[Live Mode] TTS Provider 未配置,将使用普通流式模式"
|
||||
)
|
||||
|
||||
# 使用 run_live_agent,总是使用流式响应
|
||||
@@ -376,7 +369,7 @@ class InternalAgentSubStage(Stage):
|
||||
req,
|
||||
agent_runner,
|
||||
final_resp,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
# 检查事件是否被停止,如果被停止则不保存历史记录
|
||||
@@ -404,7 +397,7 @@ class InternalAgentSubStage(Stage):
|
||||
except Exception as e:
|
||||
logger.error(f"Error occurred while processing agent: {e}")
|
||||
custom_error_message = extract_persona_custom_error_message_from_event(
|
||||
event,
|
||||
event
|
||||
)
|
||||
error_text = custom_error_message or (
|
||||
f"Error occurred while processing agent request: {e}"
|
||||
@@ -472,7 +465,7 @@ class InternalAgentSubStage(Stage):
|
||||
message_to_save.append(
|
||||
CheckpointMessageSegment(
|
||||
content=CheckpointData(id=checkpoint_id),
|
||||
).model_dump(),
|
||||
).model_dump()
|
||||
)
|
||||
|
||||
# if user_aborted:
|
||||
|
||||
Reference in New Issue
Block a user