Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f6aeffd03 | |||
| c51de491a5 |
@@ -1,7 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from astrbot.core import astrbot_config, logger, sp
|
from astrbot.core import logger, sp
|
||||||
from astrbot.core.astrbot_config_mgr import AstrBotConfigManager
|
from astrbot.core.astrbot_config_mgr import AstrBotConfigManager
|
||||||
from astrbot.core.db import BaseDatabase
|
from astrbot.core.db import BaseDatabase
|
||||||
|
|
||||||
@@ -24,7 +24,6 @@ class ProviderManager:
|
|||||||
db_helper: BaseDatabase,
|
db_helper: BaseDatabase,
|
||||||
persona_mgr: PersonaManager,
|
persona_mgr: PersonaManager,
|
||||||
):
|
):
|
||||||
self.reload_lock = asyncio.Lock()
|
|
||||||
self.persona_mgr = persona_mgr
|
self.persona_mgr = persona_mgr
|
||||||
self.acm = acm
|
self.acm = acm
|
||||||
config = acm.confs["default"]
|
config = acm.confs["default"]
|
||||||
@@ -227,7 +226,6 @@ class ProviderManager:
|
|||||||
|
|
||||||
async def load_provider(self, provider_config: dict):
|
async def load_provider(self, provider_config: dict):
|
||||||
if not provider_config["enable"]:
|
if not provider_config["enable"]:
|
||||||
logger.info(f"Provider {provider_config['id']} is disabled, skipping")
|
|
||||||
return
|
return
|
||||||
if provider_config.get("provider_type", "") == "agent_runner":
|
if provider_config.get("provider_type", "") == "agent_runner":
|
||||||
return
|
return
|
||||||
@@ -436,15 +434,13 @@ class ProviderManager:
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def reload(self, provider_config: dict):
|
async def reload(self, provider_config: dict):
|
||||||
async with self.reload_lock:
|
|
||||||
await self.terminate_provider(provider_config["id"])
|
await self.terminate_provider(provider_config["id"])
|
||||||
if provider_config["enable"]:
|
if provider_config["enable"]:
|
||||||
await self.load_provider(provider_config)
|
await self.load_provider(provider_config)
|
||||||
|
|
||||||
# 和配置文件保持同步
|
# 和配置文件保持同步
|
||||||
self.providers_config = astrbot_config["provider"]
|
|
||||||
config_ids = [provider["id"] for provider in self.providers_config]
|
config_ids = [provider["id"] for provider in self.providers_config]
|
||||||
logger.info(f"providers in user's config: {config_ids}")
|
logger.debug(f"providers in user's config: {config_ids}")
|
||||||
for key in list(self.inst_map.keys()):
|
for key in list(self.inst_map.keys()):
|
||||||
if key not in config_ids:
|
if key not in config_ids:
|
||||||
await self.terminate_provider(key)
|
await self.terminate_provider(key)
|
||||||
@@ -459,9 +455,7 @@ class ProviderManager:
|
|||||||
|
|
||||||
if len(self.stt_provider_insts) == 0:
|
if len(self.stt_provider_insts) == 0:
|
||||||
self.curr_stt_provider_inst = None
|
self.curr_stt_provider_inst = None
|
||||||
elif (
|
elif self.curr_stt_provider_inst is None and len(self.stt_provider_insts) > 0:
|
||||||
self.curr_stt_provider_inst is None and len(self.stt_provider_insts) > 0
|
|
||||||
):
|
|
||||||
self.curr_stt_provider_inst = self.stt_provider_insts[0]
|
self.curr_stt_provider_inst = self.stt_provider_insts[0]
|
||||||
logger.info(
|
logger.info(
|
||||||
f"自动选择 {self.curr_stt_provider_inst.meta().id} 作为当前语音转文本提供商适配器。",
|
f"自动选择 {self.curr_stt_provider_inst.meta().id} 作为当前语音转文本提供商适配器。",
|
||||||
@@ -469,9 +463,7 @@ class ProviderManager:
|
|||||||
|
|
||||||
if len(self.tts_provider_insts) == 0:
|
if len(self.tts_provider_insts) == 0:
|
||||||
self.curr_tts_provider_inst = None
|
self.curr_tts_provider_inst = None
|
||||||
elif (
|
elif self.curr_tts_provider_inst is None and len(self.tts_provider_insts) > 0:
|
||||||
self.curr_tts_provider_inst is None and len(self.tts_provider_insts) > 0
|
|
||||||
):
|
|
||||||
self.curr_tts_provider_inst = self.tts_provider_insts[0]
|
self.curr_tts_provider_inst = self.tts_provider_insts[0]
|
||||||
logger.info(
|
logger.info(
|
||||||
f"自动选择 {self.curr_tts_provider_inst.meta().id} 作为当前文本转语音提供商适配器。",
|
f"自动选择 {self.curr_tts_provider_inst.meta().id} 作为当前文本转语音提供商适配器。",
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const sidebarItem: menu[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'core.navigation.sessionManagement',
|
title: 'core.navigation.sessionManagement',
|
||||||
icon: 'mdi-pencil-ruler',
|
icon: 'mdi-account-group',
|
||||||
to: '/session-management'
|
to: '/session-management'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
<v-card flat>
|
<v-card flat>
|
||||||
<v-card-title class="d-flex align-center py-3 px-4">
|
<v-card-title class="d-flex align-center py-3 px-4">
|
||||||
<span class="text-h4">{{ tm('customRules.title') }}</span>
|
<span class="text-h4">{{ tm('customRules.title') }}</span>
|
||||||
<v-btn icon="mdi-information-outline" size="small" variant="text" href="https://astrbot.app/use/custom-rules.html" target="_blank"></v-btn>
|
<v-chip size="small" class="ml-2">{{ totalItems }} {{ tm('customRules.rulesCount') }}</v-chip>
|
||||||
<v-chip size="small" class="ml-1">{{ totalItems }} {{ tm('customRules.rulesCount') }}</v-chip>
|
|
||||||
<v-row class="me-4 ms-4" dense>
|
<v-row class="me-4 ms-4" dense>
|
||||||
<v-text-field v-model="searchQuery" prepend-inner-icon="mdi-magnify" :label="tm('search.placeholder')"
|
<v-text-field v-model="searchQuery" prepend-inner-icon="mdi-magnify" :label="tm('search.placeholder')"
|
||||||
hide-details clearable variant="solo-filled" flat class="me-4" density="compact"></v-text-field>
|
hide-details clearable variant="solo-filled" flat class="me-4" density="compact"></v-text-field>
|
||||||
@@ -29,8 +28,8 @@
|
|||||||
<v-card-text class="pa-0">
|
<v-card-text class="pa-0">
|
||||||
<v-data-table-server :headers="headers" :items="filteredRulesList" :loading="loading"
|
<v-data-table-server :headers="headers" :items="filteredRulesList" :loading="loading"
|
||||||
:items-length="totalItems" v-model:items-per-page="itemsPerPage" v-model:page="currentPage"
|
:items-length="totalItems" v-model:items-per-page="itemsPerPage" v-model:page="currentPage"
|
||||||
@update:options="onTableOptionsUpdate" class="elevation-0" style="font-size: 12px;" v-model="selectedItems"
|
@update:options="onTableOptionsUpdate" class="elevation-0" style="font-size: 12px;"
|
||||||
show-select item-value="umo" return-object>
|
v-model="selectedItems" show-select item-value="umo" return-object>
|
||||||
|
|
||||||
<!-- UMO 信息 -->
|
<!-- UMO 信息 -->
|
||||||
<template v-slot:item.umo_info="{ item }">
|
<template v-slot:item.umo_info="{ item }">
|
||||||
@@ -41,8 +40,7 @@
|
|||||||
</v-chip>
|
</v-chip>
|
||||||
<span class="text-truncate" style="max-width: 300px;">{{ item.umo }}</span>
|
<span class="text-truncate" style="max-width: 300px;">{{ item.umo }}</span>
|
||||||
<div class="d-flex align-center" v-if="item.rules?.session_service_config?.custom_name || true">
|
<div class="d-flex align-center" v-if="item.rules?.session_service_config?.custom_name || true">
|
||||||
<span class="ml-2" style="color: gray; font-size: 10px;"
|
<span class="ml-2" style="color: gray; font-size: 10px;" v-if="item.rules?.session_service_config?.custom_name">
|
||||||
v-if="item.rules?.session_service_config?.custom_name">
|
|
||||||
({{ item.rules?.session_service_config?.custom_name }})
|
({{ item.rules?.session_service_config?.custom_name }})
|
||||||
</span>
|
</span>
|
||||||
<v-btn icon size="x-small" variant="text" class="ml-1" @click.stop="openQuickEditName(item)">
|
<v-btn icon size="x-small" variant="text" class="ml-1" @click.stop="openQuickEditName(item)">
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class ProcessLLMRequest:
|
|||||||
if default_persona:
|
if default_persona:
|
||||||
persona_id = default_persona["name"]
|
persona_id = default_persona["name"]
|
||||||
|
|
||||||
|
|
||||||
persona = next(
|
persona = next(
|
||||||
builtins.filter(
|
builtins.filter(
|
||||||
lambda persona: persona["name"] == persona_id,
|
lambda persona: persona["name"] == persona_id,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from astrbot.core.utils.session_waiter import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Main(Star):
|
class Waiter(Star):
|
||||||
"""会话控制"""
|
"""会话控制"""
|
||||||
|
|
||||||
def __init__(self, context: Context):
|
def __init__(self, context: Context):
|
||||||
|
|||||||
+1
-11
@@ -21,17 +21,7 @@ async def core_lifecycle_td(tmp_path_factory):
|
|||||||
log_broker = LogBroker()
|
log_broker = LogBroker()
|
||||||
core_lifecycle = AstrBotCoreLifecycle(log_broker, db)
|
core_lifecycle = AstrBotCoreLifecycle(log_broker, db)
|
||||||
await core_lifecycle.initialize()
|
await core_lifecycle.initialize()
|
||||||
try:
|
return core_lifecycle
|
||||||
yield core_lifecycle
|
|
||||||
finally:
|
|
||||||
# 优先停止核心生命周期以释放资源(包括关闭 MCP 等后台任务)
|
|
||||||
try:
|
|
||||||
_stop_res = core_lifecycle.stop()
|
|
||||||
if asyncio.iscoroutine(_stop_res):
|
|
||||||
await _stop_res
|
|
||||||
except Exception:
|
|
||||||
# 停止过程中如有异常,不影响后续清理
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ def plugin_manager_pm(tmp_path):
|
|||||||
message_history_manager = MagicMock()
|
message_history_manager = MagicMock()
|
||||||
persona_manager = MagicMock()
|
persona_manager = MagicMock()
|
||||||
astrbot_config_mgr = MagicMock()
|
astrbot_config_mgr = MagicMock()
|
||||||
knowledge_base_manager = MagicMock()
|
|
||||||
|
|
||||||
star_context = Context(
|
star_context = Context(
|
||||||
event_queue,
|
event_queue,
|
||||||
@@ -51,7 +50,6 @@ def plugin_manager_pm(tmp_path):
|
|||||||
message_history_manager,
|
message_history_manager,
|
||||||
persona_manager,
|
persona_manager,
|
||||||
astrbot_config_mgr,
|
astrbot_config_mgr,
|
||||||
knowledge_base_manager=knowledge_base_manager,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create the PluginManager instance
|
# Create the PluginManager instance
|
||||||
|
|||||||
Reference in New Issue
Block a user