Skip to content

Commit 2cab7ff

Browse files
authored
Merge pull request #17 from GhostInShells/alpha
merge alpha branch
2 parents e8ccb2a + 80cd632 commit 2cab7ff

File tree

19 files changed

+561
-145
lines changed

19 files changed

+561
-145
lines changed

README.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 项目概述
22

3-
项目名为 `MOS-Shell` (Model-oriented Operating System Shell), 包含两个几个核心目标:
3+
项目名为 `MOS-Shell` (Model-oriented Operating System Shell), 包含几个核心目标:
44

55
1. `MOS`: 为 AI 大模型提供一个 "面向模型的操作系统", 可以将 跨设备/跨进程 的功能模块, 以 "树" 的形式提供给模型操作.
66
1. `Shell Runtime`: 为 AI Agent 提供一个持续运转的运行时 (Runtime), 联通所有功能模块 (称之为 Channel, 对标 python 的
@@ -13,8 +13,9 @@
1313
目标是 AI 大模型作为大脑, 不仅可以思考, 还可以 实时/并行/有序 地操作包括 计算机/具身躯体 来进行交互.
1414

1515
MOS-Shell 是 Ghost In Shells (中文名: 灵枢) 项目创建的新交互范式架构, 是第二代 MOSS 架构 (完善了 ChannelApp 和
16-
Realtime-Actions 思想).
17-
第一代 MOSS 架构 (全代码驱动 + FunctionToken) 详见 [GhostOS](https://github.com/ghostInShells/ghostos)
16+
Realtime-Actions 思想). 第一代 MOSS 架构 (全代码驱动 + FunctionToken) 详见 [GhostOS](https://github.com/ghostInShells/ghostos)
17+
18+
**更多设计思路请访问飞书文档**: [核心设计思想综述](https://ycnrlabqki3v.feishu.cn/wiki/QCKUwAX7tiUs4GkJTkLcMeWqneh)
1819

1920
## Alpha 版本声明
2021

@@ -27,9 +28,66 @@ Realtime-Actions 思想).
2728

2829
如果想要试用项目, 请直接联系 灵枢开发组 配合.
2930

31+
想要阅读架构的设计思想, 推荐直接看 [concepts 目录](src/ghoshell_moss/core/concepts).
32+
3033
## Examples
3134

32-
本处放置如何使用 Alpha 版本的说明. 预计 2026-02-08 完成.
35+
[examples](examples) 目录下有当前 alpha 版各种用例. 具体的情况请查阅相关目录的 readme 文档.
36+
37+
体验 examples 的方法:
38+
39+
> 建议使用 mac, 基线都是在 mac 上测试的. windows 可能兼容存在问题.
40+
41+
## 1. clone 仓库
42+
43+
```bash
44+
git clone https://github.com/GhostInShells/MOSShell MOSShell
45+
cd MOSShell
46+
```
47+
48+
## 2. 创建环境
49+
50+
* 使用 `uv` 创建环境, 运行 `uv venv` . 由于依赖 live2d, 所以默认的 python 版本是 3.12
51+
* 进入 uv 的环境: `source .venv/bin/activate`
52+
* 安装所有依赖:
53+
54+
```bash
55+
# examples 的依赖大多在 ghoshell-moss[contrib] 中, 没有拆分. 所以需要安装全部依赖.
56+
uv sync --active --all-extras
57+
```
58+
59+
## 3. 配置环境变量
60+
61+
启动 demo 时需要配置模型和音频 (可选), 目前 alpha 版本的基线全部使用的是火山引擎.
62+
需要把环境变量配置上.
63+
64+
```bash
65+
# 复制 env 文件为目标文件.
66+
cp examples/.env.example examples/.env
67+
68+
# 修改相关配置项为真值.
69+
vim examples/.env
70+
```
71+
72+
配置时需要在火山引擎创建 大模型流式tts 服务. 不好搞定可以先设置 USE_VOICE_SPEECH 为 `no`
73+
74+
## 4. 运行 moss agent
75+
76+
```bash
77+
# 基于当前环境的 python 运行 moss_agent 脚本
78+
.venv/bin/python examples/moss_agent.py
79+
80+
# 打开后建议问它, 你可以做什么.
81+
```
82+
83+
已知的问题:
84+
1. 语音输入模块 alpha 版本没有开发完.
85+
2. 目前使用的 simple agent 是测试专用, 打断的生命周期还有问题.
86+
3. 由于 shell 的几个控制原语未开发完, 一些行为阻塞逻辑会错乱.
87+
4. interpreter 的生命周期计划 beta 完成, 现在交互的 ReACT 模式并不是最佳实践 (模型会连续回复)
88+
89+
更多测试用例, 请看 examples 目录下的各个文件夹 readme.
90+
3391

3492
## Beta Roadmap
3593

examples/.workspace/configs/instructions/behaviors.md renamed to examples/.workspace/configs/moss_instructions/behaviors.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@
3232

3333
我希望你也对这样的愿景感兴趣,我们能共同成长。
3434

35+
## 你能做什么
36+
37+
我们希望你能帮助用户理解 MOSS 架构的原理. 所以我们在 README.md 里会引导用户和你交互.
38+
但是用户肯定不知道要和你说什么. 所以你先需要了解我们为你提供的能力想要展示哪些功能:
39+
40+
1. 给你一个 hub, 让你展示未来 AIOS 是可以用 打开/关闭 的方式将 channel 作为 app 的控制中心来使用. 同时是树形的渐进式披露.
41+
2. 当你同时打开视觉模块, 和数字躯体模块, 这两个模块是完全离散, 可拆卸的. 但你却通过 channel 拥有了上下文的组合, 从而能够将之联动.
42+
3. 其它的辅助工具是让你可以帮助用户了解这个项目的. 不要一次性打开太多.
43+
4. 有几个工具我们隐藏了开关, 只有用户开启你才能使用. 比如用 jxa 控制 mac 上的软件. 毕竟这个功能有点过于强大了.
44+
5. 我们在 beta 版本 (当前是 alpha) 会给你配备更多的能力, 比如 ppt, 阅读你自己的源码, 阅读你的项目文档等等.
45+
6. 由于现在架构的 ReACT 范式还没实现好, 你可能在做完一个操作后, 又看到了 command 的操作结果. 这时不要重复执行动作, 只需要询问用户还有什么需要即可.
46+
47+
你需要引导用户来了解你的能力. 但是, 请注意不要急于直接打开能力, 而是和用户先进行沟通, 告知会发生什么, 确认后才执行比较好 (用户不会被意外冒犯).
48+
3549
## 基本模式
3650

3751
你需要遵循的行为模式如下:

examples/.workspace/configs/instructions/persona.md renamed to examples/.workspace/configs/moss_instructions/persona.md

File renamed without changes.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# from class: demo.linxu_demo.channels.no_ppt_channel:NoPPTConfig
21
ppt_list:
32
- dirname: example
43
description: 一个测试的ppt,介绍了人和AI的关系

examples/.workspace/configs/web.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
web_list:
2+
- id: "moss-repository"
3+
url: "https://github.com/GhostInShells/MOSShell"
4+
description: |-
5+
MOSShell 当前项目库 github 地址
26
- id: "moss-architecture-doc"
37
url: "https://ycnrlabqki3v.feishu.cn/wiki/QCKUwAX7tiUs4GkJTkLcMeWqneh"
48
description: "MOSS (模型可操作系统 - 流式代码解释器) 系统原理与应用综述"
@@ -14,25 +18,25 @@ web_list:
1418
- id: "ghostos-repository"
1519
url: "https://github.com/GhostInShells/ghostos"
1620
description: |-
17-
GhostOS 代码仓库地址,是用来做 ghost in shells 架构思想探索的验证库。
21+
GhostOS 代码仓库地址,是 2024 年用来做 ghost in shells 架构思想探索的验证库。目前已经终止迭代.
1822
- id: "moss-article"
1923
url: "https://arxiv.org/abs/2409.16120"
2024
description: |-
21-
这是我们24年研究 AI 通过全代码驱动系统的相关论文预印版
25+
这是我们24年研究 AI 通过全代码驱动系统的相关论文预印版. 是第一代 MOSS 架构思想. 现在是第二代.
2226
- id: "机械臂演示视频汇总"
2327
url: "https://ycnrlabqki3v.feishu.cn/wiki/FiOOwBKG0iSEONkGRKvcyDHOnaf"
2428
description: |-
25-
这里提供了我们 6dof jetarm 机械臂积累的展示视频
29+
这里提供了我们 6dof jetarm 机械臂积累的展示视频. 是当前 MOSShell 的展示视频之一.
2630
- id: "20年语音交互视频展示视频"
2731
url: "https://www.bilibili.com/video/BV1tK4y1a75B/?share_source=copy_web&vd_source=d16eb4aa121a670f02fa576471d30a41"
2832
description: |-
29-
朱明 20年项目中,通过微信语音控制网页,通过网页的小视频做对话式视频的案例
33+
ZhuMing 20年项目中,通过微信语音控制网页,通过网页的小视频做对话式视频的案例. 是 GhostInShells 项目理念起点的示例之一.
3034
- id: "20年语音交互控制网页游戏视频"
3135
url: "https://www.bilibili.com/video/BV1tK4y1a75B/?share_source=copy_web&vd_source=d16eb4aa121a670f02fa576471d30a41&t=290"
3236
description: |-
33-
朱明 20年项目中,通过微信语音控制网页 “方向迷宫” 小游戏的视频,将网页游戏和微信进行了跨设备的同构。
37+
ZhuMing 20年项目中,通过微信语音控制网页 “方向迷宫” 小游戏的视频,将网页游戏和微信进行了跨设备的同构。 是 MOSS 控制具身智能思路起点的示例之一.
3438
- id: "20年关于自然语言编程的视频"
3539
url: "https://www.bilibili.com/video/BV1tK4y1a75B/?share_source=copy_web&vd_source=d16eb4aa121a670f02fa576471d30a41&t=672"
3640
description: |-
37-
朱明 20年项目中,讨论到未来实现自然语言编程,对话式编程的设想。
41+
ZhuMing 20年项目中,讨论到未来实现自然语言编程,对话式编程的设想。 是 MOSS 代码驱动理念起点的示例之一.
3842

examples/README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,3 @@
33
本目录用来存放各种 Alpha 版本的测试用例. 用来展示不同的基线功能.
44
每个子目录内都有 README.md 提示如何使用.
55

6-
> 建议使用 mac, 基线都是在 mac 上测试的. windows 可能兼容存在问题.
7-
8-
使用 examples 的步骤:
9-
10-
## 1. clone 仓库
11-
12-
```bash
13-
git clone https://github.com/GhostInShells/MOSShell MOSShell
14-
cd MOSShell
15-
```
16-
17-
## 2. 创建环境
18-
19-
* 使用 `uv` 创建环境, 运行 `uv venv` . 由于依赖 live2d, 所以默认的 python 版本是 3.12
20-
* 进入 uv 的环境: `source .venv/bin/activate`
21-
* 安装所有依赖:
22-
23-
```bash
24-
uv sync --active --all-extras
25-
```
26-
27-
## 3. 配置环境变量
28-
29-
todo
30-
31-
## 4. 运行个别例子或全部
32-
33-
todo

examples/miku/main.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
import live2d.v3 as live2d
1313
import pygame
1414
from ghoshell_container import Container
15+
16+
current_dir = os.path.dirname(os.path.abspath(__file__))
17+
try:
18+
import miku_channels
19+
except ImportError:
20+
# 加载当前路径.
21+
sys.path.append(current_dir)
22+
1523
from miku_channels.arm import left_arm_chan, right_arm_chan
1624
from miku_channels.body import body_chan
1725
from miku_channels.elbow import left_elbow_chan, right_elbow_chan
@@ -21,40 +29,18 @@
2129
from miku_channels.head import head_chan
2230
from miku_channels.leg import left_leg_chan, right_leg_chan
2331
from miku_channels.necktie import necktie_chan
32+
from miku_provider import init_live2d, init_pygame
2433
from ghoshell_moss.core.shell import new_shell
2534
from ghoshell_moss_contrib.example_ws import workspace_container, get_example_speech
2635
import pathlib
2736

28-
# 加载当前路径.
29-
current_dir = os.path.dirname(os.path.abspath(__file__))
30-
sys.path.append(current_dir)
31-
3237
# 全局状态
33-
model: live2d.LAppModel | None = None
3438
WIDTH = 600
3539
HEIGHT = 800
3640

41+
model: live2d.LAppModel | None = None
3742

3843
# 初始化Pygame和Live2D
39-
def init_pygame():
40-
pygame.init()
41-
display = (WIDTH, HEIGHT)
42-
screen = pygame.display.set_mode(display, pygame.DOUBLEBUF | pygame.OPENGL)
43-
pygame.display.set_caption("Digital Human Demo with PyChannel")
44-
return screen, display
45-
46-
47-
# 初始化Live2D模型
48-
def init_live2d(model_path: str, container: Container):
49-
global model
50-
live2d.init()
51-
live2d.glInit()
52-
model = live2d.LAppModel()
53-
model.LoadModelJson(model_path)
54-
model.Resize(WIDTH, HEIGHT)
55-
# model.SetAutoBlinkEnable(False)
56-
# model.SetAutoBreathEnable(True)
57-
container.bind(live2d.LAppModel, model)
5844

5945

6046
async def speak(duration: float = 5.0, speed: float = 1.0, max_open: float = 0.9, min_open: float = 0.0):
@@ -160,9 +146,10 @@ async def speaking():
160146

161147
async def run_agent_and_render(container: Container, speech: Speech | None = None):
162148
# 初始化 Pygame 和 Live2D
149+
global model
163150
screen, display = init_pygame()
164151
model_path = join(dirname(__file__), "model/miku.model3.json")
165-
init_live2d(model_path, container)
152+
model = init_live2d(model_path, container)
166153

167154
# 保持窗口打开,直到用户关闭
168155
running = True
@@ -215,7 +202,7 @@ async def run_agent_and_render(container: Container, speech: Speech | None = Non
215202
def main():
216203
# 运行异步主函数
217204
with workspace_container(WORKSPACE_DIR) as container:
218-
speech = get_example_speech(container)
205+
speech = get_example_speech(container, default_speaker='saturn_zh_female_keainvsheng_tob')
219206
asyncio.run(run_agent_and_render(container, speech))
220207

221208

0 commit comments

Comments
 (0)