Compare commits

..

10 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 04b95d7bc1 style: update dark theme color scheme to match light theme
Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
2026-02-04 17:07:59 +00:00
copilot-swe-agent[bot] bb9f2623d8 refactor: extract hardcoded original_umo key to constant
Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
2026-02-03 17:16:04 +00:00
copilot-swe-agent[bot] 3091b92158 feat: restore original UMO in respond stage and update send_message_to_user tool
Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
2026-02-03 17:14:25 +00:00
copilot-swe-agent[bot] eb667d310c refactor: improve error handling in global context info function
Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
2026-02-03 17:01:47 +00:00
copilot-swe-agent[bot] b8eb110cf4 feat: add global unified context mode configuration and implementation
Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
2026-02-03 16:59:17 +00:00
copilot-swe-agent[bot] 093dab3c98 Initial plan 2026-02-03 16:54:40 +00:00
Soulter c643e3c093 chore: ruff format 2026-02-03 23:40:23 +08:00
Soulter ff46eef3b2 chore: bump version to 4.14.1 2026-02-03 23:35:21 +08:00
Soulter a0c364aa81 fix: active reply function does not work caused by event.request_llm() outdated 2026-02-03 23:34:42 +08:00
Anima-IGCenter 0e0f923a49 chore(seo): prevent indexing with noindex, nofollow (#4844) 2026-02-03 23:19:25 +08:00
13 changed files with 99 additions and 12 deletions
-1
View File
@@ -77,7 +77,6 @@ class Main(star.Star):
yield event.request_llm(
prompt=prompt,
func_tool_manager=self.context.get_llm_tool_manager(),
session_id=event.session_id,
conversation=conv,
)
@@ -49,7 +49,7 @@ class Main(Star):
if p_settings.get("empty_mention_waiting_need_reply", True):
try:
# 尝试使用 LLM 生成更生动的回复
func_tools_mgr = self.context.get_llm_tool_manager()
# func_tools_mgr = self.context.get_llm_tool_manager()
# 获取用户当前的对话信息
curr_cid = await self.context.conversation_manager.get_curr_conversation_id(
@@ -76,7 +76,6 @@ class Main(Star):
"你友好地询问用户想要聊些什么或者需要什么帮助,回复要符合人设,不要太过机械化。"
"请注意,你仅需要输出要回复用户的内容,不要输出其他任何东西"
),
func_tool_manager=func_tools_mgr,
session_id=curr_cid,
contexts=[],
system_prompt="",
+1 -1
View File
@@ -1 +1 @@
__version__ = "4.14.0"
__version__ = "4.14.1"
+35
View File
@@ -830,6 +830,38 @@ def _get_compress_provider(
return provider
def _apply_global_context_info(event: AstrMessageEvent, req: ProviderRequest) -> None:
"""Add platform and session information to user prompt when in global unified context mode."""
from astrbot.core.config.default import (
GLOBAL_UNIFIED_CONTEXT_UMO,
ORIGINAL_UMO_KEY,
)
if event.unified_msg_origin != GLOBAL_UNIFIED_CONTEXT_UMO:
return
# Get original UMO from extras
original_umo = event.get_extra(ORIGINAL_UMO_KEY)
if not original_umo:
return
# Parse the original UMO to extract platform, message type, and session info
try:
parts = original_umo.split(":", 2)
if len(parts) != 3:
logger.warning(
f"Original UMO format is invalid (expected 3 parts): {original_umo}"
)
return
platform_id, message_type, session_id = parts
context_info = f"[Context: Platform={platform_id}, Type={message_type}, Session={session_id}]"
# Prepend context info to the user prompt
req.prompt = f"{context_info} {req.prompt or ''}"
except Exception as e:
logger.warning(f"Failed to parse original UMO for global context: {e}")
async def build_main_agent(
*,
event: AstrMessageEvent,
@@ -888,6 +920,9 @@ async def build_main_agent(
if isinstance(req.contexts, str):
req.contexts = json.loads(req.contexts)
# Apply global context information if enabled
_apply_global_context_info(event, req)
if config.file_extract_enabled:
try:
await _apply_file_extract(event, req, config)
+10 -1
View File
@@ -212,6 +212,10 @@ class SendMessageToUserTool(FunctionTool[AstrAgentContext]):
"required": ["type"],
},
},
"session": {
"type": "string",
"description": "Target session ID in format 'platform:type:session_id'. If not specified, sends to the current session.",
},
},
"required": ["messages"],
}
@@ -253,7 +257,12 @@ class SendMessageToUserTool(FunctionTool[AstrAgentContext]):
async def call(
self, context: ContextWrapper[AstrAgentContext], **kwargs
) -> ToolExecResult:
session = kwargs.get("session") or context.context.event.unified_msg_origin
# In global context mode, default to original UMO if session not specified
from astrbot.core.config.default import ORIGINAL_UMO_KEY
original_umo = context.context.event.get_extra(ORIGINAL_UMO_KEY)
default_session = original_umo or context.context.event.unified_msg_origin
session = kwargs.get("session") or default_session
messages = kwargs.get("messages")
if not isinstance(messages, list) or not messages:
+7 -1
View File
@@ -5,7 +5,7 @@ from typing import Any, TypedDict
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
VERSION = "4.14.0"
VERSION = "4.14.1"
DB_PATH = os.path.join(get_astrbot_data_path(), "data_v4.db")
WEBHOOK_SUPPORTED_PLATFORMS = [
@@ -17,11 +17,17 @@ WEBHOOK_SUPPORTED_PLATFORMS = [
"lark",
]
# Constant UMO for global unified context mode
GLOBAL_UNIFIED_CONTEXT_UMO = "global::global"
# Key for storing original UMO in event extras when global context mode is enabled
ORIGINAL_UMO_KEY = "original_umo"
# 默认配置
DEFAULT_CONFIG = {
"config_version": 2,
"platform_settings": {
"unique_session": False,
"global_unified_context_mode": False,
"rate_limit": {
"time": 60,
"count": 30,
+10
View File
@@ -169,6 +169,16 @@ class RespondStage(Stage):
f"Prepare to send - {event.get_sender_name()}/{event.get_sender_id()}: {event._outline_chain(result.chain)}",
)
# Restore original UMO before sending if in global context mode
from astrbot.core.config.default import ORIGINAL_UMO_KEY
original_umo = event.get_extra(ORIGINAL_UMO_KEY)
if original_umo:
logger.debug(
f"Restoring original UMO before sending: {event.unified_msg_origin} -> {original_umo}"
)
event.unified_msg_origin = original_umo
if result.result_content_type == ResultContentType.STREAMING_RESULT:
if result.async_stream is None:
logger.warning("async_stream 为空,跳过发送。")
@@ -72,11 +72,29 @@ class WakingCheckStage(Stage):
)
platform_settings = self.ctx.astrbot_config.get("platform_settings", {})
self.unique_session = platform_settings.get("unique_session", False)
self.global_unified_context_mode = platform_settings.get(
"global_unified_context_mode", False
)
async def process(
self,
event: AstrMessageEvent,
) -> None | AsyncGenerator[None, None]:
# apply global unified context mode
if self.global_unified_context_mode:
from astrbot.core.config.default import (
GLOBAL_UNIFIED_CONTEXT_UMO,
ORIGINAL_UMO_KEY,
)
original_umo = event.unified_msg_origin
event.unified_msg_origin = GLOBAL_UNIFIED_CONTEXT_UMO
# Store original UMO for reference in later stages
event.set_extra(ORIGINAL_UMO_KEY, original_umo)
logger.debug(
f"Global unified context mode enabled. Changed UMO from {original_umo} to {GLOBAL_UNIFIED_CONTEXT_UMO}"
)
# apply unique session
if self.unique_session and event.message_obj.type == MessageType.GROUP_MESSAGE:
sid = build_unique_session_id(event)
+5 -2
View File
@@ -8,6 +8,7 @@ from time import time
from typing import Any
from astrbot import logger
from astrbot.core.agent.tool import ToolSet
from astrbot.core.db.po import Conversation
from astrbot.core.message.components import (
At,
@@ -355,6 +356,7 @@ class AstrMessageEvent(abc.ABC):
self,
prompt: str,
func_tool_manager=None,
tool_set: ToolSet | None = None,
session_id: str = "",
image_urls: list[str] | None = None,
contexts: list | None = None,
@@ -377,7 +379,7 @@ class AstrMessageEvent(abc.ABC):
contexts: 当指定 contexts 时,将会使用 contexts 作为上下文。如果同时传入了 conversation,将会忽略 conversation。
func_tool_manager: 函数工具管理器,用于调用函数工具。用 self.context.get_llm_tool_manager() 获取。
func_tool_manager: [Deprecated] 函数工具管理器,用于调用函数工具。用 self.context.get_llm_tool_manager() 获取。已过时,请使用 tool_set 参数代替。
conversation: 可选。如果指定,将在指定的对话中进行 LLM 请求。对话的人格会被用于 LLM 请求,并且结果将会被记录到对话中。
@@ -393,7 +395,8 @@ class AstrMessageEvent(abc.ABC):
prompt=prompt,
session_id=session_id,
image_urls=image_urls,
func_tool=func_tool_manager,
# func_tool=func_tool_manager,
func_tool=tool_set,
contexts=contexts,
system_prompt=system_prompt,
conversation=conversation,
+7
View File
@@ -0,0 +1,7 @@
## What's Changed - BIG AND BEAUTIFUL VERSION
hotfix of v4.14.0
fixes:
- 由 `event.request_llm()` 过时导致的群聊上下文感知-主动回复功能可能不可用的问题
+1
View File
@@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="keywords" content="AstrBot Soulter" />
<meta name="description" content="AstrBot Dashboard" />
<meta name="robots" content="noindex, nofollow" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Outfit&family=Poppins:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap"
+3 -3
View File
@@ -4,12 +4,12 @@ const PurpleThemeDark: ThemeTypes = {
name: 'PurpleThemeDark',
dark: true,
variables: {
'border-color': '#1677ff',
'border-color': '#3c96ca',
'carousel-control-size': 10
},
colors: {
primary: '#1677ff',
secondary: '#722ed1',
primary: '#3c96ca',
secondary: '#2288b7',
info: '#03c9d7',
success: '#52c41a',
accent: '#FFAB91',
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "AstrBot"
version = "4.14.0"
version = "4.14.1"
description = "Easy-to-use multi-platform LLM chatbot and development framework"
readme = "README.md"
requires-python = ">=3.10"