Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 04b95d7bc1 | |||
| bb9f2623d8 | |||
| 3091b92158 | |||
| eb667d310c | |||
| b8eb110cf4 | |||
| 093dab3c98 | |||
| c643e3c093 | |||
| ff46eef3b2 | |||
| a0c364aa81 | |||
| 0e0f923a49 | |||
| f2d637b935 | |||
| 96e61a4a92 | |||
| e42c1b6da8 | |||
| 387bba093e | |||
| 123cf9cb11 | |||
| 93277ffac9 | |||
| c091053ea8 | |||
| 8b9f2f1e70 | |||
| 25ca7bd71e | |||
| 093b37e04b |
@@ -34,7 +34,7 @@
|
||||
<a href="https://github.com/AstrBotDevs/AstrBot/issues">问题提交</a>
|
||||
</div>
|
||||
|
||||
AstrBot 是一个开源的一站式 Agent 聊天机器人平台,可接入主流即时通讯软件,为个人、开发者和团队打造可靠、可扩展的对话式智能基础设施。无论是个人 AI 伙伴、智能客服、自动化助手,还是企业知识库,AstrBot 都能在你的即时通讯软件平台的工作流中快速构建生产可用的 AI 应用。
|
||||
AstrBot 是一个开源的一站式 Agentic 个人和群聊助手,可在 QQ、Telegram、企业微信、飞书、钉钉、Slack、等数十款主流即时通讯软件上部署,此外还内置类似 OpenWebUI 的轻量化 ChatUI,为个人、开发者和团队打造可靠、可扩展的对话式智能基础设施。无论是个人 AI 伙伴、智能客服、自动化助手,还是企业知识库,AstrBot 都能在你的即时通讯软件平台的工作流中快速构建 AI 应用。
|
||||
|
||||

