neuro-simulator 0.3.2__py3-none-any.whl → 0.4.0__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/agent/core.py +103 -136
- neuro_simulator/agent/llm.py +1 -1
- neuro_simulator/agent/memory/manager.py +24 -103
- neuro_simulator/agent/memory_prompt.txt +14 -0
- neuro_simulator/agent/neuro_prompt.txt +32 -0
- neuro_simulator/agent/tools/add_temp_memory.py +61 -0
- neuro_simulator/agent/tools/add_to_core_memory_block.py +64 -0
- neuro_simulator/agent/tools/base.py +56 -0
- neuro_simulator/agent/tools/create_core_memory_block.py +78 -0
- neuro_simulator/agent/tools/delete_core_memory_block.py +44 -0
- neuro_simulator/agent/tools/get_core_memory_block.py +44 -0
- neuro_simulator/agent/tools/get_core_memory_blocks.py +30 -0
- neuro_simulator/agent/tools/manager.py +143 -0
- neuro_simulator/agent/tools/remove_from_core_memory_block.py +65 -0
- neuro_simulator/agent/tools/speak.py +56 -0
- neuro_simulator/agent/tools/update_core_memory_block.py +65 -0
- neuro_simulator/api/system.py +5 -2
- neuro_simulator/cli.py +83 -53
- neuro_simulator/core/agent_factory.py +0 -1
- neuro_simulator/core/application.py +72 -43
- neuro_simulator/core/config.py +66 -63
- neuro_simulator/core/path_manager.py +69 -0
- neuro_simulator/services/audience.py +0 -2
- neuro_simulator/services/audio.py +0 -1
- neuro_simulator/services/builtin.py +10 -25
- neuro_simulator/services/letta.py +19 -1
- neuro_simulator/services/stream.py +24 -21
- neuro_simulator/utils/logging.py +9 -0
- neuro_simulator/utils/queue.py +27 -4
- neuro_simulator/utils/websocket.py +1 -3
- {neuro_simulator-0.3.2.dist-info → neuro_simulator-0.4.0.dist-info}/METADATA +1 -1
- neuro_simulator-0.4.0.dist-info/RECORD +46 -0
- neuro_simulator/agent/base.py +0 -43
- neuro_simulator/agent/factory.py +0 -30
- neuro_simulator/agent/tools/core.py +0 -102
- neuro_simulator/api/stream.py +0 -1
- neuro_simulator-0.3.2.dist-info/RECORD +0 -36
- {neuro_simulator-0.3.2.dist-info → neuro_simulator-0.4.0.dist-info}/WHEEL +0 -0
- {neuro_simulator-0.3.2.dist-info → neuro_simulator-0.4.0.dist-info}/entry_points.txt +0 -0
- {neuro_simulator-0.3.2.dist-info → neuro_simulator-0.4.0.dist-info}/top_level.txt +0 -0
@@ -1,27 +1,24 @@
|
|
1
1
|
# neuro_simulator/services/builtin.py
|
2
2
|
"""Builtin agent module for Neuro Simulator"""
|
3
3
|
|
4
|
-
import asyncio
|
5
|
-
import re
|
6
4
|
import logging
|
7
5
|
from typing import List, Dict, Any, Optional
|
8
6
|
|
9
7
|
from ..core.agent_interface import BaseAgent
|
10
8
|
from ..agent.core import Agent as LocalAgent
|
11
|
-
from ..
|
9
|
+
from ..utils.websocket import connection_manager
|
12
10
|
|
13
11
|
logger = logging.getLogger(__name__.replace("neuro_simulator", "server", 1))
|
14
12
|
|
15
13
|
async def initialize_builtin_agent() -> Optional[LocalAgent]:
|
16
|
-
"""Initializes
|
14
|
+
"""Initializes a new builtin agent instance and returns it."""
|
17
15
|
try:
|
18
|
-
|
19
|
-
agent_instance = LocalAgent(working_dir=working_dir)
|
16
|
+
agent_instance = LocalAgent()
|
20
17
|
await agent_instance.initialize()
|
21
|
-
logger.info("
|
18
|
+
logger.info("New builtin agent instance initialized successfully.")
|
22
19
|
return agent_instance
|
23
20
|
except Exception as e:
|
24
|
-
logger.error(f"Failed to initialize local agent
|
21
|
+
logger.error(f"Failed to initialize local agent instance: {e}", exc_info=True)
|
25
22
|
return None
|
26
23
|
|
27
24
|
class BuiltinAgentWrapper(BaseAgent):
|
@@ -50,24 +47,18 @@ class BuiltinAgentWrapper(BaseAgent):
|
|
50
47
|
|
51
48
|
async def create_memory_block(self, title: str, description: str, content: List[str]) -> Dict[str, str]:
|
52
49
|
block_id = await self.agent_instance.memory_manager.create_core_memory_block(title, description, content)
|
53
|
-
# Broadcast core_memory_updated event
|
54
50
|
updated_blocks = await self.get_memory_blocks()
|
55
|
-
from ..utils.websocket import connection_manager
|
56
51
|
await connection_manager.broadcast_to_admins({"type": "core_memory_updated", "payload": updated_blocks})
|
57
52
|
return {"block_id": block_id}
|
58
53
|
|
59
54
|
async def update_memory_block(self, block_id: str, title: Optional[str], description: Optional[str], content: Optional[List[str]]):
|
60
55
|
await self.agent_instance.memory_manager.update_core_memory_block(block_id, title, description, content)
|
61
|
-
# Broadcast core_memory_updated event
|
62
56
|
updated_blocks = await self.get_memory_blocks()
|
63
|
-
from ..utils.websocket import connection_manager
|
64
57
|
await connection_manager.broadcast_to_admins({"type": "core_memory_updated", "payload": updated_blocks})
|
65
58
|
|
66
59
|
async def delete_memory_block(self, block_id: str):
|
67
60
|
await self.agent_instance.memory_manager.delete_core_memory_block(block_id)
|
68
|
-
# Broadcast core_memory_updated event
|
69
61
|
updated_blocks = await self.get_memory_blocks()
|
70
|
-
from ..utils.websocket import connection_manager
|
71
62
|
await connection_manager.broadcast_to_admins({"type": "core_memory_updated", "payload": updated_blocks})
|
72
63
|
|
73
64
|
# Init Memory Management
|
@@ -76,9 +67,7 @@ class BuiltinAgentWrapper(BaseAgent):
|
|
76
67
|
|
77
68
|
async def update_init_memory(self, memory: Dict[str, Any]):
|
78
69
|
await self.agent_instance.memory_manager.update_init_memory(memory)
|
79
|
-
# Broadcast init_memory_updated event
|
80
70
|
updated_init_mem = await self.get_init_memory()
|
81
|
-
from ..utils.websocket import connection_manager
|
82
71
|
await connection_manager.broadcast_to_admins({"type": "init_memory_updated", "payload": updated_init_mem})
|
83
72
|
|
84
73
|
# Temp Memory Management
|
@@ -87,31 +76,27 @@ class BuiltinAgentWrapper(BaseAgent):
|
|
87
76
|
|
88
77
|
async def add_temp_memory(self, content: str, role: str):
|
89
78
|
await self.agent_instance.memory_manager.add_temp_memory(content, role)
|
90
|
-
# Broadcast temp_memory_updated event
|
91
79
|
updated_temp_mem = await self.get_temp_memory()
|
92
|
-
from ..utils.websocket import connection_manager
|
93
80
|
await connection_manager.broadcast_to_admins({"type": "temp_memory_updated", "payload": updated_temp_mem})
|
94
81
|
|
95
82
|
async def clear_temp_memory(self):
|
96
83
|
await self.agent_instance.memory_manager.reset_temp_memory()
|
97
|
-
# Broadcast temp_memory_updated event
|
98
84
|
updated_temp_mem = await self.get_temp_memory()
|
99
|
-
from ..utils.websocket import connection_manager
|
100
85
|
await connection_manager.broadcast_to_admins({"type": "temp_memory_updated", "payload": updated_temp_mem})
|
101
86
|
|
102
87
|
# Tool Management
|
103
88
|
async def get_available_tools(self) -> str:
|
104
|
-
|
89
|
+
# This method is now for internal use, the dashboard uses the new API
|
90
|
+
schemas = self.agent_instance.tool_manager.get_tool_schemas_for_agent('neuro_agent')
|
91
|
+
return self.agent_instance._format_tool_schemas_for_prompt(schemas)
|
105
92
|
|
106
93
|
async def execute_tool(self, tool_name: str, params: Dict[str, Any]) -> Any:
|
107
|
-
result = await self.agent_instance.execute_tool(tool_name, params)
|
108
|
-
# If the tool was add_temp_memory, broadcast temp_memory_updated event
|
94
|
+
result = await self.agent_instance.tool_manager.execute_tool(tool_name, **params)
|
109
95
|
if tool_name == "add_temp_memory":
|
110
96
|
updated_temp_mem = await self.get_temp_memory()
|
111
|
-
from ..utils.websocket import connection_manager
|
112
97
|
await connection_manager.broadcast_to_admins({"type": "temp_memory_updated", "payload": updated_temp_mem})
|
113
98
|
return result
|
114
99
|
|
115
100
|
# Context/Message History
|
116
101
|
async def get_message_history(self, limit: int = 20) -> List[Dict[str, Any]]:
|
117
|
-
return await self.agent_instance.
|
102
|
+
return await self.agent_instance.get_neuro_history(limit)
|
@@ -67,11 +67,29 @@ class LettaAgent(BaseAgent):
|
|
67
67
|
raise ValueError("Letta agent ID (neuro_agent_id) is not configured.")
|
68
68
|
|
69
69
|
async def reset_memory(self):
|
70
|
+
"""Resets message history and clears the conversation_summary block."""
|
70
71
|
try:
|
72
|
+
# Reset message history
|
71
73
|
await asyncio.to_thread(self.client.agents.messages.reset, agent_id=self.agent_id)
|
72
74
|
logger.info(f"Letta Agent (ID: {self.agent_id}) message history has been reset.")
|
75
|
+
|
76
|
+
# Find and clear the conversation_summary block
|
77
|
+
blocks = await asyncio.to_thread(self.client.agents.blocks.list, agent_id=self.agent_id)
|
78
|
+
summary_block = next((block for block in blocks if block.name == "conversation_summary"), None)
|
79
|
+
|
80
|
+
if summary_block:
|
81
|
+
await asyncio.to_thread(
|
82
|
+
self.client.agents.blocks.modify,
|
83
|
+
agent_id=self.agent_id,
|
84
|
+
block_id=summary_block.id,
|
85
|
+
content=""
|
86
|
+
)
|
87
|
+
logger.info(f"Cleared content of 'conversation_summary' block (ID: {summary_block.id}) for Letta Agent.")
|
88
|
+
else:
|
89
|
+
logger.warning("'conversation_summary' block not found for Letta Agent, skipping clearing.")
|
90
|
+
|
73
91
|
except Exception as e:
|
74
|
-
logger.warning(f"Failed
|
92
|
+
logger.warning(f"Failed during Letta Agent memory reset: {e}")
|
75
93
|
|
76
94
|
async def process_messages(self, messages: List[Dict[str, str]]) -> Dict[str, Any]:
|
77
95
|
# Check if this is a superchat message based on the specific structure
|
@@ -11,6 +11,28 @@ from ..utils.state import app_state
|
|
11
11
|
|
12
12
|
logger = logging.getLogger(__name__.replace("neuro_simulator", "server", 1))
|
13
13
|
|
14
|
+
_WORKING_DIR = os.getcwd()
|
15
|
+
_WELCOME_VIDEO_PATH_BACKEND = os.path.join(_WORKING_DIR, "assets", "neuro_start.mp4")
|
16
|
+
_WELCOME_VIDEO_DURATION_SEC_DEFAULT = 10.0
|
17
|
+
|
18
|
+
@staticmethod
|
19
|
+
def _get_video_duration(video_path: str) -> float:
|
20
|
+
"""Gets the duration of an MP4 video file using mutagen."""
|
21
|
+
if not os.path.exists(video_path):
|
22
|
+
logger.warning(f"Video file '{video_path}' not found. Using default duration.")
|
23
|
+
return _WELCOME_VIDEO_DURATION_SEC_DEFAULT
|
24
|
+
try:
|
25
|
+
video = MP4(video_path)
|
26
|
+
duration = video.info.length
|
27
|
+
logger.info(f"Successfully read video duration for '{video_path}': {duration:.2f}s.")
|
28
|
+
return duration
|
29
|
+
except MP4StreamInfoError:
|
30
|
+
logger.warning(f"Could not parse stream info for '{video_path}'. Using default duration.")
|
31
|
+
return _WELCOME_VIDEO_DURATION_SEC_DEFAULT
|
32
|
+
except Exception as e:
|
33
|
+
logger.error(f"Error getting video duration: {e}. Using default duration.")
|
34
|
+
return _WELCOME_VIDEO_DURATION_SEC_DEFAULT
|
35
|
+
|
14
36
|
class LiveStreamManager:
|
15
37
|
class NeuroAvatarStage:
|
16
38
|
HIDDEN = "hidden"
|
@@ -25,28 +47,9 @@ class LiveStreamManager:
|
|
25
47
|
|
26
48
|
event_queue: asyncio.Queue = asyncio.Queue()
|
27
49
|
|
28
|
-
|
29
|
-
_WELCOME_VIDEO_PATH_BACKEND = os.path.join(
|
50
|
+
_WORKING_DIR = os.getcwd()
|
51
|
+
_WELCOME_VIDEO_PATH_BACKEND = os.path.join(_WORKING_DIR, "assets", "neuro_start.mp4")
|
30
52
|
_WELCOME_VIDEO_DURATION_SEC_DEFAULT = 10.0
|
31
|
-
|
32
|
-
@staticmethod
|
33
|
-
def _get_video_duration(video_path: str) -> float:
|
34
|
-
"""Gets the duration of an MP4 video file using mutagen."""
|
35
|
-
if not os.path.exists(video_path):
|
36
|
-
logger.warning(f"Video file '{video_path}' not found. Using default duration.")
|
37
|
-
return LiveStreamManager._WELCOME_VIDEO_DURATION_SEC_DEFAULT
|
38
|
-
try:
|
39
|
-
video = MP4(video_path)
|
40
|
-
duration = video.info.length
|
41
|
-
logger.info(f"Successfully read video duration for '{video_path}': {duration:.2f}s.")
|
42
|
-
return duration
|
43
|
-
except MP4StreamInfoError:
|
44
|
-
logger.warning(f"Could not parse stream info for '{video_path}'. Using default duration.")
|
45
|
-
return LiveStreamManager._WELCOME_VIDEO_DURATION_SEC_DEFAULT
|
46
|
-
except Exception as e:
|
47
|
-
logger.error(f"Error getting video duration: {e}. Using default duration.")
|
48
|
-
return LiveStreamManager._WELCOME_VIDEO_DURATION_SEC_DEFAULT
|
49
|
-
|
50
53
|
_WELCOME_VIDEO_DURATION_SEC = _get_video_duration(_WELCOME_VIDEO_PATH_BACKEND)
|
51
54
|
AVATAR_INTRO_TOTAL_DURATION_SEC = 3.0
|
52
55
|
|
neuro_simulator/utils/logging.py
CHANGED
@@ -87,4 +87,13 @@ def configure_server_logging():
|
|
87
87
|
uvicorn_logger.handlers = [server_queue_handler, console_handler]
|
88
88
|
uvicorn_logger.propagate = False # Prevent double-logging
|
89
89
|
|
90
|
+
# Configure the neuro_agent logger
|
91
|
+
neuro_agent_logger = logging.getLogger("neuro_agent")
|
92
|
+
neuro_agent_queue_handler = QueueLogHandler(agent_log_queue)
|
93
|
+
neuro_agent_queue_handler.setFormatter(queue_formatter)
|
94
|
+
neuro_agent_logger.addHandler(neuro_agent_queue_handler)
|
95
|
+
neuro_agent_logger.addHandler(console_handler) # Also send agent logs to console
|
96
|
+
neuro_agent_logger.setLevel(logging.INFO)
|
97
|
+
neuro_agent_logger.propagate = False # Prevent double-logging
|
98
|
+
|
90
99
|
root_logger.info("Server logging configured with unified formatting for queue and console.")
|
neuro_simulator/utils/queue.py
CHANGED
@@ -3,16 +3,39 @@
|
|
3
3
|
|
4
4
|
import logging
|
5
5
|
from collections import deque
|
6
|
-
from pathlib import Path
|
7
6
|
|
8
7
|
from ..core.config import config_manager
|
9
8
|
from ..utils.state import app_state
|
10
9
|
|
11
10
|
logger = logging.getLogger(__name__.replace("neuro_simulator", "server", 1))
|
12
11
|
|
13
|
-
#
|
14
|
-
audience_chat_buffer: deque[dict] = deque(
|
15
|
-
neuro_input_queue: deque[dict] = deque(
|
12
|
+
# Deques for chat messages
|
13
|
+
audience_chat_buffer: deque[dict] = deque()
|
14
|
+
neuro_input_queue: deque[dict] = deque()
|
15
|
+
|
16
|
+
def initialize_queues():
|
17
|
+
"""
|
18
|
+
Initializes the chat queues with sizes from the loaded configuration.
|
19
|
+
This must be called after the config is loaded.
|
20
|
+
"""
|
21
|
+
global audience_chat_buffer, neuro_input_queue
|
22
|
+
|
23
|
+
settings = config_manager.settings
|
24
|
+
if not settings:
|
25
|
+
logger.error("Queue initialization failed: Config not loaded.")
|
26
|
+
return
|
27
|
+
|
28
|
+
logger.info("Initializing queues with configured sizes.")
|
29
|
+
|
30
|
+
# Re-initialize the deques with the correct maxlen
|
31
|
+
audience_chat_buffer = deque(
|
32
|
+
audience_chat_buffer,
|
33
|
+
maxlen=settings.performance.audience_chat_buffer_max_size
|
34
|
+
)
|
35
|
+
neuro_input_queue = deque(
|
36
|
+
neuro_input_queue,
|
37
|
+
maxlen=settings.performance.neuro_input_queue_max_size
|
38
|
+
)
|
16
39
|
|
17
40
|
def clear_all_queues():
|
18
41
|
"""Clears all chat queues."""
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# neuro_simulator/utils/websocket.py
|
2
|
-
import asyncio
|
3
2
|
import json
|
4
3
|
import logging
|
5
|
-
from collections import deque
|
6
4
|
|
7
5
|
from fastapi import WebSocket
|
8
6
|
from starlette.websockets import WebSocketState
|
@@ -39,7 +37,7 @@ class WebSocketManager:
|
|
39
37
|
|
40
38
|
async def broadcast(self, message: dict):
|
41
39
|
for connection in self.active_connections:
|
42
|
-
await
|
40
|
+
await self.send_personal_message(message, connection)
|
43
41
|
|
44
42
|
async def broadcast_to_admins(self, message: dict):
|
45
43
|
for connection in self.admin_connections:
|
@@ -0,0 +1,46 @@
|
|
1
|
+
neuro_simulator/__init__.py,sha256=-tposzyvg6UckPcfSvtc03UjxBa9oCe_zRvlKf8splk,31
|
2
|
+
neuro_simulator/cli.py,sha256=ma7kxzQqPaCbnUrZ516avIAsVk43PEc7-wH7BtfFe4E,5464
|
3
|
+
neuro_simulator/agent/__init__.py,sha256=t52CZlyTGWqcGjMs90qvpFpRckY2WSSlO7r_H3K_mSY,32
|
4
|
+
neuro_simulator/agent/core.py,sha256=_UkxMV1S33VHjD1JFlKz17GpaDhHQGNA9s9dsRgd3j0,9561
|
5
|
+
neuro_simulator/agent/llm.py,sha256=xPBEXpZ19WOt7YkERNaY9rscNI-ePASTjIt-_sZV7UI,4262
|
6
|
+
neuro_simulator/agent/memory_prompt.txt,sha256=wdpdnbOYhMKgPJnnGlcSejGdt2uItrXzDgz9_8cKnqw,824
|
7
|
+
neuro_simulator/agent/neuro_prompt.txt,sha256=WSN5Fa6AwVnJaSFhz98fQTb2EtQ35U6w2qga_C-s1Go,1438
|
8
|
+
neuro_simulator/agent/memory/__init__.py,sha256=YJ7cynQJI6kD7vjyv3rKc-CZqmoYSuGQtRZl_XdGEps,39
|
9
|
+
neuro_simulator/agent/memory/manager.py,sha256=tnwxxAlpS0wEd0jfX2MG9hnyAcuhUiZOIP7mz9LCPh8,5388
|
10
|
+
neuro_simulator/agent/tools/__init__.py,sha256=1WZy6PADfi6o1avyy1y-ThWBFAPJ_bBqtkobyYpf5ao,38
|
11
|
+
neuro_simulator/agent/tools/add_temp_memory.py,sha256=R6K-iVMD6ykd7pS3uI811dZIkuuAf7nPn9c6xCzqiHc,2127
|
12
|
+
neuro_simulator/agent/tools/add_to_core_memory_block.py,sha256=dt7y3w-qr379gS79mdata9w3hHG45wxdVIDXPnROO1Y,2306
|
13
|
+
neuro_simulator/agent/tools/base.py,sha256=Xj9ABTAtSFazhQf-qCMMWTCQVLsq48MZtKFVuBsYLQg,1799
|
14
|
+
neuro_simulator/agent/tools/create_core_memory_block.py,sha256=uM2vF71Ai3NH2-Qbr7u8nRmo4EoRzWYsTurfUH2X6s8,2766
|
15
|
+
neuro_simulator/agent/tools/delete_core_memory_block.py,sha256=_t2NZWZaxuWJsm9Uof3Zscvucyz-xJfyC0KrssSXPGI,1379
|
16
|
+
neuro_simulator/agent/tools/get_core_memory_block.py,sha256=vFK6lrbOqdxWVpYa7yF96wkXKMcpQAn4E68GCZlu0Ow,1432
|
17
|
+
neuro_simulator/agent/tools/get_core_memory_blocks.py,sha256=UbK-GkPgha35n703bCKzdnoIKgXR4U4YxqsSYWimW6c,1059
|
18
|
+
neuro_simulator/agent/tools/manager.py,sha256=-GFeGR1wO2GteIXOwWcFgZ-iPTj1syzGfL7coGSWf4I,7124
|
19
|
+
neuro_simulator/agent/tools/remove_from_core_memory_block.py,sha256=uiY69y2iIJYp3Zh8EdtP2_G5Zqfs4YKSmTBd9zcIp_c,2372
|
20
|
+
neuro_simulator/agent/tools/speak.py,sha256=7vPbfWjllxSz39HmOUbKRPwPx64q2vsYrqDu-JsfZJk,1870
|
21
|
+
neuro_simulator/agent/tools/update_core_memory_block.py,sha256=CQgimyPNLmOuK_pDAiAxV9qEf3Tx6u7OKludlIR08BA,2272
|
22
|
+
neuro_simulator/api/__init__.py,sha256=5LWyDSayPGdQS8Rv13nmAKLyhPnMVPyTYDdvoMPB4xw,56
|
23
|
+
neuro_simulator/api/system.py,sha256=OJT6m6HIYATMCAKrgeBRhficaiUjIDl9f-WyUT-RoBw,1874
|
24
|
+
neuro_simulator/core/__init__.py,sha256=-ojq25c8XA0CU25b0OxcGjH4IWFEDHR-HXSRSZIuKe8,57
|
25
|
+
neuro_simulator/core/agent_factory.py,sha256=p3IKT6sNzSpUojQjvbZJu0pbmyyb258sGn_YNSJlqwI,1717
|
26
|
+
neuro_simulator/core/agent_interface.py,sha256=ZXUCtkQUvsBQ5iCb0gTILJaShn5KmSrEgKhd7PK18HE,2794
|
27
|
+
neuro_simulator/core/application.py,sha256=oJUuKW3U8Uadr1IlzZThef8CgNoW1zncW_U94OFOUPQ,25518
|
28
|
+
neuro_simulator/core/config.py,sha256=QRbkm0h_FBTtYd-z5RRauSa1B0cp0LkNHVLqGBOBTYY,15324
|
29
|
+
neuro_simulator/core/path_manager.py,sha256=hfjI4s8-WXlgwvPWDSLYMQ2d0OaXPOMYWWlP5xe5NLg,2954
|
30
|
+
neuro_simulator/services/__init__.py,sha256=s3ZrAHg5TpJakadAAGY1h0wDw_xqN4Je4aJwJyRBmk4,61
|
31
|
+
neuro_simulator/services/audience.py,sha256=sAmvkz1ip1MNqaw7t-9abqfnmp0yh8EdG5bS5KYR-Us,4999
|
32
|
+
neuro_simulator/services/audio.py,sha256=EElBue80njZY8_CKQhVtZEcGchJUdmS4EDOvJEEu_LY,2909
|
33
|
+
neuro_simulator/services/builtin.py,sha256=NrdQhf4BuB8_evxnz8m6wiY9DgLwhY3l7Yp5TnmHGYo,5156
|
34
|
+
neuro_simulator/services/letta.py,sha256=OEM4qYeRRPoj8qY645YZwCHmMfg1McLp0eTbSAu3KL0,11976
|
35
|
+
neuro_simulator/services/stream.py,sha256=eueAaxhAwX_n0mT1W0W4YOVCe7fH5uPoMdRf2o0wQMI,5937
|
36
|
+
neuro_simulator/utils/__init__.py,sha256=xSEFzjT827W81mNyQ_DLtr00TgFlttqfFgpz9pSxFXQ,58
|
37
|
+
neuro_simulator/utils/logging.py,sha256=fAM8mW4czr0RLgAUS6oN-YTWKj5daqwc5g7yjyAgaPw,3892
|
38
|
+
neuro_simulator/utils/process.py,sha256=9OYWx8fzaJZqmFUcjQX37AnBhl7YWvrLxDWBa30vqwU,3192
|
39
|
+
neuro_simulator/utils/queue.py,sha256=bg-mIFF8ycClwmmfcKSPjAXtvjImzTKf6z7xZc2VX20,2196
|
40
|
+
neuro_simulator/utils/state.py,sha256=DdBqSAYfjOFtJfB1hEGhYPh32r1ZvFuVlN_-29_-luA,664
|
41
|
+
neuro_simulator/utils/websocket.py,sha256=fjC-qipzjgM_e7XImP12DFmLhvxkMOSr2GnUWws7esE,2058
|
42
|
+
neuro_simulator-0.4.0.dist-info/METADATA,sha256=n3zf_b6P5veJQ-VPxlqlCsxCfZXTd2-loTHn6XB4N3w,8643
|
43
|
+
neuro_simulator-0.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
44
|
+
neuro_simulator-0.4.0.dist-info/entry_points.txt,sha256=qVd5ypnRRgU8Cw7rWfZ7o0OXyS9P9hgY-cRoN_mgz9g,51
|
45
|
+
neuro_simulator-0.4.0.dist-info/top_level.txt,sha256=V8awSKpcrFnjJDiJxSfy7jtOrnuE2BgAR9hLmfMDWK8,16
|
46
|
+
neuro_simulator-0.4.0.dist-info/RECORD,,
|
neuro_simulator/agent/base.py
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# agent/base.py
|
2
|
-
"""Base classes for Neuro Simulator Agent"""
|
3
|
-
|
4
|
-
from abc import ABC, abstractmethod
|
5
|
-
from typing import List, Dict, Any, Optional
|
6
|
-
|
7
|
-
|
8
|
-
class BaseAgent(ABC):
|
9
|
-
"""Abstract base class for all agents"""
|
10
|
-
|
11
|
-
@abstractmethod
|
12
|
-
async def initialize(self):
|
13
|
-
"""Initialize the agent"""
|
14
|
-
pass
|
15
|
-
|
16
|
-
@abstractmethod
|
17
|
-
async def reset_memory(self):
|
18
|
-
"""Reset agent memory"""
|
19
|
-
pass
|
20
|
-
|
21
|
-
@abstractmethod
|
22
|
-
async def get_response(self, chat_messages: List[Dict[str, str]]) -> Dict[str, Any]:
|
23
|
-
"""Get response from the agent
|
24
|
-
|
25
|
-
Args:
|
26
|
-
chat_messages: List of message dictionaries with 'username' and 'text' keys
|
27
|
-
|
28
|
-
Returns:
|
29
|
-
Dictionary containing processing details including tool executions and final response
|
30
|
-
"""
|
31
|
-
pass
|
32
|
-
|
33
|
-
@abstractmethod
|
34
|
-
async def process_messages(self, messages: List[Dict[str, str]]) -> Dict[str, Any]:
|
35
|
-
"""Process messages and generate a response
|
36
|
-
|
37
|
-
Args:
|
38
|
-
messages: List of message dictionaries with 'username' and 'text' keys
|
39
|
-
|
40
|
-
Returns:
|
41
|
-
Dictionary containing processing details including tool executions and final response
|
42
|
-
"""
|
43
|
-
pass
|
neuro_simulator/agent/factory.py
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# agent/factory.py
|
2
|
-
"""Factory for creating agent instances"""
|
3
|
-
|
4
|
-
from .base import BaseAgent
|
5
|
-
from ..config import config_manager
|
6
|
-
|
7
|
-
|
8
|
-
async def create_agent() -> BaseAgent:
|
9
|
-
"""Create an agent instance based on the configuration"""
|
10
|
-
agent_type = config_manager.settings.agent_type
|
11
|
-
|
12
|
-
if agent_type == "builtin":
|
13
|
-
from ..builtin_agent import local_agent, BuiltinAgentWrapper, initialize_builtin_agent
|
14
|
-
if local_agent is None:
|
15
|
-
# Try to initialize the builtin agent
|
16
|
-
await initialize_builtin_agent()
|
17
|
-
# Re-import local_agent after initialization
|
18
|
-
from ..builtin_agent import local_agent
|
19
|
-
if local_agent is None:
|
20
|
-
raise RuntimeError("Failed to initialize Builtin agent")
|
21
|
-
return BuiltinAgentWrapper(local_agent)
|
22
|
-
elif agent_type == "letta":
|
23
|
-
from ..letta import get_letta_agent, initialize_letta_client
|
24
|
-
# Try to initialize the letta client
|
25
|
-
initialize_letta_client()
|
26
|
-
agent = get_letta_agent()
|
27
|
-
await agent.initialize()
|
28
|
-
return agent
|
29
|
-
else:
|
30
|
-
raise ValueError(f"Unknown agent type: {agent_type}")
|
@@ -1,102 +0,0 @@
|
|
1
|
-
# neuro_simulator/agent/tools/core.py
|
2
|
-
"""
|
3
|
-
Core tools for the Neuro Simulator Agent
|
4
|
-
"""
|
5
|
-
|
6
|
-
import logging
|
7
|
-
from pathlib import Path
|
8
|
-
from typing import Dict, List, Any, Optional
|
9
|
-
|
10
|
-
# Use a logger with a shortened, more readable name
|
11
|
-
logger = logging.getLogger(__name__.replace("neuro_simulator", "agent", 1))
|
12
|
-
|
13
|
-
class ToolManager:
|
14
|
-
"""Manages all tools available to the agent"""
|
15
|
-
|
16
|
-
def __init__(self, memory_manager):
|
17
|
-
self.memory_manager = memory_manager
|
18
|
-
self.tools = {}
|
19
|
-
self._register_tools()
|
20
|
-
|
21
|
-
def _register_tools(self):
|
22
|
-
"""Register all available tools"""
|
23
|
-
self.tools["get_core_memory_blocks"] = self._get_core_memory_blocks
|
24
|
-
self.tools["get_core_memory_block"] = self._get_core_memory_block
|
25
|
-
self.tools["create_core_memory_block"] = self._create_core_memory_block
|
26
|
-
self.tools["update_core_memory_block"] = self._update_core_memory_block
|
27
|
-
self.tools["delete_core_memory_block"] = self._delete_core_memory_block
|
28
|
-
self.tools["add_to_core_memory_block"] = self._add_to_core_memory_block
|
29
|
-
self.tools["remove_from_core_memory_block"] = self._remove_from_core_memory_block
|
30
|
-
self.tools["add_temp_memory"] = self._add_temp_memory
|
31
|
-
self.tools["speak"] = self._speak
|
32
|
-
|
33
|
-
def get_tool_descriptions(self) -> str:
|
34
|
-
"""Get descriptions of all available tools"""
|
35
|
-
descriptions = [
|
36
|
-
"Available tools:",
|
37
|
-
"1. get_core_memory_blocks() - Get all core memory blocks",
|
38
|
-
"2. get_core_memory_block(block_id: string) - Get a specific core memory block",
|
39
|
-
"3. create_core_memory_block(title: string, description: string, content: list) - Create a new core memory block with a generated ID",
|
40
|
-
"4. update_core_memory_block(block_id: string, title: string (optional), description: string (optional), content: list (optional)) - Update a core memory block",
|
41
|
-
"5. delete_core_memory_block(block_id: string) - Delete a core memory block",
|
42
|
-
"6. add_to_core_memory_block(block_id: string, item: string) - Add an item to a core memory block",
|
43
|
-
"7. remove_from_core_memory_block(block_id: string, index: integer) - Remove an item from a core memory block by index",
|
44
|
-
"8. add_temp_memory(content: string, role: string) - Add an item to temporary memory",
|
45
|
-
"9. speak(text: string) - Output text to the user",
|
46
|
-
"",
|
47
|
-
"IMPORTANT INSTRUCTIONS:",
|
48
|
-
"- When you want to speak to the user, ONLY use the speak tool with your response as the text parameter",
|
49
|
-
"- DO NOT use print() or any other wrapper functions around the speak tool",
|
50
|
-
"- Example of correct usage: speak(text='Hello, how can I help you today?')",
|
51
|
-
"- Example of incorrect usage: print(speak(text='Hello, how can I help you today?'))",
|
52
|
-
"- ONLY return ONE tool call per response",
|
53
|
-
"- Format your response as plain text with the tool call, nothing else"
|
54
|
-
]
|
55
|
-
return "\n".join(descriptions)
|
56
|
-
|
57
|
-
async def execute_tool(self, tool_name: str, params: Dict[str, Any]) -> Any:
|
58
|
-
"""Execute a tool by name with given parameters"""
|
59
|
-
if tool_name not in self.tools:
|
60
|
-
return {"error": f"Tool '{tool_name}' not found"}
|
61
|
-
|
62
|
-
try:
|
63
|
-
result = await self.tools[tool_name](**params)
|
64
|
-
return result
|
65
|
-
except Exception as e:
|
66
|
-
return {"error": f"Error executing tool '{tool_name}': {str(e)}"}
|
67
|
-
|
68
|
-
# Tool implementations
|
69
|
-
async def _get_core_memory_blocks(self) -> Dict[str, Any]:
|
70
|
-
return await self.memory_manager.get_core_memory_blocks()
|
71
|
-
|
72
|
-
async def _get_core_memory_block(self, block_id: str) -> Optional[Dict[str, Any]]:
|
73
|
-
return await self.memory_manager.get_core_memory_block(block_id)
|
74
|
-
|
75
|
-
async def _create_core_memory_block(self, title: str, description: str, content: List[str]) -> str:
|
76
|
-
block_id = await self.memory_manager.create_core_memory_block(title, description, content)
|
77
|
-
return f"Created core memory block '{block_id}' with title '{title}'"
|
78
|
-
|
79
|
-
async def _update_core_memory_block(self, block_id: str, title: str = None, description: str = None, content: List[str] = None) -> str:
|
80
|
-
await self.memory_manager.update_core_memory_block(block_id, title, description, content)
|
81
|
-
return f"Updated core memory block '{block_id}'"
|
82
|
-
|
83
|
-
async def _delete_core_memory_block(self, block_id: str) -> str:
|
84
|
-
await self.memory_manager.delete_core_memory_block(block_id)
|
85
|
-
return f"Deleted core memory block '{block_id}'"
|
86
|
-
|
87
|
-
async def _add_to_core_memory_block(self, block_id: str, item: str) -> str:
|
88
|
-
await self.memory_manager.add_to_core_memory_block(block_id, item)
|
89
|
-
return f"Added item to core memory block '{block_id}'"
|
90
|
-
|
91
|
-
async def _remove_from_core_memory_block(self, block_id: str, index: int) -> str:
|
92
|
-
await self.memory_manager.remove_from_core_memory_block(block_id, index)
|
93
|
-
return f"Removed item from core memory block '{block_id}' at index {index}"
|
94
|
-
|
95
|
-
async def _add_temp_memory(self, content: str, role: str = "user") -> str:
|
96
|
-
await self.memory_manager.add_temp_memory(content, role)
|
97
|
-
return f"Added item to temp memory with role '{role}'"
|
98
|
-
|
99
|
-
async def _speak(self, text: str) -> str:
|
100
|
-
"""Output text - this is how the agent communicates with users"""
|
101
|
-
logger.info(f"Agent says: {text}")
|
102
|
-
return text
|
neuro_simulator/api/stream.py
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# This file is now empty as all stream control API endpoints have been migrated to WebSockets.
|
@@ -1,36 +0,0 @@
|
|
1
|
-
neuro_simulator/__init__.py,sha256=-tposzyvg6UckPcfSvtc03UjxBa9oCe_zRvlKf8splk,31
|
2
|
-
neuro_simulator/cli.py,sha256=Nc-udO0jdRVZjlbebKBjDVOIUzd6tJr13ApBGeBEg2k,3967
|
3
|
-
neuro_simulator/agent/__init__.py,sha256=t52CZlyTGWqcGjMs90qvpFpRckY2WSSlO7r_H3K_mSY,32
|
4
|
-
neuro_simulator/agent/base.py,sha256=6v2ZO5UpGCwJEkJ23Oe96Rs510tK4ZOEpZ2DB49IZmM,1262
|
5
|
-
neuro_simulator/agent/core.py,sha256=2mPVCcNKZDRsyYd6L8RzQYlm8LwzoKoP9FJg0W4qcbc,10702
|
6
|
-
neuro_simulator/agent/factory.py,sha256=e0IBnqJQM7OuKtglrf-pWwqwmg98wh7tOq5LxF2rV-w,1146
|
7
|
-
neuro_simulator/agent/llm.py,sha256=vLz8hp2h2R0JaNfS1RLGYGkri_YoUdlEdNfFVbxeEuI,4261
|
8
|
-
neuro_simulator/agent/memory/__init__.py,sha256=YJ7cynQJI6kD7vjyv3rKc-CZqmoYSuGQtRZl_XdGEps,39
|
9
|
-
neuro_simulator/agent/memory/manager.py,sha256=UiUJgjiTV7SHCmb3V5sc4OUa_ksEeXBOyvl-WBQviqs,9266
|
10
|
-
neuro_simulator/agent/tools/__init__.py,sha256=1WZy6PADfi6o1avyy1y-ThWBFAPJ_bBqtkobyYpf5ao,38
|
11
|
-
neuro_simulator/agent/tools/core.py,sha256=o6Oyis-HFD-g6Z_u3T--tkmr9ylKJvybKqMRSMUwi1Q,5555
|
12
|
-
neuro_simulator/api/__init__.py,sha256=5LWyDSayPGdQS8Rv13nmAKLyhPnMVPyTYDdvoMPB4xw,56
|
13
|
-
neuro_simulator/api/stream.py,sha256=hM66flSUygpE-NH9X-ZOV6SiGipBzN1-wjd_wZRpQm4,94
|
14
|
-
neuro_simulator/api/system.py,sha256=W05Q41BYAFrw-MTnJ5YJrBG2S1SmTcByoex77GfUaFQ,1787
|
15
|
-
neuro_simulator/core/__init__.py,sha256=-ojq25c8XA0CU25b0OxcGjH4IWFEDHR-HXSRSZIuKe8,57
|
16
|
-
neuro_simulator/core/agent_factory.py,sha256=qMFidwT5IrOkyNHwmpO8_fRv20KLbaIBfWF-VTFCLNA,1742
|
17
|
-
neuro_simulator/core/agent_interface.py,sha256=ZXUCtkQUvsBQ5iCb0gTILJaShn5KmSrEgKhd7PK18HE,2794
|
18
|
-
neuro_simulator/core/application.py,sha256=zQ6QRUU-dyFW2GDKyBxiTO1BKh-Yt6j169YS-MLpalk,23734
|
19
|
-
neuro_simulator/core/config.py,sha256=brA8kiekV_995mpz04JiGj1swIWbZZuWWLNYtbroMyE,14884
|
20
|
-
neuro_simulator/services/__init__.py,sha256=s3ZrAHg5TpJakadAAGY1h0wDw_xqN4Je4aJwJyRBmk4,61
|
21
|
-
neuro_simulator/services/audience.py,sha256=0phlhsujh_GMXm_UMiyOntY-ZMtoseRa_FroIfc5A6w,5028
|
22
|
-
neuro_simulator/services/audio.py,sha256=ZscQA25wVYpm9FUl4Hya7tKH8t0TjR3th9-OEZ0G7xk,2934
|
23
|
-
neuro_simulator/services/builtin.py,sha256=nn3sJFPy09JxQkw35icdyGU9hzLTXXazAJkNpdcz6Zs,5848
|
24
|
-
neuro_simulator/services/letta.py,sha256=6jBvOTsLMlRILDv-fvX9fhHMONSYeu-ImJGFcKU00kc,11067
|
25
|
-
neuro_simulator/services/stream.py,sha256=dG7RuNI_ICohPkqKZ-zlBppo54BgWm_KYBs-ezzc73E,5907
|
26
|
-
neuro_simulator/utils/__init__.py,sha256=xSEFzjT827W81mNyQ_DLtr00TgFlttqfFgpz9pSxFXQ,58
|
27
|
-
neuro_simulator/utils/logging.py,sha256=BO-q_cCcoeamsc8eJqq2-L3Z8nhApze_v6LnmD-O8Ww,3411
|
28
|
-
neuro_simulator/utils/process.py,sha256=9OYWx8fzaJZqmFUcjQX37AnBhl7YWvrLxDWBa30vqwU,3192
|
29
|
-
neuro_simulator/utils/queue.py,sha256=vSkh-BrgfsGN_gDAx2mfK44ydmMapdVyLsDG-7LIJZQ,1643
|
30
|
-
neuro_simulator/utils/state.py,sha256=DdBqSAYfjOFtJfB1hEGhYPh32r1ZvFuVlN_-29_-luA,664
|
31
|
-
neuro_simulator/utils/websocket.py,sha256=1gtVoH1hafBUfVYmwkVDAbjwETeqyC3sWx706nQzSRo,2085
|
32
|
-
neuro_simulator-0.3.2.dist-info/METADATA,sha256=HBAqQoRRJmPcm1IxQwderrq7cTO-UhF-ulzqixLNPh8,8643
|
33
|
-
neuro_simulator-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
34
|
-
neuro_simulator-0.3.2.dist-info/entry_points.txt,sha256=qVd5ypnRRgU8Cw7rWfZ7o0OXyS9P9hgY-cRoN_mgz9g,51
|
35
|
-
neuro_simulator-0.3.2.dist-info/top_level.txt,sha256=V8awSKpcrFnjJDiJxSfy7jtOrnuE2BgAR9hLmfMDWK8,16
|
36
|
-
neuro_simulator-0.3.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|