🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-04-23 15:37:28 +00:00
parent c4499829a6
commit 1b380ff131
9 changed files with 160 additions and 134 deletions

View File

@@ -61,7 +61,6 @@ class InterestMonitorApp:
self.single_stream_last_active = tk.StringVar(value="活跃: N/A") self.single_stream_last_active = tk.StringVar(value="活跃: N/A")
self.single_stream_last_interaction = tk.StringVar(value="交互: N/A") self.single_stream_last_interaction = tk.StringVar(value="交互: N/A")
# --- UI 元素 --- # --- UI 元素 ---
# --- 新增:顶部全局信息框架 --- # --- 新增:顶部全局信息框架 ---
@@ -75,11 +74,10 @@ class InterestMonitorApp:
ttk.Label(self.global_info_frame, text="子流数:").pack(side=tk.LEFT, padx=(10, 0)) ttk.Label(self.global_info_frame, text="子流数:").pack(side=tk.LEFT, padx=(10, 0))
ttk.Label(self.global_info_frame, textvariable=self.latest_subflow_count).pack(side=tk.LEFT, padx=5) ttk.Label(self.global_info_frame, textvariable=self.latest_subflow_count).pack(side=tk.LEFT, padx=5)
# 创建 Notebook (选项卡控件) # 创建 Notebook (选项卡控件)
self.notebook = ttk.Notebook(root) self.notebook = ttk.Notebook(root)
# 修改fill 和 expand让 notebook 填充剩余空间 # 修改fill 和 expand让 notebook 填充剩余空间
self.notebook.pack(pady=(5, 0), padx=10, fill=tk.BOTH, expand=1) #顶部外边距改小 self.notebook.pack(pady=(5, 0), padx=10, fill=tk.BOTH, expand=1) # 顶部外边距改小
# --- 第一个选项卡:所有流 --- # --- 第一个选项卡:所有流 ---
self.frame_all = ttk.Frame(self.notebook, padding="5 5 5 5") self.frame_all = ttk.Frame(self.notebook, padding="5 5 5 5")
@@ -119,10 +117,18 @@ class InterestMonitorApp:
self.single_stream_details_frame.pack(side=tk.TOP, fill=tk.X, pady=(0, 5)) self.single_stream_details_frame.pack(side=tk.TOP, fill=tk.X, pady=(0, 5))
ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_sub_mind).pack(side=tk.LEFT, padx=5) ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_sub_mind).pack(side=tk.LEFT, padx=5)
ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_chat_state).pack(side=tk.LEFT, padx=5) ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_chat_state).pack(
ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_threshold).pack(side=tk.LEFT, padx=5) side=tk.LEFT, padx=5
ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_last_active).pack(side=tk.LEFT, padx=5) )
ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_last_interaction).pack(side=tk.LEFT, padx=5) ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_threshold).pack(
side=tk.LEFT, padx=5
)
ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_last_active).pack(
side=tk.LEFT, padx=5
)
ttk.Label(self.single_stream_details_frame, textvariable=self.single_stream_last_interaction).pack(
side=tk.LEFT, padx=5
)
# Matplotlib 图表设置 (用于第二个选项卡) # Matplotlib 图表设置 (用于第二个选项卡)
self.fig_single = Figure(figsize=(5, 4), dpi=100) self.fig_single = Figure(figsize=(5, 4), dpi=100)
@@ -191,7 +197,9 @@ class InterestMonitorApp:
continue # 跳过时间戳格式错误的行 continue # 跳过时间戳格式错误的行
# --- 新增:更新顶层信息 (使用最后一个有效行的数据) --- # --- 新增:更新顶层信息 (使用最后一个有效行的数据) ---
self.latest_main_mind.set(log_entry.get("main_mind", self.latest_main_mind.get())) # 保留旧值如果缺失 self.latest_main_mind.set(
log_entry.get("main_mind", self.latest_main_mind.get())
) # 保留旧值如果缺失
self.latest_mai_state.set(log_entry.get("mai_state", self.latest_mai_state.get())) self.latest_mai_state.set(log_entry.get("mai_state", self.latest_mai_state.get()))
self.latest_subflow_count.set(log_entry.get("subflow_count", self.latest_subflow_count.get())) self.latest_subflow_count.set(log_entry.get("subflow_count", self.latest_subflow_count.get()))
@@ -236,7 +244,9 @@ class InterestMonitorApp:
self.stream_chat_states[stream_id] = subflow_entry.get("sub_chat_state", "N/A") self.stream_chat_states[stream_id] = subflow_entry.get("sub_chat_state", "N/A")
self.stream_threshold_status[stream_id] = subflow_entry.get("is_above_threshold", False) self.stream_threshold_status[stream_id] = subflow_entry.get("is_above_threshold", False)
self.stream_last_active[stream_id] = subflow_entry.get("last_active_time") # 存储原始时间戳 self.stream_last_active[stream_id] = subflow_entry.get("last_active_time") # 存储原始时间戳
self.stream_last_interaction[stream_id] = subflow_entry.get("last_interaction_time") # 存储原始时间戳 self.stream_last_interaction[stream_id] = subflow_entry.get(
"last_interaction_time"
) # 存储原始时间戳
# 添加数据点 (使用顶层时间戳) # 添加数据点 (使用顶层时间戳)
new_stream_history[stream_id].append((entry_timestamp, interest_level_float)) new_stream_history[stream_id].append((entry_timestamp, interest_level_float))

