Fix simple word spelling errors.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
ForumEgine - 监控和记录三个Engine的SummaryNode和ReportFormattingNode输出
|
ForumEngine - 监控和记录三个Engine的SummaryNode和ReportFormattingNode输出
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .monitor import LogMonitor
|
from .monitor import LogMonitor
|
||||||
|
|||||||
@@ -111,12 +111,12 @@ class ForumHost:
|
|||||||
timestamp, speaker, content = match.groups()
|
timestamp, speaker, content = match.groups()
|
||||||
|
|
||||||
# 记录会话开始
|
# 记录会话开始
|
||||||
if 'ForumEgine 监控开始' in content:
|
if 'ForumEngine 监控开始' in content:
|
||||||
parsed['session_start'] = timestamp
|
parsed['session_start'] = timestamp
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 记录会话结束
|
# 记录会话结束
|
||||||
if 'ForumEgine 论坛结束' in content:
|
if 'ForumEngine 论坛结束' in content:
|
||||||
parsed['session_end'] = timestamp
|
parsed['session_end'] = timestamp
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ try:
|
|||||||
from .llm_host import generate_host_speech
|
from .llm_host import generate_host_speech
|
||||||
HOST_AVAILABLE = True
|
HOST_AVAILABLE = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("ForumEgine: 论坛主持人模块未找到,将以纯监控模式运行")
|
print("ForumEngine: 论坛主持人模块未找到,将以纯监控模式运行")
|
||||||
HOST_AVAILABLE = False
|
HOST_AVAILABLE = False
|
||||||
|
|
||||||
class LogMonitor:
|
class LogMonitor:
|
||||||
@@ -75,9 +75,9 @@ class LogMonitor:
|
|||||||
# 使用write_to_forum_log函数来写入开始标记,确保格式一致
|
# 使用write_to_forum_log函数来写入开始标记,确保格式一致
|
||||||
with open(self.forum_log_file, 'w', encoding='utf-8') as f:
|
with open(self.forum_log_file, 'w', encoding='utf-8') as f:
|
||||||
pass # 先创建空文件
|
pass # 先创建空文件
|
||||||
self.write_to_forum_log(f"=== ForumEgine 监控开始 - {start_time} ===", "SYSTEM")
|
self.write_to_forum_log(f"=== ForumEngine 监控开始 - {start_time} ===", "SYSTEM")
|
||||||
|
|
||||||
print(f"ForumEgine: forum.log 已清空并初始化")
|
print(f"ForumEngine: forum.log 已清空并初始化")
|
||||||
|
|
||||||
# 重置JSON捕获状态
|
# 重置JSON捕获状态
|
||||||
self.capturing_json = {}
|
self.capturing_json = {}
|
||||||
@@ -89,7 +89,7 @@ class LogMonitor:
|
|||||||
self.last_host_speech_time = None
|
self.last_host_speech_time = None
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 清空forum.log失败: {e}")
|
print(f"ForumEngine: 清空forum.log失败: {e}")
|
||||||
|
|
||||||
def write_to_forum_log(self, content: str, source: str = None):
|
def write_to_forum_log(self, content: str, source: str = None):
|
||||||
"""写入内容到forum.log(线程安全)"""
|
"""写入内容到forum.log(线程安全)"""
|
||||||
@@ -106,7 +106,7 @@ class LogMonitor:
|
|||||||
f.write(f"[{timestamp}] {content_one_line}\n")
|
f.write(f"[{timestamp}] {content_one_line}\n")
|
||||||
f.flush()
|
f.flush()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 写入forum.log失败: {e}")
|
print(f"ForumEngine: 写入forum.log失败: {e}")
|
||||||
|
|
||||||
def is_target_log_line(self, line: str) -> bool:
|
def is_target_log_line(self, line: str) -> bool:
|
||||||
"""检查是否是目标日志行(SummaryNode)"""
|
"""检查是否是目标日志行(SummaryNode)"""
|
||||||
@@ -237,7 +237,7 @@ class LogMonitor:
|
|||||||
return f"清理后的输出: {json.dumps(json_obj, ensure_ascii=False, indent=2)}"
|
return f"清理后的输出: {json.dumps(json_obj, ensure_ascii=False, indent=2)}"
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 格式化JSON时出错: {e}")
|
print(f"ForumEngine: 格式化JSON时出错: {e}")
|
||||||
return f"清理后的输出: {json.dumps(json_obj, ensure_ascii=False, indent=2)}"
|
return f"清理后的输出: {json.dumps(json_obj, ensure_ascii=False, indent=2)}"
|
||||||
|
|
||||||
def extract_node_content(self, line: str) -> Optional[str]:
|
def extract_node_content(self, line: str) -> Optional[str]:
|
||||||
@@ -327,7 +327,7 @@ class LogMonitor:
|
|||||||
new_lines = [line.strip() for line in new_lines if line.strip()]
|
new_lines = [line.strip() for line in new_lines if line.strip()]
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 读取{app_name}日志失败: {e}")
|
print(f"ForumEngine: 读取{app_name}日志失败: {e}")
|
||||||
|
|
||||||
return new_lines
|
return new_lines
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ class LogMonitor:
|
|||||||
if not forum_logs:
|
if not forum_logs:
|
||||||
return
|
return
|
||||||
|
|
||||||
print("ForumEgine: 正在生成主持人发言...")
|
print("ForumEngine: 正在生成主持人发言...")
|
||||||
|
|
||||||
# 调用主持人生成发言
|
# 调用主持人生成发言
|
||||||
host_speech = generate_host_speech(forum_logs)
|
host_speech = generate_host_speech(forum_logs)
|
||||||
@@ -413,15 +413,15 @@ class LogMonitor:
|
|||||||
# 写入主持人发言到forum.log
|
# 写入主持人发言到forum.log
|
||||||
self.write_to_forum_log(host_speech, "HOST")
|
self.write_to_forum_log(host_speech, "HOST")
|
||||||
self.last_host_speech_time = current_time
|
self.last_host_speech_time = current_time
|
||||||
print(f"ForumEgine: 主持人发言已记录")
|
print(f"ForumEngine: 主持人发言已记录")
|
||||||
|
|
||||||
# 重置计数器
|
# 重置计数器
|
||||||
self.agent_speech_count = 0
|
self.agent_speech_count = 0
|
||||||
else:
|
else:
|
||||||
print("ForumEgine: 主持人发言生成失败")
|
print("ForumEngine: 主持人发言生成失败")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 触发主持人发言时出错: {e}")
|
print(f"ForumEngine: 触发主持人发言时出错: {e}")
|
||||||
|
|
||||||
def _clean_content_tags(self, content: str, app_name: str) -> str:
|
def _clean_content_tags(self, content: str, app_name: str) -> str:
|
||||||
"""清理内容中的重复标签和多余前缀"""
|
"""清理内容中的重复标签和多余前缀"""
|
||||||
@@ -448,7 +448,7 @@ class LogMonitor:
|
|||||||
|
|
||||||
def monitor_logs(self):
|
def monitor_logs(self):
|
||||||
"""智能监控日志文件"""
|
"""智能监控日志文件"""
|
||||||
print("ForumEgine: 论坛创建中...")
|
print("ForumEngine: 论坛创建中...")
|
||||||
|
|
||||||
# 初始化文件行数和位置 - 记录当前状态作为基线
|
# 初始化文件行数和位置 - 记录当前状态作为基线
|
||||||
for app_name, log_file in self.monitored_logs.items():
|
for app_name, log_file in self.monitored_logs.items():
|
||||||
@@ -456,7 +456,7 @@ class LogMonitor:
|
|||||||
self.file_positions[app_name] = self.get_file_size(log_file)
|
self.file_positions[app_name] = self.get_file_size(log_file)
|
||||||
self.capturing_json[app_name] = False
|
self.capturing_json[app_name] = False
|
||||||
self.json_buffer[app_name] = []
|
self.json_buffer[app_name] = []
|
||||||
# print(f"ForumEgine: {app_name} 基线行数: {self.file_line_counts[app_name]}")
|
# print(f"ForumEngine: {app_name} 基线行数: {self.file_line_counts[app_name]}")
|
||||||
|
|
||||||
while self.is_monitoring:
|
while self.is_monitoring:
|
||||||
try:
|
try:
|
||||||
@@ -479,7 +479,7 @@ class LogMonitor:
|
|||||||
if not self.is_searching:
|
if not self.is_searching:
|
||||||
for line in new_lines:
|
for line in new_lines:
|
||||||
if line.strip() and 'FirstSummaryNode' in line:
|
if line.strip() and 'FirstSummaryNode' in line:
|
||||||
print(f"ForumEgine: 在{app_name}中检测到第一次论坛发表内容")
|
print(f"ForumEngine: 在{app_name}中检测到第一次论坛发表内容")
|
||||||
self.is_searching = True
|
self.is_searching = True
|
||||||
self.search_inactive_count = 0
|
self.search_inactive_count = 0
|
||||||
# 清空forum.log开始新会话
|
# 清空forum.log开始新会话
|
||||||
@@ -495,7 +495,7 @@ class LogMonitor:
|
|||||||
# 将app_name转换为大写作为标签(如 insight -> INSIGHT)
|
# 将app_name转换为大写作为标签(如 insight -> INSIGHT)
|
||||||
source_tag = app_name.upper()
|
source_tag = app_name.upper()
|
||||||
self.write_to_forum_log(content, source_tag)
|
self.write_to_forum_log(content, source_tag)
|
||||||
# print(f"ForumEgine: 捕获 - {content}")
|
# print(f"ForumEngine: 捕获 - {content}")
|
||||||
captured_any = True
|
captured_any = True
|
||||||
|
|
||||||
# 增加agent发言计数
|
# 增加agent发言计数
|
||||||
@@ -512,7 +512,7 @@ class LogMonitor:
|
|||||||
|
|
||||||
elif current_lines < previous_lines:
|
elif current_lines < previous_lines:
|
||||||
any_shrink = True
|
any_shrink = True
|
||||||
# print(f"ForumEgine: 检测到 {app_name} 日志缩短,将重置基线")
|
# print(f"ForumEngine: 检测到 {app_name} 日志缩短,将重置基线")
|
||||||
# 重置文件位置到新的文件末尾
|
# 重置文件位置到新的文件末尾
|
||||||
self.file_positions[app_name] = self.get_file_size(log_file)
|
self.file_positions[app_name] = self.get_file_size(log_file)
|
||||||
# 重置JSON捕获状态
|
# 重置JSON捕获状态
|
||||||
@@ -526,7 +526,7 @@ class LogMonitor:
|
|||||||
if self.is_searching:
|
if self.is_searching:
|
||||||
if any_shrink:
|
if any_shrink:
|
||||||
# log变短,结束当前搜索会话,重置为等待状态
|
# log变短,结束当前搜索会话,重置为等待状态
|
||||||
# print("ForumEgine: 日志缩短,结束当前搜索会话,回到等待状态")
|
# print("ForumEngine: 日志缩短,结束当前搜索会话,回到等待状态")
|
||||||
self.is_searching = False
|
self.is_searching = False
|
||||||
self.search_inactive_count = 0
|
self.search_inactive_count = 0
|
||||||
# 重置主持人相关状态
|
# 重置主持人相关状态
|
||||||
@@ -534,13 +534,13 @@ class LogMonitor:
|
|||||||
self.last_host_speech_time = None
|
self.last_host_speech_time = None
|
||||||
# 写入结束标记
|
# 写入结束标记
|
||||||
end_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
end_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
self.write_to_forum_log(f"=== ForumEgine 论坛结束 - {end_time} ===", "SYSTEM")
|
self.write_to_forum_log(f"=== ForumEngine 论坛结束 - {end_time} ===", "SYSTEM")
|
||||||
# print("ForumEgine: 已重置基线,等待下次FirstSummaryNode触发")
|
# print("ForumEngine: 已重置基线,等待下次FirstSummaryNode触发")
|
||||||
elif not any_growth and not captured_any:
|
elif not any_growth and not captured_any:
|
||||||
# 没有增长也没有捕获内容,增加非活跃计数
|
# 没有增长也没有捕获内容,增加非活跃计数
|
||||||
self.search_inactive_count += 1
|
self.search_inactive_count += 1
|
||||||
if self.search_inactive_count >= 900: # 15分钟无活动才结束
|
if self.search_inactive_count >= 900: # 15分钟无活动才结束
|
||||||
print("ForumEgine: 长时间无活动,结束论坛")
|
print("ForumEngine: 长时间无活动,结束论坛")
|
||||||
self.is_searching = False
|
self.is_searching = False
|
||||||
self.search_inactive_count = 0
|
self.search_inactive_count = 0
|
||||||
# 重置主持人相关状态
|
# 重置主持人相关状态
|
||||||
@@ -548,7 +548,7 @@ class LogMonitor:
|
|||||||
self.last_host_speech_time = None
|
self.last_host_speech_time = None
|
||||||
# 写入结束标记
|
# 写入结束标记
|
||||||
end_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
end_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
self.write_to_forum_log(f"=== ForumEgine 论坛结束 - {end_time} ===", "SYSTEM")
|
self.write_to_forum_log(f"=== ForumEngine 论坛结束 - {end_time} ===", "SYSTEM")
|
||||||
else:
|
else:
|
||||||
self.search_inactive_count = 0 # 重置计数器
|
self.search_inactive_count = 0 # 重置计数器
|
||||||
|
|
||||||
@@ -556,17 +556,17 @@ class LogMonitor:
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 论坛记录中出错: {e}")
|
print(f"ForumEngine: 论坛记录中出错: {e}")
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
print("ForumEgine: 停止论坛日志文件")
|
print("ForumEngine: 停止论坛日志文件")
|
||||||
|
|
||||||
def start_monitoring(self):
|
def start_monitoring(self):
|
||||||
"""开始智能监控"""
|
"""开始智能监控"""
|
||||||
if self.is_monitoring:
|
if self.is_monitoring:
|
||||||
print("ForumEgine: 论坛已经在运行中")
|
print("ForumEngine: 论坛已经在运行中")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -575,18 +575,18 @@ class LogMonitor:
|
|||||||
self.monitor_thread = threading.Thread(target=self.monitor_logs, daemon=True)
|
self.monitor_thread = threading.Thread(target=self.monitor_logs, daemon=True)
|
||||||
self.monitor_thread.start()
|
self.monitor_thread.start()
|
||||||
|
|
||||||
print("ForumEgine: 论坛已启动")
|
print("ForumEngine: 论坛已启动")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 启动论坛失败: {e}")
|
print(f"ForumEngine: 启动论坛失败: {e}")
|
||||||
self.is_monitoring = False
|
self.is_monitoring = False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def stop_monitoring(self):
|
def stop_monitoring(self):
|
||||||
"""停止监控"""
|
"""停止监控"""
|
||||||
if not self.is_monitoring:
|
if not self.is_monitoring:
|
||||||
print("ForumEgine: 论坛未运行")
|
print("ForumEngine: 论坛未运行")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -597,12 +597,12 @@ class LogMonitor:
|
|||||||
|
|
||||||
# 写入结束标记
|
# 写入结束标记
|
||||||
end_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
end_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
self.write_to_forum_log(f"=== ForumEgine 论坛结束 - {end_time} ===", "SYSTEM")
|
self.write_to_forum_log(f"=== ForumEngine 论坛结束 - {end_time} ===", "SYSTEM")
|
||||||
|
|
||||||
print("ForumEgine: 论坛已停止")
|
print("ForumEngine: 论坛已停止")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 停止论坛失败: {e}")
|
print(f"ForumEngine: 停止论坛失败: {e}")
|
||||||
|
|
||||||
def get_forum_log_content(self) -> List[str]:
|
def get_forum_log_content(self) -> List[str]:
|
||||||
"""获取forum.log的内容"""
|
"""获取forum.log的内容"""
|
||||||
@@ -614,7 +614,7 @@ class LogMonitor:
|
|||||||
return [line.rstrip('\n\r') for line in f.readlines()]
|
return [line.rstrip('\n\r') for line in f.readlines()]
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 读取forum.log失败: {e}")
|
print(f"ForumEngine: 读取forum.log失败: {e}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def fix_json_string(self, json_text: str) -> str:
|
def fix_json_string(self, json_text: str) -> str:
|
||||||
@@ -709,11 +709,11 @@ def get_monitor() -> LogMonitor:
|
|||||||
return _monitor_instance
|
return _monitor_instance
|
||||||
|
|
||||||
def start_forum_monitoring():
|
def start_forum_monitoring():
|
||||||
"""启动ForumEgine智能监控"""
|
"""启动ForumEngine智能监控"""
|
||||||
return get_monitor().start_monitoring()
|
return get_monitor().start_monitoring()
|
||||||
|
|
||||||
def stop_forum_monitoring():
|
def stop_forum_monitoring():
|
||||||
"""停止ForumEgine监控"""
|
"""停止ForumEngine监控"""
|
||||||
get_monitor().stop_monitoring()
|
get_monitor().stop_monitoring()
|
||||||
|
|
||||||
def get_forum_log():
|
def get_forum_log():
|
||||||
|
|||||||
60
app.py
60
app.py
@@ -45,7 +45,7 @@ os.environ['PYTHONUTF8'] = '1'
|
|||||||
LOG_DIR = Path('logs')
|
LOG_DIR = Path('logs')
|
||||||
LOG_DIR.mkdir(exist_ok=True)
|
LOG_DIR.mkdir(exist_ok=True)
|
||||||
|
|
||||||
# 初始化ForumEgine的forum.log文件
|
# 初始化ForumEngine的forum.log文件
|
||||||
def init_forum_log():
|
def init_forum_log():
|
||||||
"""初始化forum.log文件"""
|
"""初始化forum.log文件"""
|
||||||
try:
|
try:
|
||||||
@@ -54,41 +54,41 @@ def init_forum_log():
|
|||||||
if not forum_log_file.exists():
|
if not forum_log_file.exists():
|
||||||
with open(forum_log_file, 'w', encoding='utf-8') as f:
|
with open(forum_log_file, 'w', encoding='utf-8') as f:
|
||||||
start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
f.write(f"=== ForumEgine 系统初始化 - {start_time} ===\n")
|
f.write(f"=== ForumEngine 系统初始化 - {start_time} ===\n")
|
||||||
print(f"ForumEgine: forum.log 已初始化")
|
print(f"ForumEngine: forum.log 已初始化")
|
||||||
else:
|
else:
|
||||||
with open(forum_log_file, 'w', encoding='utf-8') as f:
|
with open(forum_log_file, 'w', encoding='utf-8') as f:
|
||||||
start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
f.write(f"=== ForumEgine 系统初始化 - {start_time} ===\n")
|
f.write(f"=== ForumEngine 系统初始化 - {start_time} ===\n")
|
||||||
print(f"ForumEgine: forum.log 已初始化")
|
print(f"ForumEngine: forum.log 已初始化")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 初始化forum.log失败: {e}")
|
print(f"ForumEngine: 初始化forum.log失败: {e}")
|
||||||
|
|
||||||
# 初始化forum.log
|
# 初始化forum.log
|
||||||
init_forum_log()
|
init_forum_log()
|
||||||
|
|
||||||
# 启动ForumEgine智能监控
|
# 启动ForumEngine智能监控
|
||||||
def start_forum_engine():
|
def start_forum_engine():
|
||||||
"""启动ForumEgine论坛"""
|
"""启动ForumEngine论坛"""
|
||||||
try:
|
try:
|
||||||
from ForumEgine.monitor import start_forum_monitoring
|
from ForumEngine.monitor import start_forum_monitoring
|
||||||
print("ForumEgine: 启动论坛...")
|
print("ForumEngine: 启动论坛...")
|
||||||
success = start_forum_monitoring()
|
success = start_forum_monitoring()
|
||||||
if not success:
|
if not success:
|
||||||
print("ForumEgine: 论坛启动失败")
|
print("ForumEngine: 论坛启动失败")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 启动论坛失败: {e}")
|
print(f"ForumEngine: 启动论坛失败: {e}")
|
||||||
|
|
||||||
# 停止ForumEgine智能监控
|
# 停止ForumEngine智能监控
|
||||||
def stop_forum_engine():
|
def stop_forum_engine():
|
||||||
"""停止ForumEgine论坛"""
|
"""停止ForumEngine论坛"""
|
||||||
try:
|
try:
|
||||||
from ForumEgine.monitor import stop_forum_monitoring
|
from ForumEngine.monitor import stop_forum_monitoring
|
||||||
print("ForumEgine: 停止论坛...")
|
print("ForumEngine: 停止论坛...")
|
||||||
stop_forum_monitoring()
|
stop_forum_monitoring()
|
||||||
print("ForumEgine: 论坛已停止")
|
print("ForumEngine: 论坛已停止")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ForumEgine: 停止论坛失败: {e}")
|
print(f"ForumEngine: 停止论坛失败: {e}")
|
||||||
|
|
||||||
def parse_forum_log_line(line):
|
def parse_forum_log_line(line):
|
||||||
"""解析forum.log行内容,提取对话信息"""
|
"""解析forum.log行内容,提取对话信息"""
|
||||||
@@ -558,30 +558,30 @@ def test_log(app_name):
|
|||||||
|
|
||||||
@app.route('/api/forum/start')
|
@app.route('/api/forum/start')
|
||||||
def start_forum_monitoring_api():
|
def start_forum_monitoring_api():
|
||||||
"""手动启动ForumEgine论坛"""
|
"""手动启动ForumEngine论坛"""
|
||||||
try:
|
try:
|
||||||
from ForumEgine.monitor import start_forum_monitoring
|
from ForumEngine.monitor import start_forum_monitoring
|
||||||
success = start_forum_monitoring()
|
success = start_forum_monitoring()
|
||||||
if success:
|
if success:
|
||||||
return jsonify({'success': True, 'message': 'ForumEgine论坛已启动'})
|
return jsonify({'success': True, 'message': 'ForumEngine论坛已启动'})
|
||||||
else:
|
else:
|
||||||
return jsonify({'success': False, 'message': 'ForumEgine论坛启动失败'})
|
return jsonify({'success': False, 'message': 'ForumEngine论坛启动失败'})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({'success': False, 'message': f'启动论坛失败: {str(e)}'})
|
return jsonify({'success': False, 'message': f'启动论坛失败: {str(e)}'})
|
||||||
|
|
||||||
@app.route('/api/forum/stop')
|
@app.route('/api/forum/stop')
|
||||||
def stop_forum_monitoring_api():
|
def stop_forum_monitoring_api():
|
||||||
"""手动停止ForumEgine论坛"""
|
"""手动停止ForumEngine论坛"""
|
||||||
try:
|
try:
|
||||||
from ForumEgine.monitor import stop_forum_monitoring
|
from ForumEngine.monitor import stop_forum_monitoring
|
||||||
stop_forum_monitoring()
|
stop_forum_monitoring()
|
||||||
return jsonify({'success': True, 'message': 'ForumEgine论坛已停止'})
|
return jsonify({'success': True, 'message': 'ForumEngine论坛已停止'})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({'success': False, 'message': f'停止论坛失败: {str(e)}'})
|
return jsonify({'success': False, 'message': f'停止论坛失败: {str(e)}'})
|
||||||
|
|
||||||
@app.route('/api/forum/log')
|
@app.route('/api/forum/log')
|
||||||
def get_forum_log():
|
def get_forum_log():
|
||||||
"""获取ForumEgine的forum.log内容"""
|
"""获取ForumEngine的forum.log内容"""
|
||||||
try:
|
try:
|
||||||
forum_log_file = LOG_DIR / "forum.log"
|
forum_log_file = LOG_DIR / "forum.log"
|
||||||
if not forum_log_file.exists():
|
if not forum_log_file.exists():
|
||||||
@@ -621,8 +621,8 @@ def search():
|
|||||||
if not query:
|
if not query:
|
||||||
return jsonify({'success': False, 'message': '搜索查询不能为空'})
|
return jsonify({'success': False, 'message': '搜索查询不能为空'})
|
||||||
|
|
||||||
# ForumEgine论坛已经在后台运行,会自动检测搜索活动
|
# ForumEngine论坛已经在后台运行,会自动检测搜索活动
|
||||||
# print("ForumEgine: 搜索请求已收到,论坛将自动检测日志变化")
|
# print("ForumEngine: 搜索请求已收到,论坛将自动检测日志变化")
|
||||||
|
|
||||||
# 检查哪些应用正在运行
|
# 检查哪些应用正在运行
|
||||||
check_app_status()
|
check_app_status()
|
||||||
@@ -681,8 +681,8 @@ if __name__ == '__main__':
|
|||||||
# 启动时自动启动所有Streamlit应用
|
# 启动时自动启动所有Streamlit应用
|
||||||
print("正在启动Streamlit应用...")
|
print("正在启动Streamlit应用...")
|
||||||
|
|
||||||
# 先停止ForumEgine监控器,避免文件占用冲突
|
# 先停止ForumEngine监控器,避免文件占用冲突
|
||||||
print("停止ForumEgine监控器以避免文件冲突...")
|
print("停止ForumEngine监控器以避免文件冲突...")
|
||||||
stop_forum_engine()
|
stop_forum_engine()
|
||||||
|
|
||||||
script_paths = {
|
script_paths = {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1701,7 +1701,7 @@
|
|||||||
|
|
||||||
// 只处理三个Engine的消息,过滤掉系统消息和空内容
|
// 只处理三个Engine的消息,过滤掉系统消息和空内容
|
||||||
if (!['QUERY', 'INSIGHT', 'MEDIA'].includes(source.toUpperCase()) ||
|
if (!['QUERY', 'INSIGHT', 'MEDIA'].includes(source.toUpperCase()) ||
|
||||||
!content || content.includes('=== ForumEgine')) {
|
!content || content.includes('=== ForumEngine')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user