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