View File

@@ -66,34 +66,39 @@ class BackgroundTaskManager:
# 任务配置列表: (任务变量名, 任务函数, 任务名称, 日志级别, 额外日志信息, 任务对象引用属性名) # 任务配置列表: (任务变量名, 任务函数, 任务名称, 日志级别, 额外日志信息, 任务对象引用属性名)
task_configs = [ task_configs = [
(self._state_update_task, (
self._state_update_task,
lambda: self._run_state_update_cycle(self.update_interval), lambda: self._run_state_update_cycle(self.update_interval),
"hf_state_update", "hf_state_update",
"debug", "debug",
f"聊天状态更新任务已启动 间隔:{self.update_interval}s", f"聊天状态更新任务已启动 间隔:{self.update_interval}s",
"_state_update_task"), "_state_update_task",
),
(self._cleanup_task, (
self._cleanup_task,
self._run_cleanup_cycle, self._run_cleanup_cycle,
"hf_cleanup", "hf_cleanup",
"info", "info",
f"清理任务已启动 间隔:{self.cleanup_interval}s 阈值:{self.inactive_threshold}s", f"清理任务已启动 间隔:{self.cleanup_interval}s 阈值:{self.inactive_threshold}s",
"_cleanup_task"), "_cleanup_task",
),
(self._logging_task, (
self._logging_task,
self._run_logging_cycle, self._run_logging_cycle,
"hf_logging", "hf_logging",
"info", "info",
f"日志任务已启动 间隔:{self.log_interval}s", f"日志任务已启动 间隔:{self.log_interval}s",
"_logging_task"), "_logging_task",
),
# 新增兴趣评估任务配置 # 新增兴趣评估任务配置
(self._interest_eval_task, (
self._interest_eval_task,
self._run_interest_eval_cycle, self._run_interest_eval_cycle,
"hf_interest_eval", "hf_interest_eval",
"debug", # 设为debug避免过多日志 "debug", # 设为debug避免过多日志
f"兴趣评估任务已启动 间隔:{self.interest_eval_interval}s", f"兴趣评估任务已启动 间隔:{self.interest_eval_interval}s",
"_interest_eval_task"), "_interest_eval_task",
),
] ]
# 统一启动所有任务 # 统一启动所有任务
@@ -222,6 +227,7 @@ class BackgroundTaskManager:
"""执行一轮子心流兴趣评估与提升检查。""" """执行一轮子心流兴趣评估与提升检查。"""
# 直接调用 subheartflow_manager 的方法,并传递当前状态信息 # 直接调用 subheartflow_manager 的方法,并传递当前状态信息
await self.subheartflow_manager.evaluate_interest_and_promote(self.mai_state_info) await self.subheartflow_manager.evaluate_interest_and_promote(self.mai_state_info)
# --- 结束新增 --- # --- 结束新增 ---
# --- Specific Task Runners --- # # --- Specific Task Runners --- #
@@ -237,14 +243,15 @@ class BackgroundTaskManager:
async def _run_logging_cycle(self): async def _run_logging_cycle(self):
await self._run_periodic_loop( await self._run_periodic_loop(
task_name="State Logging", task_name="State Logging", interval=self.log_interval, task_func=self._perform_logging_work
interval=self.log_interval,
task_func=self._perform_logging_work
) )
# --- 新增兴趣评估任务运行器 --- # --- 新增兴趣评估任务运行器 ---
async def _run_interest_eval_cycle(self): async def _run_interest_eval_cycle(self):
await self._run_periodic_loop( await self._run_periodic_loop(
task_name="Interest Evaluation", interval=self.interest_eval_interval, task_func=self._perform_interest_eval_work task_name="Interest Evaluation",
interval=self.interest_eval_interval,
task_func=self._perform_interest_eval_work,
) )
# --- 结束新增 --- # --- 结束新增 ---