|
||||
|
||||
@@ -50,6 +50,25 @@ AstrBot 是一个开源的一站式 Agent 聊天机器人平台,可接入主
|
||||
7. 🌈 Web ChatUI 支持,ChatUI 内置代理沙盒、网页搜索等。
|
||||
8. 🌐 国际化(i18n)支持。
|
||||
|
||||
<br>
|
||||
|
||||
<table align="center">
|
||||
<tr align="center">
|
||||
<th>💙 角色扮演 & 情感陪伴</th>
|
||||
<th>✨ 主动式 Agent</th>
|
||||
<th>🚀 通用 Agentic 能力</th>
|
||||
<th>🧩 900+ 社区插件</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><p align="center"><img width="984" height="1746" alt="99b587c5d35eea09d84f33e6cf6cfd4f" src="https://github.com/user-attachments/assets/89196061-3290-458d-b51f-afa178049f84" /></p></td>
|
||||
<td align="center"><p align="center"><img width="976" height="1612" alt="c449acd838c41d0915cc08a3824025b1" src="https://github.com/user-attachments/assets/f75368b4-e022-41dc-a9e0-131c3e73e32e" /></p></td>
|
||||
<td align="center"><p align="center"><img width="974" height="1732" alt="image" src="https://github.com/user-attachments/assets/e22a3968-87d7-4708-a7cd-e7f198c7c32e" /></p></td>
|
||||
<td align="center"><p align="center"><img width="976" height="1734" alt="image" src="https://github.com/user-attachments/assets/0952b395-6b4a-432a-8a50-c294b7f89750" /></p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
陪伴与能力**从来不应该是**对立面。我们希望创造的是一个既能理解情绪、给予陪伴,也能可靠完成工作的机器人——致敬[ATRI](https://zh.wikipedia.org/zh-cn/ATRI_-My_Dear_Moments-)。
|
||||
|
||||
## 快速开始
|
||||
|
||||
#### Docker 部署(推荐 🥳)
|
||||
|
||||
@@ -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 @@
|
||||
__version__ = "4.13.2"
|
||||
__version__ = "4.14.1"
|
||||
|
||||
@@ -99,6 +99,8 @@ class MainAgentBuildConfig:
|
||||
"""This will inject healthy and safe system prompt into the main agent,
|
||||
to prevent LLM output harmful information"""
|
||||
safety_mode_strategy: str = "system_prompt"
|
||||
computer_use_runtime: str = "local"
|
||||
"""The runtime for agent computer use: none, local, or sandbox."""
|
||||
sandbox_cfg: dict = field(default_factory=dict)
|
||||
add_cron_tools: bool = True
|
||||
"""This will add cron job management tools to the main agent for proactive cron job execution."""
|
||||
@@ -301,21 +303,11 @@ async def _ensure_persona_and_skills(
|
||||
req.system_prompt += CHATUI_SPECIAL_DEFAULT_PERSONA_PROMPT
|
||||
|
||||
# Inject skills prompt
|
||||
skills_cfg = cfg.get("skills", {})
|
||||
sandbox_cfg = cfg.get("sandbox", {})
|
||||
runtime = cfg.get("computer_use_runtime", "local")
|
||||
skill_manager = SkillManager()
|
||||
runtime = skills_cfg.get("runtime", "local")
|
||||
skills = skill_manager.list_skills(active_only=True, runtime=runtime)
|
||||
|
||||
if runtime == "sandbox" and not sandbox_cfg.get("enable", False):
|
||||
logger.warning(
|
||||
"Skills runtime is set to sandbox, but sandbox mode is disabled, will skip skills prompt injection.",
|
||||
)
|
||||
req.system_prompt += (
|
||||
"\n[Background: User added some skills, and skills runtime is set to sandbox, "
|
||||
"but sandbox mode is disabled. So skills will be unavailable.]\n"
|
||||
)
|
||||
elif skills:
|
||||
if skills:
|
||||
if persona and persona.get("skills") is not None:
|
||||
if not persona["skills"]:
|
||||
skills = []
|
||||
@@ -324,12 +316,12 @@ async def _ensure_persona_and_skills(
|
||||
skills = [skill for skill in skills if skill.name in allowed]
|
||||
if skills:
|
||||
req.system_prompt += f"\n{build_skills_prompt(skills)}\n"
|
||||
|
||||
runtime = skills_cfg.get("runtime", "local")
|
||||
sandbox_enabled = sandbox_cfg.get("enable", False)
|
||||
if runtime == "local" and not sandbox_enabled:
|
||||
_apply_local_env_tools(req)
|
||||
|
||||
if runtime == "none":
|
||||
req.system_prompt += (
|
||||
"User has not enabled the Computer Use feature. "
|
||||
"You cannot use shell or Python to perform skills. "
|
||||
"If you need to use these capabilities, ask the user to enable Computer Use in the AstrBot WebUI -> Config."
|
||||
)
|
||||
tmgr = plugin_context.get_llm_tool_manager()
|
||||
|
||||
# sub agents integration
|
||||
@@ -838,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,
|
||||
@@ -896,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)
|
||||
@@ -922,8 +949,10 @@ async def build_main_agent(
|
||||
if config.llm_safety_mode:
|
||||
_apply_llm_safety_mode(config, req)
|
||||
|
||||
if config.sandbox_cfg.get("enable", False):
|
||||
if config.computer_use_runtime == "sandbox":
|
||||
_apply_sandbox_tools(config, req, req.session_id)
|
||||
elif config.computer_use_runtime == "local":
|
||||
_apply_local_env_tools(req)
|
||||
|
||||
agent_runner = AgentRunner()
|
||||
astr_agent_ctx = AstrAgentContext(
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -35,12 +35,21 @@ async def _sync_skills_to_sandbox(booter: ComputerBooter) -> None:
|
||||
os.remove(zip_path)
|
||||
shutil.make_archive(zip_base, "zip", skills_root)
|
||||
remote_zip = Path(SANDBOX_SKILLS_ROOT) / "skills.zip"
|
||||
logger.info("Uploading skills bundle to sandbox...")
|
||||
await booter.shell.exec(f"mkdir -p {SANDBOX_SKILLS_ROOT}")
|
||||
upload_result = await booter.upload_file(zip_path, str(remote_zip))
|
||||
if not upload_result.get("success", False):
|
||||
raise RuntimeError("Failed to upload skills bundle to sandbox.")
|
||||
# Use -n flag to never overwrite existing files, fallback to Python if unzip unavailable
|
||||
await booter.shell.exec(
|
||||
f"unzip -o {remote_zip} -d {SANDBOX_SKILLS_ROOT} && rm -f {remote_zip}"
|
||||
f"unzip -n {remote_zip} -d {SANDBOX_SKILLS_ROOT} || "
|
||||
f"python3 -c \"import zipfile, os, pathlib; z=zipfile.ZipFile('{remote_zip}'); "
|
||||
f"[z.extract(m, '{SANDBOX_SKILLS_ROOT}') for m in z.namelist() "
|
||||
f"if not os.path.exists(os.path.join('{SANDBOX_SKILLS_ROOT}', m))]\" || "
|
||||
f"python -c \"import zipfile, os, pathlib; z=zipfile.ZipFile('{remote_zip}'); "
|
||||
f"[z.extract(m, '{SANDBOX_SKILLS_ROOT}') for m in z.namelist() "
|
||||
f"if not os.path.exists(os.path.join('{SANDBOX_SKILLS_ROOT}', m))]\"; "
|
||||
f"rm -f {remote_zip}"
|
||||
)
|
||||
finally:
|
||||
if os.path.exists(zip_path):
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import Any, TypedDict
|
||||
|
||||
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
|
||||
|
||||
VERSION = "4.13.2"
|
||||
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,
|
||||
@@ -117,15 +123,14 @@ DEFAULT_CONFIG = {
|
||||
"proactive_capability": {
|
||||
"add_cron_tools": True,
|
||||
},
|
||||
"computer_use_runtime": "local",
|
||||
"sandbox": {
|
||||
"enable": False,
|
||||
"booter": "shipyard",
|
||||
"shipyard_endpoint": "",
|
||||
"shipyard_access_token": "",
|
||||
"shipyard_ttl": 3600,
|
||||
"shipyard_max_sessions": 10,
|
||||
},
|
||||
"skills": {"runtime": "sandbox"},
|
||||
},
|
||||
# SubAgent orchestrator mode:
|
||||
# - main_enable = False: disabled; main LLM mounts tools normally (persona selection).
|
||||
@@ -2225,17 +2230,6 @@ CONFIG_METADATA_2 = {
|
||||
},
|
||||
},
|
||||
},
|
||||
"skills": {
|
||||
"type": "object",
|
||||
"items": {
|
||||
"enable": {
|
||||
"type": "bool",
|
||||
},
|
||||
"runtime": {
|
||||
"type": "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
"proactive_capability": {
|
||||
"type": "object",
|
||||
"items": {
|
||||
@@ -2516,6 +2510,7 @@ CONFIG_METADATA_3 = {
|
||||
},
|
||||
"persona": {
|
||||
"description": "人格",
|
||||
"hint": "",
|
||||
"type": "object",
|
||||
"items": {
|
||||
"provider_settings.default_personality": {
|
||||
@@ -2531,6 +2526,7 @@ CONFIG_METADATA_3 = {
|
||||
},
|
||||
"knowledgebase": {
|
||||
"description": "知识库",
|
||||
"hint": "",
|
||||
"type": "object",
|
||||
"items": {
|
||||
"kb_names": {
|
||||
@@ -2563,6 +2559,7 @@ CONFIG_METADATA_3 = {
|
||||
},
|
||||
"websearch": {
|
||||
"description": "网页搜索",
|
||||
"hint": "",
|
||||
"type": "object",
|
||||
"items": {
|
||||
"provider_settings.web_search": {
|
||||
@@ -2573,6 +2570,9 @@ CONFIG_METADATA_3 = {
|
||||
"description": "网页搜索提供商",
|
||||
"type": "string",
|
||||
"options": ["default", "tavily", "baidu_ai_search"],
|
||||
"condition": {
|
||||
"provider_settings.web_search": True,
|
||||
},
|
||||
},
|
||||
"provider_settings.websearch_tavily_key": {
|
||||
"description": "Tavily API Key",
|
||||
@@ -2581,6 +2581,7 @@ CONFIG_METADATA_3 = {
|
||||
"hint": "可添加多个 Key 进行轮询。",
|
||||
"condition": {
|
||||
"provider_settings.websearch_provider": "tavily",
|
||||
"provider_settings.web_search": True,
|
||||
},
|
||||
},
|
||||
"provider_settings.websearch_baidu_app_builder_key": {
|
||||
@@ -2594,6 +2595,73 @@ CONFIG_METADATA_3 = {
|
||||
"provider_settings.web_search_link": {
|
||||
"description": "显示来源引用",
|
||||
"type": "bool",
|
||||
"condition": {
|
||||
"provider_settings.web_search": True,
|
||||
},
|
||||
},
|
||||
},
|
||||
"condition": {
|
||||
"provider_settings.agent_runner_type": "local",
|
||||
"provider_settings.enable": True,
|
||||
},
|
||||
},
|
||||
"agent_computer_use": {
|
||||
"description": "Agent Computer Use",
|
||||
"hint": "",
|
||||
"type": "object",
|
||||
"items": {
|
||||
"provider_settings.computer_use_runtime": {
|
||||
"description": "Computer Use Runtime",
|
||||
"type": "string",
|
||||
"options": ["none", "local", "sandbox"],
|
||||
"labels": ["无", "本地", "沙箱"],
|
||||
"hint": "选择 Computer Use 运行环境。",
|
||||
},
|
||||
"provider_settings.sandbox.booter": {
|
||||
"description": "沙箱环境驱动器",
|
||||
"type": "string",
|
||||
"options": ["shipyard"],
|
||||
"labels": ["Shipyard"],
|
||||
"condition": {
|
||||
"provider_settings.computer_use_runtime": "sandbox",
|
||||
},
|
||||
},
|
||||
"provider_settings.sandbox.shipyard_endpoint": {
|
||||
"description": "Shipyard API Endpoint",
|
||||
"type": "string",
|
||||
"hint": "Shipyard 服务的 API 访问地址。",
|
||||
"condition": {
|
||||
"provider_settings.computer_use_runtime": "sandbox",
|
||||
"provider_settings.sandbox.booter": "shipyard",
|
||||
},
|
||||
"_special": "check_shipyard_connection",
|
||||
},
|
||||
"provider_settings.sandbox.shipyard_access_token": {
|
||||
"description": "Shipyard Access Token",
|
||||
"type": "string",
|
||||
"hint": "用于访问 Shipyard 服务的访问令牌。",
|
||||
"condition": {
|
||||
"provider_settings.computer_use_runtime": "sandbox",
|
||||
"provider_settings.sandbox.booter": "shipyard",
|
||||
},
|
||||
},
|
||||
"provider_settings.sandbox.shipyard_ttl": {
|
||||
"description": "Shipyard Session TTL",
|
||||
"type": "int",
|
||||
"hint": "Shipyard 会话的生存时间(秒)。",
|
||||
"condition": {
|
||||
"provider_settings.computer_use_runtime": "sandbox",
|
||||
"provider_settings.sandbox.booter": "shipyard",
|
||||
},
|
||||
},
|
||||
"provider_settings.sandbox.shipyard_max_sessions": {
|
||||
"description": "Shipyard Max Sessions",
|
||||
"type": "int",
|
||||
"hint": "Shipyard 最大会话数量。",
|
||||
"condition": {
|
||||
"provider_settings.computer_use_runtime": "sandbox",
|
||||
"provider_settings.sandbox.booter": "shipyard",
|
||||
},
|
||||
},
|
||||
},
|
||||
"condition": {
|
||||
@@ -2631,86 +2699,6 @@ CONFIG_METADATA_3 = {
|
||||
# "provider_settings.enable": True,
|
||||
# },
|
||||
# },
|
||||
"sandbox": {
|
||||
"description": "Agent 沙箱环境",
|
||||
"hint": "",
|
||||
"type": "object",
|
||||
"items": {
|
||||
"provider_settings.sandbox.enable": {
|
||||
"description": "启用沙箱环境",
|
||||
"type": "bool",
|
||||
"hint": "启用后,Agent 可以使用沙箱环境中的工具和资源,如 Python 代码执行、Shell 等。",
|
||||
},
|
||||
"provider_settings.sandbox.booter": {
|
||||
"description": "沙箱环境驱动器",
|
||||
"type": "string",
|
||||
"options": ["shipyard"],
|
||||
"labels": ["Shipyard"],
|
||||
"condition": {
|
||||
"provider_settings.sandbox.enable": True,
|
||||
},
|
||||
},
|
||||
"provider_settings.sandbox.shipyard_endpoint": {
|
||||
"description": "Shipyard API Endpoint",
|
||||
"type": "string",
|
||||
"hint": "Shipyard 服务的 API 访问地址。",
|
||||
"condition": {
|
||||
"provider_settings.sandbox.enable": True,
|
||||
"provider_settings.sandbox.booter": "shipyard",
|
||||
},
|
||||
"_special": "check_shipyard_connection",
|
||||
},
|
||||
"provider_settings.sandbox.shipyard_access_token": {
|
||||
"description": "Shipyard Access Token",
|
||||
"type": "string",
|
||||
"hint": "用于访问 Shipyard 服务的访问令牌。",
|
||||
"condition": {
|
||||
"provider_settings.sandbox.enable": True,
|
||||
"provider_settings.sandbox.booter": "shipyard",
|
||||
},
|
||||
},
|
||||
"provider_settings.sandbox.shipyard_ttl": {
|
||||
"description": "Shipyard Session TTL",
|
||||
"type": "int",
|
||||
"hint": "Shipyard 会话的生存时间(秒)。",
|
||||
"condition": {
|
||||
"provider_settings.sandbox.enable": True,
|
||||
"provider_settings.sandbox.booter": "shipyard",
|
||||
},
|
||||
},
|
||||
"provider_settings.sandbox.shipyard_max_sessions": {
|
||||
"description": "Shipyard Max Sessions",
|
||||
"type": "int",
|
||||
"hint": "Shipyard 最大会话数量。",
|
||||
"condition": {
|
||||
"provider_settings.sandbox.enable": True,
|
||||
"provider_settings.sandbox.booter": "shipyard",
|
||||
},
|
||||
},
|
||||
},
|
||||
"condition": {
|
||||
"provider_settings.agent_runner_type": "local",
|
||||
"provider_settings.enable": True,
|
||||
},
|
||||
},
|
||||
"skills": {
|
||||
"description": "Skills",
|
||||
"type": "object",
|
||||
"hint": "",
|
||||
"items": {
|
||||
"provider_settings.skills.runtime": {
|
||||
"description": "Skill Runtime",
|
||||
"type": "string",
|
||||
"options": ["local", "sandbox"],
|
||||
"labels": ["本地", "沙箱"],
|
||||
"hint": "选择 Skills 运行环境。使用沙箱时需先启用沙箱环境。",
|
||||
},
|
||||
},
|
||||
"condition": {
|
||||
"provider_settings.agent_runner_type": "local",
|
||||
"provider_settings.enable": True,
|
||||
},
|
||||
},
|
||||
"proactive_capability": {
|
||||
"description": "主动型 Agent",
|
||||
"hint": "https://docs.astrbot.app/use/proactive-agent.html",
|
||||
|
||||
@@ -92,6 +92,7 @@ class InternalAgentSubStage(Stage):
|
||||
"safety_mode_strategy", "system_prompt"
|
||||
)
|
||||
|
||||
self.computer_use_runtime = settings.get("computer_use_runtime")
|
||||
self.sandbox_cfg = settings.get("sandbox", {})
|
||||
|
||||
# Proactive capability configuration
|
||||
@@ -116,6 +117,7 @@ class InternalAgentSubStage(Stage):
|
||||
dequeue_context_length=self.dequeue_context_length,
|
||||
llm_safety_mode=self.llm_safety_mode,
|
||||
safety_mode_strategy=self.safety_mode_strategy,
|
||||
computer_use_runtime=self.computer_use_runtime,
|
||||
sandbox_cfg=self.sandbox_cfg,
|
||||
add_cron_tools=self.add_cron_tools,
|
||||
provider_settings=settings,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -37,9 +37,9 @@ class CustomFilter(HandlerFilter, metaclass=CustomFilterMeta):
|
||||
class CustomFilterOr(CustomFilter):
|
||||
def __init__(self, filter1: CustomFilter, filter2: CustomFilter):
|
||||
super().__init__()
|
||||
if not isinstance(filter1, CustomFilter | CustomFilterAnd | CustomFilterOr):
|
||||
if not isinstance(filter1, (CustomFilter, CustomFilterAnd, CustomFilterOr)):
|
||||
raise ValueError(
|
||||
"CustomFilter lass can only operate with other CustomFilter.",
|
||||
"CustomFilter class can only operate with other CustomFilter.",
|
||||
)
|
||||
self.filter1 = filter1
|
||||
self.filter2 = filter2
|
||||
@@ -51,7 +51,7 @@ class CustomFilterOr(CustomFilter):
|
||||
class CustomFilterAnd(CustomFilter):
|
||||
def __init__(self, filter1: CustomFilter, filter2: CustomFilter):
|
||||
super().__init__()
|
||||
if not isinstance(filter1, CustomFilter | CustomFilterAnd | CustomFilterOr):
|
||||
if not isinstance(filter1, (CustomFilter, CustomFilterAnd, CustomFilterOr)):
|
||||
raise ValueError(
|
||||
"CustomFilter lass can only operate with other CustomFilter.",
|
||||
)
|
||||
|
||||
@@ -150,7 +150,7 @@ def register_custom_filter(custom_type_filter, *args, **kwargs):
|
||||
if args:
|
||||
raise_error = args[0]
|
||||
|
||||
if not isinstance(custom_filter, CustomFilterAnd | CustomFilterOr):
|
||||
if not isinstance(custom_filter, (CustomFilterAnd, CustomFilterOr)):
|
||||
custom_filter = custom_filter(raise_error)
|
||||
|
||||
def decorator(awaitable):
|
||||
|
||||
@@ -315,6 +315,17 @@ class PluginRoute(Route):
|
||||
"display_name": plugin.display_name,
|
||||
"logo": f"/api/file/{logo_url}" if logo_url else None,
|
||||
}
|
||||
# 检查是否为全空的幽灵插件
|
||||
if not any(
|
||||
[
|
||||
plugin.name,
|
||||
plugin.author,
|
||||
plugin.desc,
|
||||
plugin.version,
|
||||
plugin.display_name,
|
||||
]
|
||||
):
|
||||
continue
|
||||
_plugin_resp.append(_t)
|
||||
return (
|
||||
Response()
|
||||
|
||||
@@ -24,14 +24,22 @@ class SkillsRoute(Route):
|
||||
|
||||
async def get_skills(self):
|
||||
try:
|
||||
cfg = self.core_lifecycle.astrbot_config.get("provider_settings", {}).get(
|
||||
"skills", {}
|
||||
provider_settings = self.core_lifecycle.astrbot_config.get(
|
||||
"provider_settings", {}
|
||||
)
|
||||
runtime = cfg.get("runtime", "local")
|
||||
runtime = provider_settings.get("computer_use_runtime", "local")
|
||||
skills = SkillManager().list_skills(
|
||||
active_only=False, runtime=runtime, show_sandbox_path=False
|
||||
)
|
||||
return Response().ok([skill.__dict__ for skill in skills]).__dict__
|
||||
return (
|
||||
Response()
|
||||
.ok(
|
||||
{
|
||||
"skills": [skill.__dict__ for skill in skills],
|
||||
}
|
||||
)
|
||||
.__dict__
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(traceback.format_exc())
|
||||
return Response().error(str(e)).__dict__
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
## What's Changed - BIG AND BEAUTIFUL VERSION
|
||||
|
||||
> 如果在之前版本使用了 Skill,这次更新之后**需要重新配置** Skill Runtime 相关选项。
|
||||
|
||||
### 新增
|
||||
- 🔥 新增未来任务系统(Future Tasks)。给 AstrBot 布置的未来任务,让 AstrBot 能够在某一时刻自动唤醒,帮你完成任务。详见 [主动任务](https://docs.astrbot.app/use/proactive-agent.html) 。(实验性) ([#4697](https://github.com/AstrBotDevs/AstrBot/issues/4831))
|
||||
- 🔥 新增子代理(SubAgent)编排器。(实验性)([#4697](https://github.com/AstrBotDevs/AstrBot/issues/4831))
|
||||
- 🔥 AstrBot 目前可以直接通过调用 tool 将图片 / 文件推送给用户,大大提高交互效果。
|
||||
- 新增 Computer Use 运行时配置,以融合 Skill 和 Sandbox 配置 ([#4831](https://github.com/AstrBotDevs/AstrBot/issues/4831))
|
||||
- 新增主题自定义功能,可设置主色与辅色
|
||||
- 支持在配置页下人格对话框的编辑人格 ([#4826](https://github.com/AstrBotDevs/AstrBot/issues/4826))
|
||||
- 支持开关 “追踪” 功能;支持在系统配置中设置是否将日志写入 log 文件 ([#4822](https://github.com/AstrBotDevs/AstrBot/issues/4822))
|
||||
|
||||
### 修复
|
||||
- ‼️ 修复 ChatUI 图片、思考等显示异常问题。
|
||||
- ‼️ 修复 Skill 上传到 Sandbox 后未自动解压导致 Agent 无法读取的问题。
|
||||
- ‼️ 修复配置特定插件集时 MCP 工具被过滤的问题 ([#4825](https://github.com/AstrBotDevs/AstrBot/issues/4825))
|
||||
- ‼️ 移除 ChatUI 自带的让 LLM 最后提出问题的 prompt ([#4824](https://github.com/AstrBotDevs/AstrBot/issues/4824))
|
||||
- ‼️ 修复 WebUI 在上传 Skill 失败后仍显示成功消息的 bug ([#4768](https://github.com/AstrBotDevs/AstrBot/issues/4768))
|
||||
- 修复 MCP 服务器无法重命名的问题 ([#4766](https://github.com/AstrBotDevs/AstrBot/issues/4766))
|
||||
- 修复插件的 tool 无法在 WebUI 管理行为中看到来源的问题 ([#4776](https://github.com/AstrBotDevs/AstrBot/issues/4776))
|
||||
- ‼️ 修复 skill-like 的 tool 模式下,调用 tool 失败的问题 ([#4775](https://github.com/AstrBotDevs/AstrBot/issues/4775))
|
||||
|
||||
### 优化
|
||||
|
||||
- WebUI 整体 UI 效果优化
|
||||
- 部分 Dialog 标题样式统一
|
||||
|
||||
## What's Changed (EN)
|
||||
|
||||
### New Features
|
||||
- Introduce CronJob system with one-time tasks and enhanced dashboard management
|
||||
- Add theme customization with primary & secondary color options
|
||||
- Add computer-use runtime config for skills sandbox execution ([#4831](https://github.com/AstrBotDevs/AstrBot/issues/4831))
|
||||
- Add edit button to persona selector dialog ([#4826](https://github.com/AstrBotDevs/AstrBot/issues/4826))
|
||||
- Add trace logging toggle and configuration UI ([#4822](https://github.com/AstrBotDevs/AstrBot/issues/4822))
|
||||
- Add proactive-messaging capability with cron-tool trigger
|
||||
- Implement SubAgent orchestrator with configurable tool-management policies
|
||||
- Support resolving sandbox file paths and auto-download when necessary
|
||||
- Add embedded image & audio styles in MessagePartsRenderer
|
||||
- Introduce i18n foundation
|
||||
- Persist agent-interaction history
|
||||
- Add user notifications for file-download success/removal
|
||||
|
||||
### Bug Fixes
|
||||
- Improve ghost-plugin detection accuracy
|
||||
- Add error handling to prevent ghost-plugin crashes
|
||||
- Prevent skills bundle from overwriting existing files
|
||||
- Fix skills bundle unzip failure inside sandbox
|
||||
- Fix MCP tools being filtered when specific plugin set configured ([#4825](https://github.com/AstrBotDevs/AstrBot/issues/4825))
|
||||
- Merge ChatUI persona pop-up into default persona ([#4824](https://github.com/AstrBotDevs/AstrBot/issues/4824))
|
||||
- Fix reasoning block style
|
||||
- Add missing comma in truncate_and_compress hint
|
||||
- Fix frontend still showing success message ([#4768](https://github.com/AstrBotDevs/AstrBot/issues/4768))
|
||||
- Fix unable to rename MCP server ([#4766](https://github.com/AstrBotDevs/AstrBot/issues/4766))
|
||||
- Remove leftover sandbox runtime handling in skill upload ([#4798](https://github.com/AstrBotDevs/AstrBot/issues/4798))
|
||||
- Fix handler module path construction ([#4776](https://github.com/AstrBotDevs/AstrBot/issues/4776))
|
||||
- Fix skill-like tool invocation error ([#4775](https://github.com/AstrBotDevs/AstrBot/issues/4775))
|
||||
|
||||
### Improvements
|
||||
- Runtime hints & refined UI in skills management
|
||||
- Performance and UX improvements on cron-job page
|
||||
- General WebUI performance boost
|
||||
- Group tools by plugin in dropdown
|
||||
- Consistent dialog titles with padding and text styles
|
||||
- Code formatting unified (ruff format)
|
||||
- Bump version to 4.13.2
|
||||
|
||||
### Others
|
||||
- Remove obsolete reminder code
|
||||
- Extract main-agent module for better architecture
|
||||
- Merge AstrBot_skill branch changes
|
||||
@@ -0,0 +1,7 @@
|
||||
## What's Changed - BIG AND BEAUTIFUL VERSION
|
||||
|
||||
hotfix of v4.14.0
|
||||
|
||||
fixes:
|
||||
|
||||
- 由 `event.request_llm()` 过时导致的群聊上下文感知-主动回复功能可能不可用的问题
|
||||
@@ -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"
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"markdown-it": "^14.1.0",
|
||||
"markstream-vue": "^0.0.6",
|
||||
"mermaid": "^11.12.2",
|
||||
"monaco-editor": "^0.55.1",
|
||||
"monaco-editor": "^0.52.2",
|
||||
"pinia": "2.1.6",
|
||||
"pinyin-pro": "^3.26.0",
|
||||
"remixicon": "3.5.0",
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
<v-container fluid class="pa-0" elevation="0">
|
||||
<v-row class="d-flex justify-space-between align-center px-4 py-3 pb-8">
|
||||
<div>
|
||||
<v-btn color="success" prepend-icon="mdi-upload" class="me-2" variant="tonal"
|
||||
@click="uploadDialog = true">
|
||||
<v-btn color="success" prepend-icon="mdi-upload" class="me-2" variant="tonal" @click="uploadDialog = true">
|
||||
{{ tm('skills.upload') }}
|
||||
</v-btn>
|
||||
<v-btn color="primary" prepend-icon="mdi-refresh" variant="tonal" @click="fetchSkills">
|
||||
@@ -13,6 +12,10 @@
|
||||
</div>
|
||||
</v-row>
|
||||
|
||||
<div class="px-2 pb-2">
|
||||
<small style="color: grey;">{{ tm('skills.runtimeHint') }}</small>
|
||||
</div>
|
||||
|
||||
<v-progress-linear v-if="loading" indeterminate color="primary"></v-progress-linear>
|
||||
|
||||
<div v-else-if="skills.length === 0" class="text-center pa-8">
|
||||
@@ -45,8 +48,8 @@
|
||||
<v-card-title class="text-h3 pa-4 pb-0 pl-6">{{ tm('skills.uploadDialogTitle') }}</v-card-title>
|
||||
<v-card-text>
|
||||
<small class="text-grey">{{ tm('skills.uploadHint') }}</small>
|
||||
<v-file-input v-model="uploadFile" accept=".zip" :label="tm('skills.selectFile')" prepend-icon="mdi-folder-zip-outline"
|
||||
variant="outlined" class="mt-4" :multiple="false" />
|
||||
<v-file-input v-model="uploadFile" accept=".zip" :label="tm('skills.selectFile')"
|
||||
prepend-icon="mdi-folder-zip-outline" variant="outlined" class="mt-4" :multiple="false" />
|
||||
</v-card-text>
|
||||
<v-card-actions class="d-flex justify-end">
|
||||
<v-btn variant="text" @click="uploadDialog = false">{{ tm('skills.cancel') }}</v-btn>
|
||||
@@ -110,7 +113,12 @@ export default {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await axios.get("/api/skills");
|
||||
skills.value = res.data.data || [];
|
||||
const payload = res.data?.data || [];
|
||||
if (Array.isArray(payload)) {
|
||||
skills.value = payload;
|
||||
} else {
|
||||
skills.value = payload.skills || [];
|
||||
}
|
||||
} catch (err) {
|
||||
showMessage(tm("skills.loadFailed"), "error");
|
||||
} finally {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script setup>
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import { VueMonacoEditor } from '@guolao/vue-monaco-editor'
|
||||
import { ref, computed } from 'vue'
|
||||
import ConfigItemRenderer from './ConfigItemRenderer.vue'
|
||||
@@ -24,12 +25,23 @@ const props = defineProps({
|
||||
const { t } = useI18n()
|
||||
const { tm, getRaw } = useModuleI18n('features/config-metadata')
|
||||
|
||||
const hintMarkdown = new MarkdownIt({
|
||||
linkify: true,
|
||||
breaks: true
|
||||
})
|
||||
|
||||
// 翻译器函数 - 如果是国际化键则翻译,否则原样返回
|
||||
const translateIfKey = (value) => {
|
||||
if (!value || typeof value !== 'string') return value
|
||||
return tm(value)
|
||||
}
|
||||
|
||||
const renderHint = (value) => {
|
||||
const text = translateIfKey(value)
|
||||
if (!text) return ''
|
||||
return hintMarkdown.renderInline(text)
|
||||
}
|
||||
|
||||
// 处理labels翻译 - labels可以是数组或国际化键
|
||||
const getTranslatedLabels = (itemMeta) => {
|
||||
if (!itemMeta?.labels) return null
|
||||
@@ -185,7 +197,7 @@ function getSpecialSubtype(value) {
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="config-hint">
|
||||
<span v-if="metadata[metadataKey]?.obvious_hint && metadata[metadataKey]?.hint" class="important-hint">‼️</span>
|
||||
{{ translateIfKey(metadata[metadataKey]?.hint) }}
|
||||
<span v-html="renderHint(metadata[metadataKey]?.hint)"></span>
|
||||
</v-list-item-subtitle>
|
||||
</v-card-text>
|
||||
|
||||
@@ -205,7 +217,7 @@ function getSpecialSubtype(value) {
|
||||
|
||||
<v-list-item-subtitle class="property-hint">
|
||||
<span v-if="itemMeta?.obvious_hint && itemMeta?.hint" class="important-hint">‼️</span>
|
||||
{{ translateIfKey(itemMeta?.hint) }}
|
||||
<span v-html="renderHint(itemMeta?.hint)"></span>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
</v-col>
|
||||
@@ -293,6 +305,12 @@ function getSpecialSubtype(value) {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.config-hint :deep(a),
|
||||
.property-hint :deep(a) {
|
||||
color: var(--v-theme-primary);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.metadata-key,
|
||||
.property-key {
|
||||
font-size: 0.85em;
|
||||
|
||||
@@ -530,8 +530,13 @@ export default {
|
||||
try {
|
||||
const response = await axios.get('/api/skills');
|
||||
if (response.data.status === 'ok') {
|
||||
const skills = response.data.data || [];
|
||||
this.availableSkills = skills.filter(skill => skill.active !== false);
|
||||
const payload = response.data.data || [];
|
||||
if (Array.isArray(payload)) {
|
||||
this.availableSkills = payload.filter(skill => skill.active !== false);
|
||||
} else {
|
||||
const skills = payload.skills || [];
|
||||
this.availableSkills = skills.filter(skill => skill.active !== false);
|
||||
}
|
||||
} else {
|
||||
this.$emit('error', response.data.message || 'Failed to load skills');
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
},
|
||||
"websearch_baidu_app_builder_key": {
|
||||
"description": "Baidu Qianfan Smart Cloud APP Builder API Key",
|
||||
"hint": "Reference: https://console.bce.baidu.com/iam/#/iam/apikey/list"
|
||||
"hint": "Reference: [https://console.bce.baidu.com/iam/#/iam/apikey/list](https://console.bce.baidu.com/iam/#/iam/apikey/list)"
|
||||
},
|
||||
"web_search_link": {
|
||||
"description": "Display Source Citations"
|
||||
@@ -133,15 +133,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"sandbox": {
|
||||
"description": "Agent Sandbox Env(Beta)",
|
||||
"hint": "https://docs.astrbot.app/en/use/astrbot-agent-sandbox.html",
|
||||
"agent_computer_use": {
|
||||
"description": "Agent Computer Use",
|
||||
"hint": "Allows the AstrBot to access and use your computer or an sandbox environment to perform more complex tasks. See [Sandbox Mode](https://docs.astrbot.app/use/astrbot-agent-sandbox.html), [Skills](https://docs.astrbot.app/use/skills.html)",
|
||||
"provider_settings": {
|
||||
"computer_use_runtime": {
|
||||
"description": "Computer Use Runtime",
|
||||
"hint": "sandbox means running in a sandbox environment, local means running in a local environment, none means disabling Computer Use. If skills are uploaded, choosing none will cause them to not be usable by the Agent."
|
||||
},
|
||||
"sandbox": {
|
||||
"enable": {
|
||||
"description": "Enable Sandbox Env",
|
||||
"hint": "When enabled, Agent can use tools and resources in the sandbox environment, such as Python tool, Shell, etc."
|
||||
},
|
||||
"booter": {
|
||||
"description": "Sandbox Environment Driver"
|
||||
},
|
||||
@@ -164,21 +164,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"skills": {
|
||||
"hint": "https://docs.astrbot.app/use/skills.html",
|
||||
"description": "Skills",
|
||||
"provider_settings": {
|
||||
"skills": {
|
||||
"runtime": {
|
||||
"description": "Skill Runtime",
|
||||
"hint": "Select the runtime for Skills. Sandbox runtime requires sandbox to be enabled first. In local mode, the Agent CAN FULLY ACCESS the runtime environment through Shell and Python tools, but non-admin users will be automatically prohibited from using it to ensure security."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"proactive_capability": {
|
||||
"description": "Proactive Agent",
|
||||
"hint": "https://docs.astrbot.app/en/use/proactive-agent.html",
|
||||
"hint": "AstrBot will wake up, run your tasks, and deliver the results to you. See [Proactive Agent](https://docs.astrbot.app/en/use/proactive-agent.html)",
|
||||
"provider_settings": {
|
||||
"proactive_capability": {
|
||||
"add_cron_tools": {
|
||||
@@ -189,7 +177,7 @@
|
||||
}
|
||||
},
|
||||
"truncate_and_compress": {
|
||||
"hint": "https://docs.astrbot.app/en/use/context-compress.html",
|
||||
"hint": "[Context Management](https://docs.astrbot.app/en/use/context-compress.html)",
|
||||
"description": "Context Management Strategy",
|
||||
"provider_settings": {
|
||||
"max_context_length": {
|
||||
@@ -440,7 +428,7 @@
|
||||
},
|
||||
"emojis": {
|
||||
"description": "Emoji List (Lark Emoji Enum Names)",
|
||||
"hint": "Emoji enum names reference: https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce"
|
||||
"hint": "Emoji enum names reference: [https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce](https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce)"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -451,7 +439,7 @@
|
||||
},
|
||||
"emojis": {
|
||||
"description": "Emoji List (Unicode)",
|
||||
"hint": "Telegram only supports a fixed reaction set, reference: https://gist.github.com/Soulter/3f22c8e5f9c7e152e967e8bc28c97fc9"
|
||||
"hint": "Telegram only supports a fixed reaction set, reference: [https://gist.github.com/Soulter/3f22c8e5f9c7e152e967e8bc28c97fc9](https://gist.github.com/Soulter/3f22c8e5f9c7e152e967e8bc28c97fc9)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -608,15 +596,15 @@
|
||||
},
|
||||
"pypi_index_url": {
|
||||
"description": "PyPI Repository URL",
|
||||
"hint": "PyPI repository URL for installing Python dependencies. Defaults to https://mirrors.aliyun.com/pypi/simple/"
|
||||
"hint": "PyPI repository URL for installing Python dependencies. Defaults to [https://mirrors.aliyun.com/pypi/simple/](https://mirrors.aliyun.com/pypi/simple/)"
|
||||
},
|
||||
"callback_api_base": {
|
||||
"description": "Externally Accessible Callback API Address",
|
||||
"hint": "External services may access AstrBot's backend through callback links generated by AstrBot (such as file download links). Since AstrBot cannot automatically determine the externally accessible host address in the deployment environment, this configuration item is needed to explicitly specify how external services should access AstrBot's address. Examples: http://localhost:6185, https://example.com, etc."
|
||||
"hint": "External services may access AstrBot's backend through callback links generated by AstrBot (such as file download links). Since AstrBot cannot automatically determine the externally accessible host address in the deployment environment, this configuration item is needed to explicitly specify how external services should access AstrBot's address. Examples: [http://localhost:6185](http://localhost:6185), [https://example.com](https://example.com), etc."
|
||||
},
|
||||
"timezone": {
|
||||
"description": "Timezone",
|
||||
"hint": "Timezone setting. Please enter an IANA timezone name, such as Asia/Shanghai. Uses system default timezone when empty. For all timezones, see: https://data.iana.org/time-zones/tzdb-2021a/zone1970.tab"
|
||||
"hint": "Timezone setting. Please enter an IANA timezone name, such as Asia/Shanghai. Uses system default timezone when empty. For all timezones, see: [https://data.iana.org/time-zones/tzdb-2021a/zone1970.tab](https://data.iana.org/time-zones/tzdb-2021a/zone1970.tab)"
|
||||
},
|
||||
"http_proxy": {
|
||||
"description": "HTTP Proxy",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"page": {
|
||||
"title": "Future Task Management",
|
||||
"beta": "Beta",
|
||||
"beta": "Experimental",
|
||||
"subtitle": "See scheduled tasks for AstrBot. AstrBot will wake up, run them, and deliver the results.",
|
||||
"proactive": {
|
||||
"supported": "Proactive delivery is available on: {platforms}",
|
||||
@@ -22,6 +22,7 @@
|
||||
"name": "Name",
|
||||
"type": "Type",
|
||||
"cron": "Cron",
|
||||
"session": "Session ID",
|
||||
"nextRun": "Next Run",
|
||||
"lastRun": "Last Run",
|
||||
"note": "Note",
|
||||
@@ -39,6 +40,7 @@
|
||||
},
|
||||
"form": {
|
||||
"title": "New Task",
|
||||
"chatHint": "You can ask AstrBot in chat to create future tasks instead of adding them here.",
|
||||
"runOnce": "One-off task",
|
||||
"name": "Task name",
|
||||
"note": "Task description",
|
||||
|
||||
@@ -210,7 +210,9 @@
|
||||
"deleteTitle": "Delete confirmation",
|
||||
"deleteMessage": "Are you sure you want to delete this Skill?",
|
||||
"deleteSuccess": "Deleted successfully",
|
||||
"deleteFailed": "Delete failed"
|
||||
"deleteFailed": "Delete failed",
|
||||
"runtimeNoneWarning": "Computer Use runtime is set to None; Skills may not run correctly because no runtime is enabled.",
|
||||
"runtimeHint": "Set the Computer Use runtime to Local or Sandbox in settings so AstrBot can use your Skills."
|
||||
},
|
||||
"card": {
|
||||
"actions": {
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
"loadingSkills": "Loading skills...",
|
||||
"allSkillsAvailable": "Use all available Skills",
|
||||
"noSkillsSelected": "No skills selected",
|
||||
"skillsRuntimeNoneWarning": "Computer Use runtime is set to None; Skills may not run correctly because no runtime is enabled.",
|
||||
"createInFolder": "Will be created in \"{folder}\"",
|
||||
"rootFolder": "All Personas"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"page": {
|
||||
"title": "SubAgent Orchestration",
|
||||
"beta": "Beta",
|
||||
"beta": "Experimental",
|
||||
"subtitle": "The main LLM only chats and delegates; tools live on individual SubAgents."
|
||||
},
|
||||
"actions": {
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
},
|
||||
"persona": {
|
||||
"description": "人格",
|
||||
"hint": "赋予 AstrBot 人格。",
|
||||
"provider_settings": {
|
||||
"default_personality": {
|
||||
"description": "默认采用的人格"
|
||||
@@ -78,6 +79,7 @@
|
||||
},
|
||||
"knowledgebase": {
|
||||
"description": "知识库",
|
||||
"hint": "AstrBot 的 “外置大脑”。",
|
||||
"kb_names": {
|
||||
"description": "知识库列表",
|
||||
"hint": "支持多选"
|
||||
@@ -97,6 +99,7 @@
|
||||
},
|
||||
"websearch": {
|
||||
"description": "网页搜索",
|
||||
"hint": "让 AstrBot 能够访问互联网,获悉时讯。",
|
||||
"provider_settings": {
|
||||
"web_search": {
|
||||
"description": "启用网页搜索"
|
||||
@@ -110,7 +113,7 @@
|
||||
},
|
||||
"websearch_baidu_app_builder_key": {
|
||||
"description": "百度千帆智能云 APP Builder API Key",
|
||||
"hint": "参考:https://console.bce.baidu.com/iam/#/iam/apikey/list"
|
||||
"hint": "参考:[https://console.bce.baidu.com/iam/#/iam/apikey/list](https://console.bce.baidu.com/iam/#/iam/apikey/list)"
|
||||
},
|
||||
"web_search_link": {
|
||||
"description": "显示来源引用"
|
||||
@@ -133,15 +136,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"sandbox": {
|
||||
"description": "Agent 沙箱环境(Beta)",
|
||||
"hint": "https://docs.astrbot.app/use/astrbot-agent-sandbox.html",
|
||||
"agent_computer_use": {
|
||||
"description": "使用电脑能力",
|
||||
"hint": "让 AstrBot 访问和使用你的电脑或者隔离的沙盒环境,以执行更复杂的任务。详见: [沙盒模式](https://docs.astrbot.app/use/astrbot-agent-sandbox.html), [Skills](https://docs.astrbot.app/use/skills.html)。",
|
||||
"provider_settings": {
|
||||
"computer_use_runtime": {
|
||||
"description": "运行环境",
|
||||
"hint": "sandbox 代表在沙箱环境中运行, local 代表在本地环境中运行, none 代表不启用。如果上传了 skills,选择 none 会导致其无法被 Agent 正常使用。"
|
||||
},
|
||||
"sandbox": {
|
||||
"enable": {
|
||||
"description": "启用沙箱环境",
|
||||
"hint": "启用后,Agent 可以使用沙箱环境中的工具和资源,如 Python 代码执行、Shell 等。"
|
||||
},
|
||||
"booter": {
|
||||
"description": "沙箱环境驱动器"
|
||||
},
|
||||
@@ -164,21 +167,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"skills": {
|
||||
"hint": "https://docs.astrbot.app/en/use/skills.html",
|
||||
"description": "Skills",
|
||||
"provider_settings": {
|
||||
"skills": {
|
||||
"runtime": {
|
||||
"description": "Skill Runtime",
|
||||
"hint": "选择 Skills 运行环境。使用 sandbox 前需启用沙箱;local 模式下 Agent 可通过 Shell 和 Python 功能完全访问运行环境,非管理员将被自动禁止使用以保证安全。"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"proactive_capability": {
|
||||
"description": "主动型 Agent",
|
||||
"hint": "https://docs.astrbot.app/use/proactive-agent.html",
|
||||
"description": "主动型能力",
|
||||
"hint": "让 AstrBot 能够在某一时刻自动唤醒,帮你完成任务。详见: [主动型 Agent](https://docs.astrbot.app/use/proactive-agent.html)。",
|
||||
"provider_settings": {
|
||||
"proactive_capability": {
|
||||
"add_cron_tools": {
|
||||
@@ -189,7 +180,7 @@
|
||||
}
|
||||
},
|
||||
"truncate_and_compress": {
|
||||
"hint": "https://docs.astrbot.app/use/context-compress.html",
|
||||
"hint": "AstrBot 如何管理工作记忆。详见: [上下文管理策略](https://docs.astrbot.app/use/context-compress.html)。",
|
||||
"description": "上下文管理策略",
|
||||
"provider_settings": {
|
||||
"max_context_length": {
|
||||
@@ -438,7 +429,7 @@
|
||||
},
|
||||
"emojis": {
|
||||
"description": "表情列表(飞书表情枚举名)",
|
||||
"hint": "表情枚举名参考:https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce"
|
||||
"hint": "表情枚举名参考:[https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce](https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce)"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -449,7 +440,7 @@
|
||||
},
|
||||
"emojis": {
|
||||
"description": "表情列表(Unicode)",
|
||||
"hint": "Telegram 仅支持固定反应集合,参考:https://gist.github.com/Soulter/3f22c8e5f9c7e152e967e8bc28c97fc9"
|
||||
"hint": "Telegram 仅支持固定反应集合,参考:[https://gist.github.com/Soulter/3f22c8e5f9c7e152e967e8bc28c97fc9](https://gist.github.com/Soulter/3f22c8e5f9c7e152e967e8bc28c97fc9)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -606,15 +597,15 @@
|
||||
},
|
||||
"pypi_index_url": {
|
||||
"description": "PyPI 软件仓库地址",
|
||||
"hint": "安装 Python 依赖时请求的 PyPI 软件仓库地址。默认为 https://mirrors.aliyun.com/pypi/simple/"
|
||||
"hint": "安装 Python 依赖时请求的 PyPI 软件仓库地址。默认为 [https://mirrors.aliyun.com/pypi/simple/](https://mirrors.aliyun.com/pypi/simple/)"
|
||||
},
|
||||
"callback_api_base": {
|
||||
"description": "对外可达的回调接口地址",
|
||||
"hint": "外部服务可能会通过 AstrBot 生成的回调链接(如文件下载链接)访问 AstrBot 后端。由于 AstrBot 无法自动判断部署环境中对外可达的主机地址(host),因此需要通过此配置项显式指定外部服务如何访问 AstrBot 的地址。如 http://localhost:6185,https://example.com 等。"
|
||||
"hint": "外部服务可能会通过 AstrBot 生成的回调链接(如文件下载链接)访问 AstrBot 后端。由于 AstrBot 无法自动判断部署环境中对外可达的主机地址(host),因此需要通过此配置项显式指定外部服务如何访问 AstrBot 的地址。如 [http://localhost:6185](http://localhost:6185),[https://example.com](https://example.com) 等。"
|
||||
},
|
||||
"timezone": {
|
||||
"description": "时区",
|
||||
"hint": "时区设置。请填写 IANA 时区名称, 如 Asia/Shanghai, 为空时使用系统默认时区。所有时区请查看: https://data.iana.org/time-zones/tzdb-2021a/zone1970.tab"
|
||||
"hint": "时区设置。请填写 IANA 时区名称, 如 Asia/Shanghai, 为空时使用系统默认时区。所有时区请查看: [https://data.iana.org/time-zones/tzdb-2021a/zone1970.tab](https://data.iana.org/time-zones/tzdb-2021a/zone1970.tab)"
|
||||
},
|
||||
"http_proxy": {
|
||||
"description": "HTTP 代理",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"page": {
|
||||
"title": "未来任务管理",
|
||||
"beta": "Beta",
|
||||
"subtitle": "查看给 AstrBot 布置的未来任务。AstrBot 将会被自动唤醒、执行任务,然后将结果告知任务布置方。",
|
||||
"beta": "实验性",
|
||||
"subtitle": "查看给 AstrBot 布置的未来任务。AstrBot 将会被自动唤醒、执行任务,然后将结果告知任务布置方。需要先在配置文件中启用“主动型能力”。",
|
||||
"proactive": {
|
||||
"supported": "主动发送结果仅支持以下平台:{platforms}",
|
||||
"supported": "主动发送结果仅支持以下您已配置的平台:{platforms}",
|
||||
"unsupported": "暂无支持主动消息的平台,请在平台设置中开启。"
|
||||
}
|
||||
},
|
||||
@@ -22,6 +22,7 @@
|
||||
"name": "名称",
|
||||
"type": "类型",
|
||||
"cron": "Cron",
|
||||
"session": "会话 ID",
|
||||
"nextRun": "下一次执行",
|
||||
"lastRun": "最近执行",
|
||||
"note": "说明",
|
||||
@@ -39,6 +40,7 @@
|
||||
},
|
||||
"form": {
|
||||
"title": "新建任务",
|
||||
"chatHint": "你可以直接通过聊天的方式来让 AstrBot 创建未来任务,而不必在此添加。",
|
||||
"runOnce": "一次性任务",
|
||||
"name": "任务名称",
|
||||
"note": "任务说明",
|
||||
|
||||
@@ -210,7 +210,9 @@
|
||||
"deleteTitle": "删除确认",
|
||||
"deleteMessage": "确定要删除该 Skill 吗?",
|
||||
"deleteSuccess": "删除成功",
|
||||
"deleteFailed": "删除失败"
|
||||
"deleteFailed": "删除失败",
|
||||
"runtimeNoneWarning": "Computer Use 运行环境为无,Skills 可能无法正确被 Agent 运行,因为没有启用运行环境。",
|
||||
"runtimeHint": "需要在配置的 “使用电脑能力” 中将运行环境设置为 “local” 或 “sandbox” 才能让 AstrBot 正常使用你提供的 Skills。"
|
||||
},
|
||||
"card": {
|
||||
"actions": {
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
"loadingSkills": "正在加载 Skills...",
|
||||
"allSkillsAvailable": "使用所有可用 Skills",
|
||||
"noSkillsSelected": "未选择任何 Skills",
|
||||
"skillsRuntimeNoneWarning": "Computer Use 运行环境为无,Skills 可能无法正确被 Agent 运行,因为没有启用运行环境。",
|
||||
"createInFolder": "将在「{folder}」中创建",
|
||||
"rootFolder": "全部人格"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"page": {
|
||||
"title": "SubAgent 编排",
|
||||
"beta": "Beta",
|
||||
"beta": "实验性",
|
||||
"subtitle": "主 LLM 只负责聊天与分派(handoff),工具挂载在各个 SubAgent 上。"
|
||||
},
|
||||
"actions": {
|
||||
@@ -35,8 +35,8 @@
|
||||
"nameHint": "建议使用英文小写+下划线,且全局唯一",
|
||||
"providerLabel": "Chat Provider(可选)",
|
||||
"providerHint": "留空表示跟随全局默认 provider。",
|
||||
"personaLabel": "选择 Persona",
|
||||
"personaHint": "SubAgent 将直接继承所选 Persona 的系统设定与工具。",
|
||||
"personaLabel": "选择人格设定",
|
||||
"personaHint": "SubAgent 将直接继承所选 Persona 的系统设定与工具。在人格设定页管理和新建人格。",
|
||||
"descriptionLabel": "对主 LLM 的描述(用于决定是否 handoff)",
|
||||
"descriptionHint": "这段会作为 transfer_to_* 工具的描述给主 LLM 看,建议简短明确。"
|
||||
},
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
<div class="text-caption text-medium-emphasis">{{ item.timezone || tm('table.timezoneLocal') }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #item.session="{ item }">
|
||||
<div>{{ item.session || tm('table.notAvailable') }}</div>
|
||||
</template>
|
||||
<template #item.next_run_time="{ item }">{{ formatTime(item.next_run_time) }}</template>
|
||||
<template #item.last_run_at="{ item }">{{ formatTime(item.last_run_at) }}</template>
|
||||
<template #item.note="{ item }">{{ item.note || tm('table.notAvailable') }}</template>
|
||||
@@ -70,6 +73,9 @@
|
||||
<v-dialog v-model="createDialog" max-width="560">
|
||||
<v-card>
|
||||
<v-card-title class="text-h6">{{ tm('form.title') }}</v-card-title>
|
||||
<v-card-subtitle class="text-body-2 text-medium-emphasis">
|
||||
{{ tm('form.chatHint') }}
|
||||
</v-card-subtitle>
|
||||
<v-card-text>
|
||||
<v-switch v-model="newJob.run_once" :label="tm('form.runOnce')" inset color="primary" hide-details />
|
||||
<v-text-field v-model="newJob.name" :label="tm('form.name')" variant="outlined" density="comfortable" />
|
||||
@@ -126,6 +132,7 @@ const headers = computed(() => [
|
||||
{ title: tm('table.headers.name'), key: 'name', minWidth: '200px' },
|
||||
{ title: tm('table.headers.type'), key: 'type', width: 110 },
|
||||
{ title: tm('table.headers.cron'), key: 'cron_expression', minWidth: '160px' },
|
||||
{ title: tm('table.headers.session'), key: 'session', minWidth: '200px' },
|
||||
{ title: tm('table.headers.nextRun'), key: 'next_run_time', minWidth: '160px' },
|
||||
{ title: tm('table.headers.lastRun'), key: 'last_run_at', minWidth: '160px' },
|
||||
{ title: tm('table.headers.note'), key: 'note', minWidth: '220px' },
|
||||
@@ -160,7 +167,11 @@ async function loadJobs() {
|
||||
try {
|
||||
const res = await axios.get('/api/cron/jobs')
|
||||
if (res.data.status === 'ok') {
|
||||
jobs.value = Array.isArray(res.data.data) ? res.data.data : []
|
||||
const data = Array.isArray(res.data.data) ? res.data.data : []
|
||||
jobs.value = data.map((job: any) => ({
|
||||
...job,
|
||||
session: job?.payload?.session || job?.session || ''
|
||||
}))
|
||||
} else {
|
||||
toast(res.data.message || tm('messages.loadFailed'), 'error')
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "AstrBot"
|
||||
version = "4.13.2"
|
||||
version = "4.14.1"
|
||||
description = "Easy-to-use multi-platform LLM chatbot and development framework"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
|
||||
Executable
+253
@@ -0,0 +1,253 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Auto-generate changelog from git commits using LLM.
|
||||
Usage: python scripts/generate_changelog.py [--version VERSION]
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def get_latest_tag():
|
||||
"""Get the latest git tag."""
|
||||
result = subprocess.run(
|
||||
["git", "describe", "--tags", "--abbrev=0"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return result.stdout.strip()
|
||||
|
||||
|
||||
def get_commits_since_tag(tag):
|
||||
"""Get all commit messages since the specified tag."""
|
||||
result = subprocess.run(
|
||||
["git", "log", f"{tag}..HEAD", "--pretty=format:%H|%s|%b"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
commits = []
|
||||
for line in result.stdout.strip().split("\n"):
|
||||
if not line:
|
||||
continue
|
||||
parts = line.split("|", 2)
|
||||
if len(parts) >= 2:
|
||||
commit_hash = parts[0]
|
||||
subject = parts[1]
|
||||
body = parts[2] if len(parts) > 2 else ""
|
||||
commits.append({"hash": commit_hash[:7], "subject": subject, "body": body})
|
||||
return commits
|
||||
|
||||
|
||||
def extract_issue_number(text):
|
||||
"""Extract issue number from commit message."""
|
||||
# Match #1234 or (#1234)
|
||||
match = re.search(r"#(\d+)", text)
|
||||
return match.group(1) if match else None
|
||||
|
||||
|
||||
def call_llm_for_changelog(commits, version):
|
||||
"""Call LLM to generate changelog from commits."""
|
||||
try:
|
||||
# Try to use OpenAI API or other LLM providers
|
||||
import openai
|
||||
|
||||
# Build prompt
|
||||
commits_text = "\n".join([f"- {c['subject']}" for c in commits])
|
||||
|
||||
prompt = f"""Based on the following git commit messages, generate a changelog document in BOTH Chinese and English.
|
||||
|
||||
Commit messages:
|
||||
{commits_text}
|
||||
|
||||
Please organize the changes into these categories:
|
||||
- 新增 (New Features)
|
||||
- 修复 (Bug Fixes)
|
||||
- 优化 (Improvements)
|
||||
- 其他 (Others)
|
||||
|
||||
Format requirements:
|
||||
1. Start with Chinese version under "## What's Changed"
|
||||
2. Follow with English version under "## What's Changed (EN)"
|
||||
3. Use markdown format with proper bullet points
|
||||
4. Keep descriptions concise and user-friendly
|
||||
5. If a commit mentions an issue number (#1234), include it in the format ([#1234](https://github.com/AstrBotDevs/AstrBot/issues/1234))
|
||||
|
||||
Example format:
|
||||
## What's Changed
|
||||
|
||||
### 新增
|
||||
- 支持某某功能 ([#1234](https://github.com/AstrBotDevs/AstrBot/issues/1234))
|
||||
|
||||
### 修复
|
||||
- 修复某某问题
|
||||
|
||||
## What's Changed (EN)
|
||||
|
||||
### New Features
|
||||
- Add support for something ([#1234](https://github.com/AstrBotDevs/AstrBot/issues/1234))
|
||||
|
||||
### Bug Fixes
|
||||
- Fix something
|
||||
"""
|
||||
|
||||
client = openai.OpenAI(
|
||||
api_key=os.getenv("OPENAI_API_KEY"),
|
||||
base_url=os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1"),
|
||||
)
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model=os.getenv("OPENAI_MODEL", "gpt-4"),
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": "You are a helpful assistant that generates well-structured changelogs.",
|
||||
},
|
||||
{"role": "user", "content": prompt},
|
||||
],
|
||||
temperature=0.3,
|
||||
)
|
||||
|
||||
return response.choices[0].message.content
|
||||
|
||||
except ImportError:
|
||||
print(
|
||||
"Warning: openai package not installed. Install it with: pip install openai"
|
||||
)
|
||||
return generate_simple_changelog(commits)
|
||||
except Exception as e:
|
||||
print(f"Warning: Failed to call LLM API: {e}")
|
||||
print("Falling back to simple changelog generation...")
|
||||
return generate_simple_changelog(commits)
|
||||
|
||||
|
||||
def generate_simple_changelog(commits):
|
||||
"""Generate a simple changelog without LLM."""
|
||||
sections = {
|
||||
"feat": ("新增", "New Features", []),
|
||||
"fix": ("修复", "Bug Fixes", []),
|
||||
"perf": ("优化", "Improvements", []),
|
||||
"docs": ("文档", "Documentation", []),
|
||||
"refactor": ("重构", "Refactoring", []),
|
||||
"test": ("测试", "Tests", []),
|
||||
"chore": ("其他", "Chore", []),
|
||||
"other": ("其他", "Others", []),
|
||||
}
|
||||
|
||||
# Categorize commits by conventional commit type
|
||||
for commit in commits:
|
||||
subject = commit["subject"]
|
||||
issue_num = extract_issue_number(subject)
|
||||
issue_link = (
|
||||
f" ([#{issue_num}](https://github.com/AstrBotDevs/AstrBot/issues/{issue_num}))"
|
||||
if issue_num
|
||||
else ""
|
||||
)
|
||||
|
||||
# Detect conventional commit type
|
||||
matched = False
|
||||
for prefix in ["feat", "fix", "perf", "docs", "refactor", "test", "chore"]:
|
||||
if subject.lower().startswith(f"{prefix}:") or subject.lower().startswith(
|
||||
f"{prefix}("
|
||||
):
|
||||
# Remove prefix for display
|
||||
clean_subject = re.sub(
|
||||
r"^[a-z]+(\([^)]+\))?:\s*", "", subject, flags=re.IGNORECASE
|
||||
)
|
||||
sections[prefix][2].append(f"- {clean_subject}{issue_link}")
|
||||
matched = True
|
||||
break
|
||||
|
||||
if not matched:
|
||||
sections["other"][2].append(f"- {subject}{issue_link}")
|
||||
|
||||
# Build Chinese version
|
||||
changelog_zh = "## What's Changed\n\n"
|
||||
for section_key in ["feat", "fix", "perf", "docs", "refactor", "test", "other"]:
|
||||
zh_title, _, items = sections[section_key]
|
||||
if items:
|
||||
changelog_zh += f"### {zh_title}\n\n"
|
||||
changelog_zh += "\n".join(items) + "\n\n"
|
||||
|
||||
# Build English version
|
||||
changelog_en = "## What's Changed (EN)\n\n"
|
||||
for section_key in ["feat", "fix", "perf", "docs", "refactor", "test", "other"]:
|
||||
_, en_title, items = sections[section_key]
|
||||
if items:
|
||||
changelog_en += f"### {en_title}\n\n"
|
||||
changelog_en += "\n".join(items) + "\n\n"
|
||||
|
||||
return changelog_zh + changelog_en
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Generate changelog from git commits")
|
||||
parser.add_argument(
|
||||
"--version", help="Version number for the changelog (e.g., v4.13.3)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--use-llm",
|
||||
action="store_true",
|
||||
help="Use LLM to generate changelog (requires OpenAI API key)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get latest tag
|
||||
try:
|
||||
latest_tag = get_latest_tag()
|
||||
print(f"Latest tag: {latest_tag}")
|
||||
except subprocess.CalledProcessError:
|
||||
print("Error: No tags found in repository")
|
||||
sys.exit(1)
|
||||
|
||||
# Get commits since tag
|
||||
commits = get_commits_since_tag(latest_tag)
|
||||
if not commits:
|
||||
print(f"No commits found since {latest_tag}")
|
||||
sys.exit(0)
|
||||
|
||||
print(f"Found {len(commits)} commits since {latest_tag}")
|
||||
|
||||
# Determine version
|
||||
if args.version:
|
||||
version = args.version
|
||||
else:
|
||||
# Auto-increment patch version
|
||||
match = re.match(r"v(\d+)\.(\d+)\.(\d+)", latest_tag)
|
||||
if match:
|
||||
major, minor, patch = map(int, match.groups())
|
||||
version = f"v{major}.{minor}.{patch + 1}"
|
||||
else:
|
||||
print(f"Warning: Could not parse version from tag {latest_tag}")
|
||||
version = "vX.X.X"
|
||||
|
||||
print(f"Generating changelog for {version}...")
|
||||
|
||||
# Generate changelog
|
||||
if args.use_llm:
|
||||
changelog_content = call_llm_for_changelog(commits, version)
|
||||
else:
|
||||
changelog_content = generate_simple_changelog(commits)
|
||||
|
||||
# Save to file
|
||||
changelog_dir = Path(__file__).parent.parent / "changelogs"
|
||||
changelog_dir.mkdir(exist_ok=True)
|
||||
changelog_file = changelog_dir / f"{version}.md"
|
||||
|
||||
with open(changelog_file, "w", encoding="utf-8") as f:
|
||||
f.write(changelog_content)
|
||||
|
||||
print(f"\n✓ Changelog generated: {changelog_file}")
|
||||
print("\nPreview:")
|
||||
print("=" * 80)
|
||||
print(changelog_content)
|
||||
print("=" * 80)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user