mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-01 01:10:21 +08:00
chore: remove redundant logger messages and improve log clarity
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -36,8 +36,6 @@ class KnowledgeBaseManager:
|
|||||||
async def initialize(self) -> None:
|
async def initialize(self) -> None:
|
||||||
"""初始化知识库模块"""
|
"""初始化知识库模块"""
|
||||||
try:
|
try:
|
||||||
logger.info("正在初始化知识库模块...")
|
|
||||||
|
|
||||||
# 初始化数据库
|
# 初始化数据库
|
||||||
await self._init_kb_database()
|
await self._init_kb_database()
|
||||||
|
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ class FunctionToolManager:
|
|||||||
handler=handler,
|
handler=handler,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
logger.info(f"添加函数调用工具: {name}")
|
logger.info(f"Added llm tool: {name}")
|
||||||
|
|
||||||
def remove_func(self, name: str) -> None:
|
def remove_func(self, name: str) -> None:
|
||||||
"""删除一个函数调用工具。"""
|
"""删除一个函数调用工具。"""
|
||||||
|
|||||||
@@ -304,7 +304,6 @@ def save_config(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""验证并保存配置"""
|
"""验证并保存配置"""
|
||||||
errors = None
|
errors = None
|
||||||
logger.info(f"Saving config, is_core={is_core}")
|
|
||||||
|
|
||||||
# Snapshot old Computer config for change detection
|
# Snapshot old Computer config for change detection
|
||||||
if is_core:
|
if is_core:
|
||||||
@@ -993,10 +992,6 @@ class ConfigRoute(Route):
|
|||||||
if inspect.iscoroutinefunction(terminate_fn):
|
if inspect.iscoroutinefunction(terminate_fn):
|
||||||
await terminate_fn()
|
await terminate_fn()
|
||||||
|
|
||||||
logger.info(
|
|
||||||
f"获取到 provider_source {provider_source_id} 的模型列表: {models}",
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
Response()
|
Response()
|
||||||
.ok({"models": models, "model_metadata": metadata_map})
|
.ok({"models": models, "model_metadata": metadata_map})
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ class PluginRoute(Route):
|
|||||||
cache_data = json.load(f)
|
cache_data = json.load(f)
|
||||||
return cache_data.get("md5")
|
return cache_data.get("md5")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"加载缓存MD5失败: {e}")
|
logger.warning(f"Failed to load cached MD5: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def _fetch_remote_md5(self, md5_url: str | None) -> str | None:
|
async def _fetch_remote_md5(self, md5_url: str | None) -> str | None:
|
||||||
@@ -283,7 +283,7 @@ class PluginRoute(Route):
|
|||||||
data = await response.json()
|
data = await response.json()
|
||||||
return data.get("md5", "")
|
return data.get("md5", "")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"获取远程MD5失败: {e}")
|
logger.debug(f"Failed to fetch remote MD5: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
async def _is_cache_valid(self, source: RegistrySource) -> bool:
|
async def _is_cache_valid(self, source: RegistrySource) -> bool:
|
||||||
@@ -291,17 +291,17 @@ class PluginRoute(Route):
|
|||||||
try:
|
try:
|
||||||
cached_md5 = self._load_cached_md5(source.cache_file)
|
cached_md5 = self._load_cached_md5(source.cache_file)
|
||||||
if not cached_md5:
|
if not cached_md5:
|
||||||
logger.debug("缓存文件中没有MD5信息")
|
logger.debug("MD5 not found in cache, treating cache as invalid")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
remote_md5 = await self._fetch_remote_md5(source.md5_url)
|
remote_md5 = await self._fetch_remote_md5(source.md5_url)
|
||||||
if remote_md5 is None:
|
if remote_md5 is None:
|
||||||
logger.warning("无法获取远程MD5,将使用缓存")
|
logger.warning("Cannot fetch remote MD5, using cache without validation")
|
||||||
return True # 如果无法获取远程MD5,认为缓存有效
|
return True # 如果无法获取远程MD5,认为缓存有效
|
||||||
|
|
||||||
is_valid = cached_md5 == remote_md5
|
is_valid = cached_md5 == remote_md5
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"插件数据MD5: 本地={cached_md5}, 远程={remote_md5}, 有效={is_valid}",
|
f"Plugin cache: local={cached_md5}, remote={remote_md5}, effective={is_valid}",
|
||||||
)
|
)
|
||||||
return is_valid
|
return is_valid
|
||||||
|
|
||||||
@@ -318,11 +318,11 @@ class PluginRoute(Route):
|
|||||||
# 检查缓存是否有效
|
# 检查缓存是否有效
|
||||||
if "data" in cache_data and "timestamp" in cache_data:
|
if "data" in cache_data and "timestamp" in cache_data:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"加载缓存文件: {cache_file}, 缓存时间: {cache_data['timestamp']}",
|
f"Loading cached file: {cache_file}, Cache time: {cache_data['timestamp']}",
|
||||||
)
|
)
|
||||||
return cache_data["data"]
|
return cache_data["data"]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"加载插件市场缓存失败: {e}")
|
logger.warning(f"Failed to load plugin market cache: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _save_plugin_cache(self, cache_file: str, data, md5: str | None = None) -> None:
|
def _save_plugin_cache(self, cache_file: str, data, md5: str | None = None) -> None:
|
||||||
@@ -339,9 +339,9 @@ class PluginRoute(Route):
|
|||||||
|
|
||||||
with open(cache_file, "w", encoding="utf-8") as f:
|
with open(cache_file, "w", encoding="utf-8") as f:
|
||||||
json.dump(cache_data, f, ensure_ascii=False, indent=2)
|
json.dump(cache_data, f, ensure_ascii=False, indent=2)
|
||||||
logger.debug(f"插件市场数据已缓存到: {cache_file}, MD5: {md5}")
|
logger.debug(f"Cached plugin market data: {cache_file}, MD5: {md5}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"保存插件市场缓存失败: {e}")
|
logger.warning(f"Failed to save plugin market cache: {e}")
|
||||||
|
|
||||||
async def get_plugin_logo_token(self, logo_path: str):
|
async def get_plugin_logo_token(self, logo_path: str):
|
||||||
try:
|
try:
|
||||||
@@ -742,7 +742,6 @@ class PluginRoute(Route):
|
|||||||
|
|
||||||
async def get_plugin_readme(self):
|
async def get_plugin_readme(self):
|
||||||
plugin_name = request.args.get("name")
|
plugin_name = request.args.get("name")
|
||||||
logger.debug(f"正在获取插件 {plugin_name} 的README文件内容")
|
|
||||||
|
|
||||||
if not plugin_name:
|
if not plugin_name:
|
||||||
logger.warning("插件名称为空")
|
logger.warning("插件名称为空")
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ const togglePin = () => {
|
|||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
<v-card-actions class="extension-actions" @click.stop>
|
<v-card-actions class="extension-actions">
|
||||||
<template v-if="!marketMode">
|
<template v-if="!marketMode">
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-tooltip location="top">
|
<v-tooltip location="top">
|
||||||
@@ -303,7 +303,7 @@ const togglePin = () => {
|
|||||||
size="small"
|
size="small"
|
||||||
variant="tonal"
|
variant="tonal"
|
||||||
class="extension-pin-btn"
|
class="extension-pin-btn"
|
||||||
@click="togglePin"
|
@click.stop="togglePin"
|
||||||
></v-btn>
|
></v-btn>
|
||||||
</template>
|
</template>
|
||||||
<span>{{ isPinned ? tm("buttons.unpin") : tm("buttons.pin") }}</span>
|
<span>{{ isPinned ? tm("buttons.unpin") : tm("buttons.pin") }}</span>
|
||||||
@@ -317,7 +317,7 @@ const togglePin = () => {
|
|||||||
size="small"
|
size="small"
|
||||||
variant="tonal"
|
variant="tonal"
|
||||||
color="info"
|
color="info"
|
||||||
@click="viewReadme"
|
@click.stop="viewReadme"
|
||||||
></v-btn>
|
></v-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
@@ -330,7 +330,7 @@ const togglePin = () => {
|
|||||||
size="small"
|
size="small"
|
||||||
variant="tonal"
|
variant="tonal"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="configure"
|
@click.stop="configure"
|
||||||
></v-btn>
|
></v-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
@@ -343,7 +343,7 @@ const togglePin = () => {
|
|||||||
size="small"
|
size="small"
|
||||||
variant="tonal"
|
variant="tonal"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click="reloadExtension"
|
@click.stop="reloadExtension"
|
||||||
></v-btn>
|
></v-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
@@ -356,14 +356,15 @@ const togglePin = () => {
|
|||||||
size="small"
|
size="small"
|
||||||
variant="tonal"
|
variant="tonal"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
@click.stop
|
||||||
></v-btn>
|
></v-btn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<v-list-item class="styled-menu-item" prepend-icon="mdi-information" @click="viewHandlers">
|
<v-list-item class="styled-menu-item" prepend-icon="mdi-information" @click.stop="viewHandlers">
|
||||||
<v-list-item-title>{{ tm("buttons.viewInfo") }}</v-list-item-title>
|
<v-list-item-title>{{ tm("buttons.viewInfo") }}</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
|
||||||
<v-list-item class="styled-menu-item" prepend-icon="mdi-update" @click="updateExtension">
|
<v-list-item class="styled-menu-item" prepend-icon="mdi-update" @click.stop="updateExtension">
|
||||||
<v-list-item-title>{{
|
<v-list-item-title>{{
|
||||||
extension.has_update
|
extension.has_update
|
||||||
? tm("card.actions.updateTo") + " " + extension.online_version
|
? tm("card.actions.updateTo") + " " + extension.online_version
|
||||||
@@ -371,13 +372,13 @@ const togglePin = () => {
|
|||||||
}}</v-list-item-title>
|
}}</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
|
||||||
<v-list-item class="styled-menu-item" prepend-icon="mdi-delete" @click="uninstallExtension">
|
<v-list-item class="styled-menu-item" prepend-icon="mdi-delete" @click.stop="uninstallExtension">
|
||||||
<v-list-item-title class="text-error">{{ tm("card.actions.uninstallPlugin") }}</v-list-item-title>
|
<v-list-item-title class="text-error">{{ tm("card.actions.uninstallPlugin") }}</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</StyledMenu>
|
</StyledMenu>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<v-btn color="primary" size="small" @click="viewReadme">
|
<v-btn color="primary" size="small" @click.stop="viewReadme">
|
||||||
{{ tm("buttons.viewDocs") }}
|
{{ tm("buttons.viewDocs") }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -282,44 +282,48 @@ const installDialogPluginLogo = computed(() => {
|
|||||||
|
|
||||||
<!-- 已安装的 MCP 服务器标签页内容 -->
|
<!-- 已安装的 MCP 服务器标签页内容 -->
|
||||||
<v-tab-item v-if="activeTab === 'mcp'">
|
<v-tab-item v-if="activeTab === 'mcp'">
|
||||||
<div class="mb-4 pt-4 pb-4">
|
<div class="extension-detail-width">
|
||||||
<div class="d-flex flex-column" style="gap: 6px">
|
<div class="mb-4 pt-4 pb-4">
|
||||||
<h2 class="text-h2 mb-0">{{ tm("tabs.installedMcpServers") }}</h2>
|
<div class="d-flex flex-column" style="gap: 6px">
|
||||||
<div class="text-body-2 text-medium-emphasis">
|
<h2 class="text-h2 mb-0">{{ tm("tabs.installedMcpServers") }}</h2>
|
||||||
{{ t("features.tooluse.mcpServers.description") }}
|
<div class="text-body-2 text-medium-emphasis">
|
||||||
|
{{ t("features.tooluse.mcpServers.description") }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<v-card
|
||||||
|
class="rounded-lg"
|
||||||
|
variant="flat"
|
||||||
|
style="background-color: transparent"
|
||||||
|
>
|
||||||
|
<v-card-text class="pa-0">
|
||||||
|
<McpServersSection />
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
<v-card
|
|
||||||
class="rounded-lg"
|
|
||||||
variant="flat"
|
|
||||||
style="background-color: transparent"
|
|
||||||
>
|
|
||||||
<v-card-text class="pa-0">
|
|
||||||
<McpServersSection />
|
|
||||||
</v-card-text>
|
|
||||||
</v-card>
|
|
||||||
</v-tab-item>
|
</v-tab-item>
|
||||||
|
|
||||||
<!-- Skills 标签页内容 -->
|
<!-- Skills 标签页内容 -->
|
||||||
<v-tab-item v-if="activeTab === 'skills'">
|
<v-tab-item v-if="activeTab === 'skills'">
|
||||||
<div class="mb-4 pt-4 pb-4">
|
<div class="extension-detail-width">
|
||||||
<div class="d-flex flex-column" style="gap: 6px">
|
<div class="mb-4 pt-4 pb-4">
|
||||||
<h2 class="text-h2 mb-0">{{ tm("tabs.skills") }}</h2>
|
<div class="d-flex flex-column" style="gap: 6px">
|
||||||
<div class="text-body-2 text-medium-emphasis">
|
<h2 class="text-h2 mb-0">{{ tm("tabs.skills") }}</h2>
|
||||||
{{ tm("skills.runtimeHint") }}
|
<div class="text-body-2 text-medium-emphasis">
|
||||||
|
{{ tm("skills.runtimeHint") }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<v-card
|
||||||
|
class="rounded-lg"
|
||||||
|
variant="flat"
|
||||||
|
style="background-color: transparent"
|
||||||
|
>
|
||||||
|
<v-card-text class="pa-0">
|
||||||
|
<SkillsSection />
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
<v-card
|
|
||||||
class="rounded-lg"
|
|
||||||
variant="flat"
|
|
||||||
style="background-color: transparent"
|
|
||||||
>
|
|
||||||
<v-card-text class="pa-0">
|
|
||||||
<SkillsSection />
|
|
||||||
</v-card-text>
|
|
||||||
</v-card>
|
|
||||||
</v-tab-item>
|
</v-tab-item>
|
||||||
|
|
||||||
<!-- 插件市场标签页内容 -->
|
<!-- 插件市场标签页内容 -->
|
||||||
@@ -1101,6 +1105,12 @@ const installDialogPluginLogo = computed(() => {
|
|||||||
box-shadow: 0 12px 20px rgba(var(--v-theme-primary), 0.4);
|
box-shadow: 0 12px 20px rgba(var(--v-theme-primary), 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.extension-detail-width {
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 1040px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.market-install-confirm {
|
.market-install-confirm {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ onMounted(() => {
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.document-detail-page {
|
.document-detail-page {
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
max-width: 1400px;
|
max-width: 1040px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
animation: fadeIn 0.3s ease;
|
animation: fadeIn 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ const goToList = () => {
|
|||||||
<style scoped>
|
<style scoped>
|
||||||
.kb-container {
|
.kb-container {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
max-width: 1400px;
|
max-width: 1040px;
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ def _try_patch_aiohttp_ssl_context(
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
setattr(aiohttp_connector, attr_name, ssl_context)
|
setattr(aiohttp_connector, attr_name, ssl_context)
|
||||||
log.info("Configured aiohttp verified SSL context with system+certifi trust chain.")
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@@ -38,7 +37,6 @@ def configure_runtime_ca_bundle(log_obj: Any | None = None) -> bool:
|
|||||||
log = log_obj or logger
|
log = log_obj or logger
|
||||||
|
|
||||||
try:
|
try:
|
||||||
log.info("Bootstrapping runtime CA bundle.")
|
|
||||||
ssl_context = build_ssl_context_with_certifi(log_obj=log)
|
ssl_context = build_ssl_context_with_certifi(log_obj=log)
|
||||||
return _try_patch_aiohttp_ssl_context(ssl_context, log_obj=log)
|
return _try_patch_aiohttp_ssl_context(ssl_context, log_obj=log)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|||||||
Reference in New Issue
Block a user