View File

@@ -60,9 +60,7 @@ class InterestLogger:
for subheartflow in all_flows: for subheartflow in all_flows:
if self.subheartflow_manager.get_subheartflow(subheartflow.subheartflow_id): if self.subheartflow_manager.get_subheartflow(subheartflow.subheartflow_id):
tasks.append( tasks.append(
asyncio.create_task( asyncio.create_task(subheartflow.get_full_state(), name=f"get_state_{subheartflow.subheartflow_id}")
subheartflow.get_full_state(), name=f"get_state_{subheartflow.subheartflow_id}"
)
) )
else: else:
logger.warning(f"子心流 {subheartflow.subheartflow_id} 在创建任务前已消失") logger.warning(f"子心流 {subheartflow.subheartflow_id} 在创建任务前已消失")
@@ -107,7 +105,7 @@ class InterestLogger:
"main_mind": main_mind, "main_mind": main_mind,
"mai_state": mai_state_name, "mai_state": mai_state_name,
"subflow_count": len(all_subflow_states), "subflow_count": len(all_subflow_states),
"subflows": [] "subflows": [],
} }
if not all_subflow_states: if not all_subflow_states:

View File

@@ -18,6 +18,7 @@ from src.plugins.chat.chat_stream import chat_manager
import math import math
from src.plugins.heartFC_chat.heartFC_chat import HeartFChatting from src.plugins.heartFC_chat.heartFC_chat import HeartFChatting
from src.plugins.heartFC_chat.normal_chat import NormalChat from src.plugins.heartFC_chat.normal_chat import NormalChat
# from src.do_tool.tool_use import ToolUser # from src.do_tool.tool_use import ToolUser
from src.heart_flow.mai_state_manager import MaiStateInfo from src.heart_flow.mai_state_manager import MaiStateInfo
@@ -147,10 +148,11 @@ class InterestChatting:
decay_factor = math.pow(self.decay_rate_per_second, self.update_interval) decay_factor = math.pow(self.decay_rate_per_second, self.update_interval)
self.interest_level *= decay_factor self.interest_level *= decay_factor
except ValueError as e: except ValueError as e:
interest_logger.error(f"衰减计算错误: {e} 参数: 衰减率={self.decay_rate_per_second} 时间差={self.update_interval} 当前兴趣={self.interest_level}") interest_logger.error(
f"衰减计算错误: {e} 参数: 衰减率={self.decay_rate_per_second} 时间差={self.update_interval} 当前兴趣={self.interest_level}"
)
self.interest_level = 0.0 self.interest_level = 0.0
async def _update_reply_probability(self): async def _update_reply_probability(self):
self.above_threshold = self.interest_level >= self.trigger_threshold self.above_threshold = self.interest_level >= self.trigger_threshold
if self.above_threshold: if self.above_threshold:
@@ -181,7 +183,6 @@ class InterestChatting:
} }
async def should_evaluate_reply(self) -> bool: async def should_evaluate_reply(self) -> bool:
if self.current_reply_probability > 0: if self.current_reply_probability > 0:
trigger = random.random() < self.current_reply_probability trigger = random.random() < self.current_reply_probability
return trigger return trigger
@@ -198,7 +199,6 @@ class InterestChatting:
await self._update_reply_probability() await self._update_reply_probability()
# 等待下一个周期或停止事件 # 等待下一个周期或停止事件
await asyncio.wait_for(self._stop_event.wait(), timeout=update_interval) await asyncio.wait_for(self._stop_event.wait(), timeout=update_interval)
except asyncio.TimeoutError: except asyncio.TimeoutError:
@@ -214,7 +214,6 @@ class InterestChatting:
await asyncio.sleep(5) await asyncio.sleep(5)
interest_logger.info("InterestChatting 更新循环已停止。") interest_logger.info("InterestChatting 更新循环已停止。")
def start_updates(self, update_interval: float = 1.0): def start_updates(self, update_interval: float = 1.0):
"""启动后台更新任务""" """启动后台更新任务"""
if self.update_task is None or self.update_task.done(): if self.update_task is None or self.update_task.done():
@@ -224,7 +223,6 @@ class InterestChatting:
else: else:
interest_logger.debug("后台兴趣更新任务已在运行中。") interest_logger.debug("后台兴趣更新任务已在运行中。")
async def stop_updates(self): async def stop_updates(self):
"""停止后台更新任务""" """停止后台更新任务"""
if self.update_task and not self.update_task.done(): if self.update_task and not self.update_task.done():
@@ -247,6 +245,7 @@ class InterestChatting:
self.update_task = None self.update_task = None
else: else:
interest_logger.debug("InterestChatting 后台更新任务未运行或已完成。") interest_logger.debug("InterestChatting 后台更新任务未运行或已完成。")
# --- 结束 新增方法 --- # --- 结束 新增方法 ---
@@ -406,7 +405,9 @@ class SubHeartflow:
current_chat_count = current_states_num[1] if len(current_states_num) > 1 else 0 current_chat_count = current_states_num[1] if len(current_states_num) > 1 else 0
if current_chat_count >= normal_limit and current_state != ChatState.CHAT: if current_chat_count >= normal_limit and current_state != ChatState.CHAT:
logger.debug(f"{log_prefix} 无法从 {current_state.value} 转到 聊天。原因:聊不过来了 ({current_chat_count}/{normal_limit})") logger.debug(
f"{log_prefix} 无法从 {current_state.value} 转到 聊天。原因:聊不过来了 ({current_chat_count}/{normal_limit})"
)
return # 阻止状态转换 return # 阻止状态转换
else: else:
logger.debug(f"{log_prefix} 准备进入或保持 聊天 状态 ({current_chat_count}/{normal_limit})") logger.debug(f"{log_prefix} 准备进入或保持 聊天 状态 ({current_chat_count}/{normal_limit})")
@@ -423,7 +424,9 @@ class SubHeartflow:
current_focused_count = current_states_num[2] if len(current_states_num) > 2 else 0 current_focused_count = current_states_num[2] if len(current_states_num) > 2 else 0
if current_focused_count >= focused_limit and current_state != ChatState.FOCUSED: if current_focused_count >= focused_limit and current_state != ChatState.FOCUSED:
logger.debug(f"{log_prefix} 无法从 {current_state.value} 转到 专注。原因:聊不过来了 ({current_focused_count}/{focused_limit})") logger.debug(
f"{log_prefix} 无法从 {current_state.value} 转到 专注。原因:聊不过来了 ({current_focused_count}/{focused_limit})"
)
return # 阻止状态转换 return # 阻止状态转换
else: else:
logger.debug(f"{log_prefix} 准备进入或保持 专注聊天 状态 ({current_focused_count}/{focused_limit})") logger.debug(f"{log_prefix} 准备进入或保持 专注聊天 状态 ({current_focused_count}/{focused_limit})")
@@ -435,7 +438,6 @@ class SubHeartflow:
# 启动失败状态回滚到之前的状态或ABSENT这里保持不改变 # 启动失败状态回滚到之前的状态或ABSENT这里保持不改变
return # 启动失败,不改变状态 return # 启动失败,不改变状态
elif new_state == ChatState.ABSENT: elif new_state == ChatState.ABSENT:
logger.info(f"{log_prefix} 进入 ABSENT 状态,停止所有聊天活动...") logger.info(f"{log_prefix} 进入 ABSENT 状态,停止所有聊天活动...")
await self._stop_normal_chat() await self._stop_normal_chat()
@@ -449,7 +451,9 @@ class SubHeartflow:
self.last_active_time = time.time() self.last_active_time = time.time()
else: else:
# 如果因为某些原因(如启动失败)没有成功改变状态,记录一下 # 如果因为某些原因(如启动失败)没有成功改变状态,记录一下
logger.debug(f"{log_prefix} 尝试将状态从 {current_state.value} 变为 {new_state.value},但未成功或未执行更改。") logger.debug(
f"{log_prefix} 尝试将状态从 {current_state.value} 变为 {new_state.value},但未成功或未执行更改。"
)
async def subheartflow_start_working(self): async def subheartflow_start_working(self):
"""启动子心流的后台任务 """启动子心流的后台任务
@@ -463,7 +467,6 @@ class SubHeartflow:
while not self.should_stop: while not self.should_stop:
await asyncio.sleep(30) # 30秒检查一次停止标志 await asyncio.sleep(30) # 30秒检查一次停止标志
logger.info(f"{self.log_prefix} 子心流后台任务已停止。") logger.info(f"{self.log_prefix} 子心流后台任务已停止。")
async def do_thinking_before_reply( async def do_thinking_before_reply(

View File

@@ -271,7 +271,9 @@ class SubHeartflowManager:
current_state_enum = current_mai_state.get_current_state() current_state_enum = current_mai_state.get_current_state()
focused_limit = current_state_enum.get_focused_chat_max_num() focused_limit = current_state_enum.get_focused_chat_max_num()
if focused_limit <= 0: if focused_limit <= 0:
logger.debug(f"{log_prefix_manager} 当前状态 ({current_state_enum.value}) 不允许 FOCUSED 子心流, 跳过提升检查。") logger.debug(
f"{log_prefix_manager} 当前状态 ({current_state_enum.value}) 不允许 FOCUSED 子心流, 跳过提升检查。"
)
return return
# 获取当前 FOCUSED 状态的数量 (初始值) # 获取当前 FOCUSED 状态的数量 (初始值)
@@ -300,7 +302,9 @@ class SubHeartflowManager:
# 注意:在循环内部再次获取当前数量,因为之前的提升可能已经改变了计数 # 注意:在循环内部再次获取当前数量,因为之前的提升可能已经改变了计数
# 使用已经记录并在循环中更新的 current_focused_count # 使用已经记录并在循环中更新的 current_focused_count
if current_focused_count >= focused_limit: if current_focused_count >= focused_limit:
logger.debug(f"{log_prefix_manager} {log_prefix_flow} 达到专注上限 ({current_focused_count}/{focused_limit}), 无法提升。概率={sub_hf.interest_chatting.start_hfc_probability:.2f}") logger.debug(
f"{log_prefix_manager} {log_prefix_flow} 达到专注上限 ({current_focused_count}/{focused_limit}), 无法提升。概率={sub_hf.interest_chatting.start_hfc_probability:.2f}"
)
continue # 跳过这个子心流,继续检查下一个 continue # 跳过这个子心流,继续检查下一个
# --- 执行提升 --- # --- 执行提升 ---
@@ -310,7 +314,9 @@ class SubHeartflowManager:
logger.warning(f"{log_prefix_manager} {log_prefix_flow} 尝试提升时状态已改变或实例消失,跳过。") logger.warning(f"{log_prefix_manager} {log_prefix_flow} 尝试提升时状态已改变或实例消失,跳过。")
continue continue
logger.info(f"{log_prefix_manager} {log_prefix_flow} 兴趣评估触发升级 (prob={sub_hf.interest_chatting.start_hfc_probability:.2f}, 上限:{focused_limit}, 当前:{current_focused_count}) -> FOCUSED") logger.info(
f"{log_prefix_manager} {log_prefix_flow} 兴趣评估触发升级 (prob={sub_hf.interest_chatting.start_hfc_probability:.2f}, 上限:{focused_limit}, 当前:{current_focused_count}) -> FOCUSED"
)
states_num = ( states_num = (
self.count_subflows_by_state(ChatState.ABSENT), self.count_subflows_by_state(ChatState.ABSENT),
@@ -327,14 +333,20 @@ class SubHeartflowManager:
if final_subflow: if final_subflow:
final_state = final_subflow.chat_state.chat_status final_state = final_subflow.chat_state.chat_status
if final_state == ChatState.FOCUSED: if final_state == ChatState.FOCUSED:
logger.debug(f"{log_prefix_manager} {log_prefix_flow} 成功从 {original_state.value} 升级到 FOCUSED 状态") logger.debug(
f"{log_prefix_manager} {log_prefix_flow} 成功从 {original_state.value} 升级到 FOCUSED 状态"
)
promoted_count += 1 promoted_count += 1
# 提升成功后,更新当前专注计数,以便后续检查能使用最新值 # 提升成功后,更新当前专注计数,以便后续检查能使用最新值
current_focused_count += 1 current_focused_count += 1
elif final_state == original_state: # 状态未变 elif final_state == original_state: # 状态未变
logger.warning(f"{log_prefix_manager} {log_prefix_flow} 尝试从 {original_state.value} 升级 FOCUSED 失败,状态仍为: {final_state.value} (可能被内部逻辑阻止)") logger.warning(
f"{log_prefix_manager} {log_prefix_flow} 尝试从 {original_state.value} 升级 FOCUSED 失败,状态仍为: {final_state.value} (可能被内部逻辑阻止)"
)
else: # 状态变成其他了? else: # 状态变成其他了?
logger.warning(f"{log_prefix_manager} {log_prefix_flow} 尝试从 {original_state.value} 升级 FOCUSED 后状态变为 {final_state.value}") logger.warning(
f"{log_prefix_manager} {log_prefix_flow} 尝试从 {original_state.value} 升级 FOCUSED 后状态变为 {final_state.value}"
)
else: # 子心流消失了? else: # 子心流消失了?
logger.warning(f"{log_prefix_manager} {log_prefix_flow} 升级后验证时子心流 {flow_id} 消失") logger.warning(f"{log_prefix_manager} {log_prefix_flow} 升级后验证时子心流 {flow_id} 消失")

View File

@@ -73,10 +73,7 @@ class HeartFChatting:
现在由其关联的 SubHeartflow 管理生命周期。 现在由其关联的 SubHeartflow 管理生命周期。
""" """
def __init__( def __init__(self, chat_id: str):
self,
chat_id: str
):
""" """
HeartFChatting 初始化函数 HeartFChatting 初始化函数

View File

@@ -69,7 +69,6 @@ class HeartFCProcessor:
subheartflow = await heartflow.create_subheartflow(chat.stream_id) subheartflow = await heartflow.create_subheartflow(chat.stream_id)
message.update_chat_stream(chat) message.update_chat_stream(chat)
await heartflow.create_subheartflow(chat.stream_id) await heartflow.create_subheartflow(chat.stream_id)

View File

@@ -358,7 +358,6 @@ class NormalChat:
task.add_done_callback(lambda t: self._handle_task_completion(t)) # 回调现在是实例方法 task.add_done_callback(lambda t: self._handle_task_completion(t)) # 回调现在是实例方法
self._chat_task = task self._chat_task = task
# 改为实例方法, 移除 stream_id 参数 # 改为实例方法, 移除 stream_id 参数
def _handle_task_completion(self, task: asyncio.Task): def _handle_task_completion(self, task: asyncio.Task):
"""兴趣监控任务完成时的回调函数。""" """兴趣监控任务完成时的回调函数。"""
@@ -403,4 +402,3 @@ class NormalChat:
# 确保任务状态更新,即使等待出错 (回调函数也会尝试更新) # 确保任务状态更新,即使等待出错 (回调函数也会尝试更新)
if self._chat_task is task: if self._chat_task is task:
self._chat_task = None self._chat_task = None

View File

@@ -148,7 +148,9 @@ class MessageServer(BaseMessageHandler):
if self.own_app: if self.own_app:
# 如果使用自己的 FastAPI 实例,运行 uvicorn 服务器 # 如果使用自己的 FastAPI 实例,运行 uvicorn 服务器
# 禁用 uvicorn 默认日志和访问日志 # 禁用 uvicorn 默认日志和访问日志
config = uvicorn.Config(self.app, host=self.host, port=self.port, loop="asyncio", log_config=None, access_log=False) config = uvicorn.Config(
self.app, host=self.host, port=self.port, loop="asyncio", log_config=None, access_log=False
)
self.server = uvicorn.Server(config) self.server = uvicorn.Server(config)
await self.server.serve() await self.server.serve()
else: else: