neuro-simulator 0.1.3__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neuro_simulator/__init__.py +1 -10
- neuro_simulator/agent/__init__.py +1 -8
- neuro_simulator/agent/base.py +43 -0
- neuro_simulator/agent/core.py +105 -398
- neuro_simulator/agent/factory.py +30 -0
- neuro_simulator/agent/llm.py +34 -31
- neuro_simulator/agent/memory/__init__.py +1 -4
- neuro_simulator/agent/memory/manager.py +61 -203
- neuro_simulator/agent/tools/__init__.py +1 -4
- neuro_simulator/agent/tools/core.py +8 -18
- neuro_simulator/api/__init__.py +1 -0
- neuro_simulator/api/agent.py +163 -0
- neuro_simulator/api/stream.py +55 -0
- neuro_simulator/api/system.py +90 -0
- neuro_simulator/cli.py +60 -143
- neuro_simulator/core/__init__.py +1 -0
- neuro_simulator/core/agent_factory.py +52 -0
- neuro_simulator/core/agent_interface.py +91 -0
- neuro_simulator/core/application.py +278 -0
- neuro_simulator/services/__init__.py +1 -0
- neuro_simulator/{chatbot.py → services/audience.py} +24 -24
- neuro_simulator/{audio_synthesis.py → services/audio.py} +18 -15
- neuro_simulator/services/builtin.py +87 -0
- neuro_simulator/services/letta.py +206 -0
- neuro_simulator/{stream_manager.py → services/stream.py} +39 -47
- neuro_simulator/utils/__init__.py +1 -0
- neuro_simulator/utils/logging.py +90 -0
- neuro_simulator/utils/process.py +67 -0
- neuro_simulator/{stream_chat.py → utils/queue.py} +17 -4
- neuro_simulator/utils/state.py +14 -0
- neuro_simulator/{websocket_manager.py → utils/websocket.py} +18 -14
- {neuro_simulator-0.1.3.dist-info → neuro_simulator-0.2.1.dist-info}/METADATA +83 -33
- neuro_simulator-0.2.1.dist-info/RECORD +37 -0
- neuro_simulator/agent/api.py +0 -737
- neuro_simulator/agent/memory.py +0 -137
- neuro_simulator/agent/tools.py +0 -69
- neuro_simulator/builtin_agent.py +0 -83
- neuro_simulator/config.yaml.example +0 -157
- neuro_simulator/letta.py +0 -164
- neuro_simulator/log_handler.py +0 -43
- neuro_simulator/main.py +0 -673
- neuro_simulator/media/neuro_start.mp4 +0 -0
- neuro_simulator/process_manager.py +0 -70
- neuro_simulator/shared_state.py +0 -11
- neuro_simulator-0.1.3.dist-info/RECORD +0 -31
- /neuro_simulator/{config.py → core/config.py} +0 -0
- {neuro_simulator-0.1.3.dist-info → neuro_simulator-0.2.1.dist-info}/WHEEL +0 -0
- {neuro_simulator-0.1.3.dist-info → neuro_simulator-0.2.1.dist-info}/entry_points.txt +0 -0
- {neuro_simulator-0.1.3.dist-info → neuro_simulator-0.2.1.dist-info}/top_level.txt +0 -0
@@ -1,70 +0,0 @@
|
|
1
|
-
# backend/process_manager.py
|
2
|
-
import asyncio
|
3
|
-
|
4
|
-
class ProcessManager:
|
5
|
-
"""管理后台核心直播任务的生命周期。"""
|
6
|
-
|
7
|
-
def __init__(self):
|
8
|
-
self._tasks: list[asyncio.Task] = []
|
9
|
-
self._is_running = False
|
10
|
-
print("ProcessManager initialized.")
|
11
|
-
|
12
|
-
@property
|
13
|
-
def is_running(self) -> bool:
|
14
|
-
"""返回直播核心进程是否正在运行。"""
|
15
|
-
return self._is_running
|
16
|
-
|
17
|
-
def start_live_processes(self):
|
18
|
-
"""
|
19
|
-
启动所有与直播相关的后台任务。
|
20
|
-
这个方法会动态地从 main.py 导入任务函数,以避免循环导入。
|
21
|
-
"""
|
22
|
-
if self.is_running:
|
23
|
-
print("警告: 直播进程已在运行,无法重复启动。")
|
24
|
-
return
|
25
|
-
|
26
|
-
print("正在启动直播核心进程...")
|
27
|
-
from .main import generate_audience_chat_task, neuro_response_cycle, broadcast_events_task
|
28
|
-
from .stream_manager import live_stream_manager
|
29
|
-
from .stream_chat import clear_all_queues
|
30
|
-
|
31
|
-
# Initialize Agent and reset memory
|
32
|
-
from .letta import reset_neuro_agent_memory, initialize_agent
|
33
|
-
import asyncio
|
34
|
-
asyncio.create_task(initialize_agent())
|
35
|
-
|
36
|
-
# 清理状态和队列,开始新的直播周期
|
37
|
-
clear_all_queues()
|
38
|
-
live_stream_manager.reset_stream_state()
|
39
|
-
|
40
|
-
# 创建并存储任务
|
41
|
-
self._tasks.append(asyncio.create_task(live_stream_manager.start_new_stream_cycle()))
|
42
|
-
self._tasks.append(asyncio.create_task(broadcast_events_task()))
|
43
|
-
self._tasks.append(asyncio.create_task(generate_audience_chat_task()))
|
44
|
-
self._tasks.append(asyncio.create_task(neuro_response_cycle()))
|
45
|
-
|
46
|
-
self._is_running = True
|
47
|
-
print(f"直播核心进程已启动,共 {len(self._tasks)} 个任务。")
|
48
|
-
|
49
|
-
def stop_live_processes(self):
|
50
|
-
"""停止并清理所有后台任务。"""
|
51
|
-
if not self.is_running:
|
52
|
-
print("信息: 直播进程未运行,无需停止。")
|
53
|
-
return
|
54
|
-
|
55
|
-
print(f"正在停止 {len(self._tasks)} 个直播核心任务...")
|
56
|
-
for task in self._tasks:
|
57
|
-
if not task.done():
|
58
|
-
task.cancel()
|
59
|
-
|
60
|
-
self._tasks.clear()
|
61
|
-
self._is_running = False
|
62
|
-
|
63
|
-
# 停止后,也重置一下 stream manager 的状态
|
64
|
-
from .stream_manager import live_stream_manager
|
65
|
-
live_stream_manager.reset_stream_state()
|
66
|
-
|
67
|
-
print("所有直播核心任务已停止。")
|
68
|
-
|
69
|
-
# 创建一个全局单例
|
70
|
-
process_manager = ProcessManager()
|
neuro_simulator/shared_state.py
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# backend/shared_state.py
|
2
|
-
import asyncio
|
3
|
-
|
4
|
-
# 用来同步直播进入 LIVE 阶段的信号
|
5
|
-
live_phase_started_event = asyncio.Event()
|
6
|
-
|
7
|
-
# --- 用于在任务间共享 Neuro 的最新发言 ---
|
8
|
-
# 使用一个锁来确保在读写时不会发生冲突
|
9
|
-
neuro_last_speech_lock = asyncio.Lock()
|
10
|
-
# 存储 Neuro 最新一次完整发言的文本,并提供一个初始值
|
11
|
-
neuro_last_speech: str = "Neuro-Sama has just started the stream and hasn't said anything yet."
|
@@ -1,31 +0,0 @@
|
|
1
|
-
neuro_simulator/__init__.py,sha256=PpTff-dZfzIweg_Ld0Zt8JNAMTtvLtGn_OC0Ms2E2Q8,276
|
2
|
-
neuro_simulator/audio_synthesis.py,sha256=fwS0car42-aheCFVQDgRpUTnqLv4DU9Re66PCa6zTBM,2938
|
3
|
-
neuro_simulator/builtin_agent.py,sha256=0TrAmIIjg7aCXiZxgXggyBvBSGR-CsVFUcot71NNfck,2751
|
4
|
-
neuro_simulator/chatbot.py,sha256=qQamPO5QTPwV1avNXrzjZpiJlWN3X_6vxSZPSA17jb0,5152
|
5
|
-
neuro_simulator/cli.py,sha256=rlwUW1ol8_G06OLf0G-ae0WRXofjoTt3eO9l_Ea8XCY,8183
|
6
|
-
neuro_simulator/config.py,sha256=brA8kiekV_995mpz04JiGj1swIWbZZuWWLNYtbroMyE,14884
|
7
|
-
neuro_simulator/config.yaml.example,sha256=RbSHEAFD9NEuIvgl5Smpasfz4jiZYQgzTovL3MrhhIs,6549
|
8
|
-
neuro_simulator/letta.py,sha256=q7ME_idhW6-koOpFfdNZ1-wwr3DEFIyk1hSFKVci24s,7568
|
9
|
-
neuro_simulator/log_handler.py,sha256=w8nQ-91CgiZNI94vJA9Ezgt-x5LRL_AbFZ4-0Mc6ekE,1756
|
10
|
-
neuro_simulator/main.py,sha256=d8kgo3Bc0q7pXzw6mmDXHOBaZ93JLs2Ov-cNJVuT_ps,28820
|
11
|
-
neuro_simulator/process_manager.py,sha256=cQ7XqHz0cbuJQ_ju0PoOxZzzS04ADQVARyKRHIN1bN8,2578
|
12
|
-
neuro_simulator/shared_state.py,sha256=cvYg8vGrkuDmb0e-4J1xvIjXVwspRisuxQaIR9YgsyQ,459
|
13
|
-
neuro_simulator/stream_chat.py,sha256=X655rrOW8oQ77qAFK-dQDhHT3bYiE9w44a9Na_ikM2w,997
|
14
|
-
neuro_simulator/stream_manager.py,sha256=bwY7Dxo_HLPmQw-1IFvptHBZPMeBbBxdw8_oyZHOSkQ,6966
|
15
|
-
neuro_simulator/websocket_manager.py,sha256=a9mMAN7xmgK2w9tVDOOzy4DuWSwdAPatSp6bW9fhE3I,2183
|
16
|
-
neuro_simulator/agent/__init__.py,sha256=H6eIGBRG5y1FdjUw3BcwP1nWzmMEpIE1XG2xMV_e5Y0,113
|
17
|
-
neuro_simulator/agent/api.py,sha256=Oy4xy32B9dPzBeGyjKtw89tAPjKDKnye9fUaGVsHu-s,33483
|
18
|
-
neuro_simulator/agent/core.py,sha256=htDIGW2VarLeGLfGV1NkYgo-vT27Unx579LtU3Z3_Cw,22816
|
19
|
-
neuro_simulator/agent/llm.py,sha256=ohINZpP6ybRWfxK89XMM1yYXehKvRVBuy14ksoqrm8I,4125
|
20
|
-
neuro_simulator/agent/memory.py,sha256=b41THZj0LCHlW4GApF02NoW1n1WanySLsNl6JMGpYDQ,5416
|
21
|
-
neuro_simulator/agent/tools.py,sha256=hwdJ99soOSOFOqfkBl0oGMYVe4U5rfh1HsGkXd3EUFc,2801
|
22
|
-
neuro_simulator/agent/memory/__init__.py,sha256=Be08Az0lWn9d51TLfE2UoluIT9yXVfzHPekIjxJnGOU,78
|
23
|
-
neuro_simulator/agent/memory/manager.py,sha256=Xr0zdb1iyWy-zp2_c1sGjivZ4TyhfvykikA_Ks6ei2c,15035
|
24
|
-
neuro_simulator/agent/tools/__init__.py,sha256=8ztH_OkeXaQDxOaKBb78vKIA8IKkRLxyHLnwGtdk9YU,76
|
25
|
-
neuro_simulator/agent/tools/core.py,sha256=YsXbwjF5be_yrh0w5goaSWux53LOkLJ91rikgWPUKDQ,5974
|
26
|
-
neuro_simulator/media/neuro_start.mp4,sha256=xCLnNzv4THnzRYwkdV6EiqXc-XtFd867R2ZVLDvNp0Y,8226418
|
27
|
-
neuro_simulator-0.1.3.dist-info/METADATA,sha256=gkkNB968MDpAKLIauIuyH5JuMuwd-dUIQuY8WEC-U44,6366
|
28
|
-
neuro_simulator-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
29
|
-
neuro_simulator-0.1.3.dist-info/entry_points.txt,sha256=qVd5ypnRRgU8Cw7rWfZ7o0OXyS9P9hgY-cRoN_mgz9g,51
|
30
|
-
neuro_simulator-0.1.3.dist-info/top_level.txt,sha256=V8awSKpcrFnjJDiJxSfy7jtOrnuE2BgAR9hLmfMDWK8,16
|
31
|
-
neuro_simulator-0.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|