-
-
Save Xiaozonglin/2954257501bb5516d8c898fb6ab322dd to your computer and use it in GitHub Desktop.
xdwe manim展示视频代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from manim import * | |
| import json | |
| class XDWeRefinedPresentation(Scene): | |
| def construct(self): | |
| # ============================== | |
| # 0. 全局配置部分 (Configuration) | |
| # ============================== | |
| # 字体配置 (请确保系统中安装了 'Source Han Serif CN' 或替换为你电脑里有的中文字体) | |
| han_font = "Source Han Serif CN" | |
| # 颜色配置 (Color Palette) | |
| COL_STUDENT = BLUE_C | |
| COL_TEACHER = GREEN_C | |
| COL_AI = PURPLE_C | |
| COL_KB = YELLOW_C | |
| COL_TEXT_DEH = GRAY_C | |
| # 定义通用文本样式函数,保持全局风格统一 | |
| def DehText(text, **kwargs): | |
| if 'color' not in kwargs: | |
| kwargs['color'] = COL_TEXT_DEH | |
| return Text(text, font=han_font, **kwargs) | |
| def EngText(text, **kwargs): | |
| return Text(text, **kwargs) | |
| # ============================== | |
| # 场景 1:项目简介 (Intro) - 精炼版 | |
| # ============================== | |
| text_title = EngText("XDAgent", font_size=68, weight=BOLD).shift(UP * 1.2) | |
| text_subtitle_1 = EngText("Teacher-Augmented AI Learning System", font_size=28, color=COL_STUDENT) | |
| text_subtitle_2 = EngText("for Xidian University", font_size=28, color=COL_STUDENT) | |
| text_desc = DehText("一个 AI 驱动的师生交流互动平台", font_size=24, color=WHITE) | |
| subtitle_group = VGroup(text_subtitle_1, text_subtitle_2).arrange(DOWN, buff=0.2).next_to(text_title, DOWN, buff=0.4) | |
| text_desc.next_to(subtitle_group, DOWN, buff=0.8) | |
| # 动画入场 | |
| self.play(Write(text_title, run_time=1.5)) | |
| self.wait(0.3) | |
| self.play(FadeIn(subtitle_group, shift=UP)) | |
| self.wait(0.5) | |
| self.play(Write(text_desc, run_time=1.5)) | |
| self.wait(2) | |
| # 场景切换:整体淡出 | |
| self.play(FadeOut(VGroup(text_title, subtitle_group, text_desc), shift=DOWN)) | |
| # ============================== | |
| # 场景 2:核心 RAG 闭环生态演示 (细节强化) | |
| # ============================== | |
| loop_title = DehText("XDAgent 知识闭环生态", font_size=36, color=WHITE).to_edge(UP) | |
| self.play(Write(loop_title)) | |
| # --- 创建四个核心节点 --- | |
| node_student = VGroup( | |
| Circle(radius=0.8, color=COL_STUDENT, fill_opacity=0.15, stroke_width=4), | |
| DehText("学生\nStudent", font_size=20, color=WHITE, line_spacing=0.5) | |
| ).move_to(LEFT * 4 + UP * 0.5) | |
| node_ai = VGroup( | |
| RoundedRectangle(corner_radius=0.2, height=1.6, width=2.8, color=COL_AI, fill_opacity=0.15, stroke_width=4), | |
| DehText("AI 模型\n(Qwen2.5 + RAG)", font_size=20, color=WHITE, line_spacing=0.5) | |
| ).move_to(ORIGIN + UP * 0.5) | |
| node_teacher = VGroup( | |
| Circle(radius=0.8, color=COL_TEACHER, fill_opacity=0.15, stroke_width=4), | |
| DehText("教师\nTeacher", font_size=20, color=WHITE, line_spacing=0.5) | |
| ).move_to(RIGHT * 4 + UP * 0.5) | |
| node_kb = VGroup( | |
| Rectangle(height=1.2, width=3.2, color=COL_KB, fill_opacity=0.15, stroke_width=3), | |
| DehText("本地动态知识库\n(FAISS Index)", font_size=20, color=COL_KB, line_spacing=0.5) | |
| ).move_to(DOWN * 2.5) | |
| # 节点动画入场 | |
| self.play( | |
| SpinInFromNothing(node_student), | |
| SpinInFromNothing(node_teacher), | |
| run_time=1 | |
| ) | |
| self.play(DrawBorderThenFill(node_ai), run_time=0.8) | |
| self.play(FadeIn(node_kb, shift=UP), run_time=0.8) | |
| # --- 流程演练 --- | |
| # 1. 提问 (加入消息气泡飞行动效) | |
| arrow_ask = Arrow(node_student.get_right(), node_ai.get_left(), buff=0.1, color=COL_STUDENT) | |
| label_ask = DehText("1. 提问", font_size=16, color=COL_STUDENT).next_to(arrow_ask, UP, buff=0.1) | |
| msg_bubble = RoundedRectangle(height=0.4, width=0.6, corner_radius=0.1, color=COL_STUDENT, fill_opacity=0.8) | |
| msg_mark = EngText("?", font_size=24, color=WHITE).move_to(msg_bubble.get_center()) | |
| msg_group = VGroup(msg_bubble, msg_mark).move_to(node_student.get_right()) | |
| self.play(GrowArrow(arrow_ask), FadeIn(label_ask, shift=UP)) | |
| self.play(msg_group.animate.move_to(node_ai.get_left()), run_time=0.8) | |
| self.play(FadeOut(msg_group), Flash(node_ai, color=COL_STUDENT, flash_radius=1.5, line_length=0.2)) | |
| # 2. 语义检索 | |
| arrow_retrieve = DoubleArrow(node_ai.get_bottom(), node_kb.get_top(), buff=0.1, color=COL_KB) | |
| label_retrieve = DehText("2. 语义检索", font_size=16, color=COL_KB).next_to(arrow_retrieve, RIGHT, buff=0.1) | |
| self.play(Create(arrow_retrieve), FadeIn(label_retrieve, shift=LEFT)) | |
| self.play(Indicate(node_kb, color=COL_KB, scale_factor=1.1)) | |
| # 3. AI初答 | |
| arrow_ans = Arrow(node_ai.get_top(), node_student.get_top(), path_arc=1.2, color=COL_AI) | |
| label_ans = DehText("生成初答", font_size=16, color=COL_AI).next_to(arrow_ans, UP, buff=0.1) | |
| self.play(Create(arrow_ans), Write(label_ans)) | |
| # 4. 教师审核 (重点:教师介入改变AI状态) | |
| arrow_verify = Arrow(node_teacher.get_left(), node_ai.get_right(), buff=0.1, color=COL_TEACHER) | |
| label_verify = DehText("3. 审核 / 权威纠偏", font_size=16, color=COL_TEACHER).next_to(arrow_verify, UP, buff=0.1) | |
| self.play(GrowArrow(arrow_verify), FadeIn(label_verify, shift=LEFT)) | |
| # AI 模型颜色闪烁为绿色,代表注入了教师的权威数据 | |
| self.play(node_ai[0].animate.set_color(COL_TEACHER), run_time=0.4) | |
| self.play(node_ai[0].animate.set_color(COL_AI), run_time=0.4) | |
| # 5. 知识沉淀 | |
| arrow_precipitate = CurvedArrow(node_teacher.get_bottom(), node_kb.get_right(), angle=-TAU/4, color=COL_KB) | |
| label_precipitate = DehText("4. 知识入库", font_size=16, color=COL_KB).next_to(arrow_precipitate, RIGHT, buff=0.1) | |
| self.play(Create(arrow_precipitate), FadeIn(label_precipitate, shift=UP)) | |
| self.play(Flash(node_kb, color=COL_TEACHER, flash_radius=1.8, line_length=0.3)) | |
| self.wait(2) | |
| # 清屏 | |
| self.play(FadeOut(Group(*self.mobjects))) | |
| # ============================== | |
| # 场景 3:技术架构 (Tech Architecture) - 数据流增强版 | |
| # ============================== | |
| tech_title = DehText("XDAgent 底层技术架构与数据流", font_size=36, color=WHITE).to_edge(UP) | |
| self.play(Write(tech_title)) | |
| # --- 架构图组件 --- | |
| fe_title = EngText("Frontend", color=WHITE) | |
| fe_tech = DehText("Vue.js 3 + Axios", font_size=20, color=COL_TEXT_DEH) | |
| fe_group = VGroup(fe_title, fe_tech).arrange(DOWN, buff=0.2) | |
| box_frontend = SurroundingRectangle(fe_group, color=TEAL, buff=0.4, corner_radius=0.1, fill_opacity=0.1) | |
| frontend = VGroup(box_frontend, fe_group).move_to(UP * 1.5 + LEFT * 3.5) | |
| be_title = EngText("Backend", color=WHITE) | |
| be_tech = DehText("Flask + SQLAlchemy", font_size=20, color=COL_TEXT_DEH, line_spacing=0.5) | |
| be_group = VGroup(be_title, be_tech).arrange(DOWN, buff=0.2) | |
| box_backend = SurroundingRectangle(be_group, color=RED_C, buff=0.4, corner_radius=0.1, fill_opacity=0.1) | |
| backend = VGroup(box_backend, be_group).move_to(UP * 1.5 + RIGHT * 3.5) | |
| model_title = EngText("AI & Vector Engine", color=WHITE) | |
| model_tech = EngText("Qwen2.5-1.5B | BGE | FAISS", font_size=20, color=COL_TEXT_DEH) | |
| model_group = VGroup(model_title, model_tech).arrange(DOWN, buff=0.3) | |
| box_model = SurroundingRectangle(model_group, color=ORANGE, buff=0.6, corner_radius=0.2, fill_opacity=0.15) | |
| model_layer = VGroup(box_model, model_group).move_to(DOWN * 1.5) | |
| # 引入组件 | |
| self.play(FadeIn(frontend, shift=RIGHT), FadeIn(backend, shift=LEFT), run_time=1) | |
| self.play(GrowFromCenter(model_layer)) | |
| self.wait(0.5) | |
| # --- 数据流动画 --- | |
| # 1. 前后端 API 交互 | |
| line_api = DoubleArrow(box_frontend.get_right(), box_backend.get_left(), buff=0.1, color=GRAY) | |
| label_api = EngText("RESTful API", font_size=16, color=GRAY).next_to(line_api, UP, buff=0.1) | |
| self.play(GrowArrow(line_api), Write(label_api)) | |
| # 2. 模拟流式回答 (SSE) | |
| line_call = DoubleArrow(box_backend.get_bottom(), box_model.get_top(), buff=0.1, color=ORANGE) | |
| label_call = DehText("RPC 推理调用", font_size=16, color=ORANGE).next_to(line_call, RIGHT, buff=0.1) | |
| self.play(GrowArrow(line_call), Write(label_call)) | |
| # 流式回答文本框 | |
| stream_box = RoundedRectangle(corner_radius=0.1, height=1.5, width=4.5, color=COL_AI, fill_opacity=0.8).move_to(DOWN * 3.2) | |
| stream_label = DehText("SSE 实时流式响应...", font_size=14, color=WHITE).next_to(stream_box.get_corner(UL), RIGHT, buff=0.1).shift(DOWN*0.1) | |
| sim_tokens = [ | |
| '{"token": "You"}', | |
| '{"token": " are"}', | |
| '{"token": " an"}', | |
| '{"token": " XDUer."}', | |
| '[DONE]' | |
| ] | |
| self.play(FadeIn(stream_box), FadeIn(stream_label)) | |
| # 逐行打字显示流数据 | |
| stream_texts = VGroup() | |
| for i, token in enumerate(sim_tokens): | |
| t = Text(f"data: {token}", font="Consolas", font_size=14, color=GREEN_A) | |
| if i == 0: | |
| t.next_to(stream_label, DOWN, aligned_edge=LEFT, buff=0.15) | |
| else: | |
| t.next_to(stream_texts[-1], DOWN, aligned_edge=LEFT, buff=0.1) | |
| stream_texts.add(t) | |
| self.play(AddTextLetterByLetter(t), run_time=0.4) | |
| self.wait(1) | |
| self.play(FadeOut(stream_box), FadeOut(stream_label), FadeOut(stream_texts)) | |
| self.wait(1) | |
| # 整体淡出 | |
| self.play(FadeOut(Group(*self.mobjects))) | |
| # ============================== | |
| # 场景 4:结束致谢 (Outro) - 完善版 | |
| # ============================== | |
| # 1. 基础文字定义 | |
| school_cn = DehText("西安电子科技大学", font_size=48, color=WHITE).shift(UP * 1.0) # 稍微往上移一点给下方腾出空间 | |
| school_en = EngText("Xidian University", font_size=32, color=GRAY_A).next_to(school_cn, DOWN, buff=0.4) | |
| # 2. 装饰线条 | |
| line = Line(LEFT * 3.5, RIGHT * 3.5, color=COL_STUDENT, stroke_width=2).next_to(school_en, DOWN, buff=0.5) | |
| # 3. 新增:作者与指导教师信息 | |
| # 使用稍小的字号 (font_size=24) 显得更精致 | |
| authors = DehText("作者:肖宗林、姚焱夫、孟子钦", font_size=24, color=GRAY_A).next_to(line, DOWN, buff=0.6) | |
| mentor = DehText("指导教师:苗银宾", font_size=24, color=GRAY_A).next_to(authors, DOWN, buff=0.3) | |
| # 组合信息便于一起操作 | |
| info_group = VGroup(authors, mentor) | |
| # --- 动画部分 --- | |
| self.play( | |
| Write(school_cn, run_time=1.5), | |
| FadeIn(school_en, shift=UP, run_time=1.5) | |
| ) | |
| self.play(Create(line), run_time=0.8) | |
| # 让人员信息从下方轻微浮现 | |
| self.play(FadeIn(info_group, shift=UP * 0.3), run_time=1.2) | |
| # 仪式感动画:校名微动 | |
| self.play(school_cn.animate.scale(1.05), run_time=1.5) | |
| self.play(school_cn.animate.scale(1/1.05), run_time=1.5) | |
| self.wait(3) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
项目介绍视频:
default.mp4