Compare commits

..

1 Commits

12 changed files with 1631 additions and 2323 deletions

View File

@@ -6,7 +6,7 @@ import os
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
VERSION = "4.0.0-beta.4"
VERSION = "4.0.0"
DB_PATH = os.path.join(get_astrbot_data_path(), "data_v4.db")
# 默认配置
@@ -51,6 +51,10 @@ DEFAULT_CONFIG = {
"enable": True,
"default_provider_id": "",
"default_image_caption_provider_id": "",
"default_summarize_provider_id": "",
"context_exceed_calc_method": "token_size",
"max_token_size": 128000,
"max_context_length": 100,
"image_caption_prompt": "Please describe the image using Chinese.",
"provider_pool": ["*"], # "*" 表示使用所有可用的提供者
"wake_prefix": "",
@@ -64,7 +68,6 @@ DEFAULT_CONFIG = {
"default_personality": "default",
"persona_pool": ["*"],
"prompt_prefix": "",
"max_context_length": -1,
"dequeue_context_length": 1,
"streaming_response": False,
"show_tool_use_status": False,
@@ -1832,6 +1835,12 @@ CONFIG_METADATA_3 = {
"_special": "select_provider",
"hint": "留空时使用第一个模型。",
},
"provider_settings.default_summarize_provider_id": {
"description": "默认对话总结模型",
"type": "string",
"_special": "select_provider",
"hint": "留空代表不进行对话总结。可用于压缩上下文以减少 token 用量,并一定程度上保持历史聊天记忆。",
},
"provider_settings.default_image_caption_provider_id": {
"description": "默认图片转述模型",
"type": "string",
@@ -1850,6 +1859,28 @@ CONFIG_METADATA_3 = {
"hint": "留空代表不使用。",
"_special": "select_provider_tts",
},
"provider_settings.context_exceed_calc_method": {
"description": "上下文超限的触发策略",
"type": "string",
"options": ["token_size", "context_length"],
"labels": ["基于 Token 长度(估算)", "基于对话轮数"],
"hint": "如配置了对话总结模型,则触发时总结对话内容,否则丢弃最旧部分。"
},
"provider_settings.max_context_length": {
"description": "对话轮数上限",
"type": "int",
"condition": {
"provider_settings.context_exceed_calc_method": "context_length"
}
},
"provider_settings.max_token_size": {
"description": "Token 长度上限(估算)",
"type": "int",
"hint": "超出这个数量时丢弃最旧的部分。",
"condition": {
"provider_settings.context_exceed_calc_method": "token_size"
}
},
"provider_settings.image_caption_prompt": {
"description": "图片转述提示词",
"type": "text",
@@ -1913,7 +1944,7 @@ CONFIG_METADATA_3 = {
"type": "bool",
},
"provider_settings.identifier": {
"description": "用户识别",
"description": "用户感知",
"type": "bool",
},
"provider_settings.datetime_system_prompt": {
@@ -1926,7 +1957,7 @@ CONFIG_METADATA_3 = {
},
"provider_settings.max_agent_step": {
"description": "工具调用轮数上限",
"type": "bool",
"type": "int",
},
"provider_settings.streaming_response": {
"description": "流式回复",
@@ -1936,11 +1967,6 @@ CONFIG_METADATA_3 = {
"description": "不支持流式回复的平台采取分段输出",
"type": "bool",
},
"provider_settings.max_context_length": {
"description": "最多携带对话轮数",
"type": "int",
"hint": "超出这个数量时丢弃最旧的部分,一轮聊天记为 1 条。-1 为不限制。",
},
"provider_settings.dequeue_context_length": {
"description": "丢弃对话轮数",
"type": "int",
@@ -2288,7 +2314,7 @@ CONFIG_METADATA_3_SYSTEM = {
"condition": {
"t2i_strategy": "remote",
},
"_special": "t2i_template",
"_special": "t2i_template"
},
"log_level": {
"description": "控制台日志级别",

View File

@@ -1,3 +0,0 @@
# What's Changed
> 请仔细阅读:**这是 v4.0.0 的测试版本beta.3),功能尚未完全稳定和加入**。v4.0.0 被设计为向前兼容,如有任何插件兼容性问题或者其他异常请在 GitHub 提交 [Issue](https://github.com/AstrBotDevs/AstrBot/issues)。在测试版本期间,您可以无缝回退到旧版本的 AstrBot并且数据不受影响。新版本文档请[从此](https://docs-v4.astrbot.app/)访问,直到第一个 v4.0.0 稳定版本发布。

View File

@@ -1,8 +0,0 @@
# What's Changed
> 请仔细阅读:**这是 v4.0.0 的测试版本beta.4),功能尚未完全稳定和加入**。v4.0.0 被设计为向前兼容,如有任何插件兼容性问题或者其他异常请在 GitHub 提交 [Issue](https://github.com/AstrBotDevs/AstrBot/issues)。在测试版本期间,您可以无缝回退到旧版本的 AstrBot并且数据不受影响。新版本文档请[从此](https://docs-v4.astrbot.app/)访问,直到第一个 v4.0.0 稳定版本发布。
相较于 beta.3
1. 修复了主动回复时报错的问题
2. 数据迁移完毕之后引导重启程序

View File

@@ -12,13 +12,7 @@
<div v-if="migrationCompleted" class="text-center py-8">
<v-icon size="64" color="success" class="mb-4">mdi-check-circle</v-icon>
<h3 class="mb-4">{{ t('features.migration.dialog.completed') }}</h3>
<p class="mb-4">{{ migrationResult?.message || t('features.migration.dialog.success') }}</p>
<v-alert type="info" variant="tonal" class="mb-4">
<template v-slot:prepend>
<v-icon>mdi-information</v-icon>
</template>
{{ t('features.migration.dialog.restartRecommended') }}
</v-alert>
{{ migrationResult?.message || t('features.migration.dialog.success') }}
</div>
<div v-else-if="migrating" class="migration-in-progress">
@@ -86,11 +80,8 @@
<v-card-actions class="px-6 py-4">
<v-spacer></v-spacer>
<template v-if="migrationCompleted">
<v-btn color="grey" variant="text" @click="handleClose">
{{ t('core.common.close') }}
</v-btn>
<v-btn color="primary" variant="elevated" @click="restartAstrBot">
{{ t('features.migration.dialog.restartNow') }}
<v-btn color="primary" variant="elevated" @click="handleClose">
{{ t('core.common.confirm') }}
</v-btn>
</template>
<template v-else>
@@ -105,8 +96,6 @@
</v-card-actions>
</v-card>
</v-dialog>
<WaitingForRestart ref="wfr"></WaitingForRestart>
</template>
<script setup>
@@ -114,7 +103,6 @@ import { ref, computed, watch } from 'vue'
import axios from 'axios'
import { useI18n } from '@/i18n/composables'
import ConsoleDisplayer from './ConsoleDisplayer.vue'
import WaitingForRestart from './WaitingForRestart.vue'
const { t } = useI18n()
@@ -126,7 +114,6 @@ const migrationCompleted = ref(false)
const migrationResult = ref(null)
const platforms = ref([])
const selectedPlatforms = ref({})
const wfr = ref(null)
let resolvePromise = null
@@ -257,15 +244,6 @@ const getPlatformLabel = (platform) => {
return `${name}`
}
// 重启 AstrBot
const restartAstrBot = () => {
axios.post('/api/stat/restart-core').then(() => {
if (wfr.value) {
wfr.value.check();
}
})
}
// 打开对话框的方法
const open = () => {
isOpen.value = true

View File

@@ -11,8 +11,6 @@
"migratingSubtitle": "Please wait patiently, do not close this window during migration",
"migrationError": "Migration failed",
"success": "Migration completed successfully!",
"completed": "Migration Completed",
"restartRecommended": "It is recommended to restart the application for all changes to take effect.",
"restartNow": "Restart Now"
"completed": "Migration Completed"
}
}

View File

@@ -11,8 +11,6 @@
"migratingSubtitle": "请耐心等待,迁移过程中请勿关闭此窗口",
"migrationError": "迁移失败",
"success": "迁移成功完成!",
"completed": "迁移已完成",
"restartRecommended": "建议重启应用程序以使所有更改生效。",
"restartNow": "立即重启"
"completed": "迁移已完成"
}
}

View File

@@ -383,7 +383,8 @@ export default {
messageType: 'success',
personaIdRules: [
v => !!v || this.tm('validation.required'),
v => (v && v.length >= 0) || this.tm('validation.minLength', { min: 2 }),
v => (v && v.length >= 2) || this.tm('validation.minLength', { min: 2 }),
v => /^[a-zA-Z0-9_-]+$/.test(v) || this.tm('validation.alphanumeric')
],
systemPromptRules: [
v => !!v || this.tm('validation.required'),

View File

@@ -25,18 +25,14 @@ class LongTermMemory:
def cfg(self, event: AstrMessageEvent):
cfg = self.context.get_config(umo=event.unified_msg_origin)
try:
max_cnt = int(cfg["provider_ltm_settings"]["group_message_max_cnt"])
max_cnt = int(cfg["group_message_max_cnt"])
except BaseException as e:
logger.error(e)
max_cnt = 300
image_caption = (
True
if cfg["provider_settings"]["default_image_caption_provider_id"]
else False
)
image_caption_prompt = cfg["provider_settings"]["image_caption_prompt"]
image_caption_provider_id = cfg["provider_settings"]["default_image_caption_provider_id"]
active_reply = cfg["provider_ltm_settings"]["active_reply"]
image_caption = cfg["image_caption"]
image_caption_prompt = cfg["image_caption_prompt"]
image_caption_provider_id = cfg["image_caption_provider_id"]
active_reply = cfg["active_reply"]
enable_active_reply = active_reply.get("enable", False)
ar_method = active_reply["method"]
ar_possibility = active_reply["possibility_reply"]
@@ -92,9 +88,7 @@ class LongTermMemory:
if cfg["ar_whitelist"] and (
event.unified_msg_origin not in cfg["ar_whitelist"]
and (
event.get_group_id() and event.get_group_id() not in cfg["ar_whitelist"]
)
and (event.get_group_id() and event.get_group_id() not in cfg["ar_whitelist"])
):
return False
@@ -118,6 +112,7 @@ class LongTermMemory:
if isinstance(comp, Plain):
final_message += f" {comp.text}"
elif isinstance(comp, Image):
cfg = self.cfg(event)
if cfg["image_caption"]:
try:
caption = await self.get_image_caption(

View File

@@ -1110,9 +1110,7 @@ UID: {user_id} 此 ID 可用于设置管理员。
@filter.command("unset")
async def unset_variable(self, event: AstrMessageEvent, key: str):
uid = event.unified_msg_origin
session_var = await sp.session_get(
umo="uid", key="session_variables", default={}
)
session_var = await sp.session_get(umo="uid", key="session_variables", default={})
if key not in session_var:
yield event.plain_result("没有那个变量名。格式 /unset 变量名。")
@@ -1178,7 +1176,9 @@ UID: {user_id} 此 ID 可用于设置管理员。
)
return
prompt = event.message_str
prompt = self.ltm.ar_prompt
if not prompt:
prompt = event.message_str
yield event.request_llm(
prompt=prompt,

View File

@@ -1,6 +1,6 @@
[project]
name = "AstrBot"
version = "4.0.0-beta.4"
version = "4.0.0"
description = "易上手的多平台 LLM 聊天机器人及开发框架"
readme = "README.md"
requires-python = ">=3.10"

View File

@@ -39,7 +39,4 @@ faiss-cpu
aiosqlite
py-cord>=2.6.1
slack-sdk
pydub
sqlmodel
deprecated
sqlalchemy[asyncio]
pydub

3824
uv.lock generated

File diff suppressed because it is too large Load Diff