#!/usr/bin/env python3 """ Project Aura × DeepSeek R1 — 完整集成示例 本示例展示如何将 Aura 调度系统直接套进 DeepSeek R1 模型, 实现有呼吸感的AI主动性。 用法: # 基本演示(使用规则引擎Fallback,无需GPU) python r1_integration.py # 完整模式(加载DeepSeek R1 + LoRA) python r1_integration.py --model ljsysfurry/DeepSeek-R1-Distill-Qwen-7B --lora ljsysfurry/deepseek-r1-7b-xiaoshan-lora 架构: ┌─────────────────────────────────────────────┐ │ Aura 调度引擎 │ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────────┐ │ │ │心跳 │→│双系统 │→│价值 │→│反骚扰 │ │ │ │调度器│ │决策器│ │网络 │ │漏斗 │ │ │ └──────┘ └──────┘ └──────┘ └──────────┘ │ │ ↓ │ │ ┌──────────────────────────────────────┐ │ │ │ DeepSeek R1 生成层 │ │ │ │ (内容生成 / 慢系统评估) │ │ │ └──────────────────────────────────────┘ │ │ ↓ │ │ ┌──────────────────────────────────────┐ │ │ │ 表达层 + 用户界面 │ │ │ │ (呼吸光效/标题/完整消息) │ │ │ └──────────────────────────────────────┘ │ └─────────────────────────────────────────────┘ """ import time import argparse import sys import os # 添加父目录到路径 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from aura.config import AuraConfig from aura.engine import AuraEngine from aura.interaction import ExpressionOutput, NotificationLevel def simulate_conversation(engine: AuraEngine): """模拟一个完整的用户使用场景""" print("\n" + "=" * 60) print(" Project Aura × DeepSeek R1 — 集成演示") print("=" * 60) print() print("场景:用户晚上10点还在加班,已经1小时没说话了") print() # 用户最后一条消息(1小时前) engine.user_interacted("最近项目压力好大,感觉快撑不住了", mood="anxious") print("[用户] 最近项目压力好大,感觉快撑不住了") # 模拟1小时空闲 engine.perception.update( last_interaction_time=time.time() - 3600, is_active_session=False, device_mode="normal", ) print("[系统] 1小时后...") print() # 主动触发决策 print("[Aura] 决策中...") engine.on_tick() print() # 用户回复后 print("[用户] 嗯,你说得对,我准备休息了") engine.user_interacted("嗯,你说得对,我准备休息了") print() # 深夜关怀 engine.perception.update(device_mode="sleep") print("[系统] 深夜,用户已进入睡眠...") engine.on_tick() print() # 第二天早上 print("[系统] 第二天早上...") engine.perception.update( device_mode="normal", last_interaction_time=time.time() - 28800, # 8小时 ) engine.on_tick() print() # 用户拒绝 print("[用户] 别老问我好不好,让我静静") engine.antispam.record_rejection() print() # 检查冷却 engine.on_tick() print() def main(): parser = argparse.ArgumentParser(description="Project Aura × DeepSeek R1 集成演示") parser.add_argument("--model", default="", help="DeepSeek R1 模型路径(留空使用规则引擎Fallback)") parser.add_argument("--lora", default="", help="LoRA 适配器路径(可选)") parser.add_argument("--dry-run", action="store_true", help="仅测试调度系统,不加载模型") args = parser.parse_args() # 配置 config = AuraConfig() if args.model: config.r1_model_path = args.model if args.lora: config.r1_lora_path = args.lora # 初始化引擎 engine = AuraEngine(config) # 设置消息回调 def on_message(output: ExpressionOutput): level_map = { NotificationLevel.BREATHING: "🌫 (呼吸光效)", NotificationLevel.TITLE: "📎 (标题预览)", NotificationLevel.FULL: "💬 (完整消息)", } print(f"[Aura] → {level_map.get(output.level, '')} {output.body}") engine.set_message_callback(on_message) # 加载模型(如果指定了路径) if args.model and not args.dry_run: print("[Aura] 正在加载 DeepSeek R1...") engine.load_model() else: print("[Aura] 使用规则引擎 Fallback(未加载LLM)") # 启动系统 engine.start() try: simulate_conversation(engine) except KeyboardInterrupt: print("\n[Aura] 用户中断") finally: engine.stop() print("\n" + "=" * 60) print(" ✅ 演示完成") print(" 开源防御声明: PROJECT_ROOT/PATENT_DEFENSE.md") print("=" * 60) if __name__ == "__main__": main()