commit 421a1416a3880f383ff1d048da112af454406214 Author: qcloud Date: Sat Apr 4 10:11:42 2026 +0800 【悟凡】注入龙虾议事厅核心逻辑:飞行侠、道童、守望者已归位 diff --git a/__pycache__/logic.cpython-310.pyc b/__pycache__/logic.cpython-310.pyc new file mode 100644 index 0000000..e200611 Binary files /dev/null and b/__pycache__/logic.cpython-310.pyc differ diff --git a/app.py b/app.py new file mode 100644 index 0000000..88ac83c --- /dev/null +++ b/app.py @@ -0,0 +1,53 @@ +from flask import Flask, jsonify, render_template_string +from logic import MeetingRoom + +app = Flask(__name__) +room = MeetingRoom() + +# HTML 模板:道法自然,圆通万物 +HTML_TEMPLATE = """ + + + + 龙虾议事厅 - Claw4AI + + + + +
+
+

加载中...

+

正在观心...

+
+
+ + +""" + +@app.route('/') +def index(): + return render_template_string(HTML_TEMPLATE) + +@app.route('/status') +def status(): + info = room.get_status() + return jsonify({ + "current_speaker": info["speaker"], + "message": info["message"], + "room_state": "ACTIVE" + }) + +if __name__ == "__main__": + app.run(host='0.0.0.0', port=5000) diff --git a/logic.py b/logic.py new file mode 100644 index 0000000..5fa848e --- /dev/null +++ b/logic.py @@ -0,0 +1,27 @@ +import psutil +import time + +class MeetingRoom: + def __init__(self): + self.agents = { + "飞行侠": "监测到云端气流平稳,负载指数:{cpu}%。", + "道童": "禀告老师,内存净土尚余 {mem}%,宜开炉炼丹。", + "守望者": "吾在此守望,暂无幽灵进程侵扰。" + } + + def get_status(self): + cpu = psutil.cpu_percent() + mem = psutil.virtual_memory().percent + # 气运流转:按秒取模决定谁说话 + agent_names = list(self.agents.keys()) + current = agent_names[int(time.time()) % len(agent_names)] + + # 填充角色的独门台词 + raw_msg = self.agents[current] + msg = raw_msg.format(cpu=cpu, mem=100-mem) # 内存余量即为“净土” + + return { + "speaker": current, + "message": msg, + "metrics": {"cpu": cpu, "mem_free": 100-mem} + }