neuro-simulator 0.5.1__tar.gz → 0.5.2__tar.gz
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-0.5.1 → neuro_simulator-0.5.2}/PKG-INFO +1 -1
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/api/system.py +0 -11
- neuro_simulator-0.5.2/neuro_simulator/cli.py +112 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/core/application.py +6 -7
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/core/config.py +21 -51
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/services/audio.py +30 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator.egg-info/PKG-INFO +1 -1
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/pyproject.toml +1 -1
- neuro_simulator-0.5.1/neuro_simulator/cli.py +0 -125
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/README.md +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/core.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/llm.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/memory/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/memory/manager.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/memory_prompt.txt +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/neuro_prompt.txt +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/add_temp_memory.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/add_to_core_memory_block.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/base.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/create_core_memory_block.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/delete_core_memory_block.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/get_core_memory_block.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/get_core_memory_blocks.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/manager.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/model_spin.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/model_zoom.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/remove_from_core_memory_block.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/speak.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/update_core_memory_block.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/api/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/assets/neuro_start.mp4 +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/core.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/llm.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/memory/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/memory/manager.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/nickname_gen/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/nickname_gen/generator.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/prompts/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/tools/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/tools/add_temp_memory.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/tools/base.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/tools/manager.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/tools/post_chat_message.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/config.yaml.example +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/core/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/core/agent_factory.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/core/agent_interface.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/core/path_manager.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/services/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/services/builtin.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/services/letta.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/services/stream.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/utils/__init__.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/utils/logging.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/utils/process.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/utils/queue.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/utils/state.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/utils/websocket.py +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator.egg-info/SOURCES.txt +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator.egg-info/dependency_links.txt +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator.egg-info/entry_points.txt +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator.egg-info/requires.txt +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator.egg-info/top_level.txt +0 -0
- {neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/setup.cfg +0 -0
@@ -13,17 +13,6 @@ from ..utils.process import process_manager
|
|
13
13
|
router = APIRouter(tags=["System & Utilities"])
|
14
14
|
|
15
15
|
|
16
|
-
# --- Utility function to filter config for frontend ---
|
17
|
-
def filter_config_for_frontend(settings):
|
18
|
-
"""Filters the full settings object to remove sensitive fields before sending to the frontend."""
|
19
|
-
# Create a dictionary representation of the settings
|
20
|
-
config_dict = settings.model_dump()
|
21
|
-
|
22
|
-
# Remove sensitive fields
|
23
|
-
config_dict.pop('api_keys', None)
|
24
|
-
|
25
|
-
return config_dict
|
26
|
-
|
27
16
|
|
28
17
|
# --- Auth Dependency ---
|
29
18
|
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""Command-line interface for the Neuro-Simulator Server."""
|
3
|
+
|
4
|
+
import argparse
|
5
|
+
import logging
|
6
|
+
import os
|
7
|
+
import shutil
|
8
|
+
import sys
|
9
|
+
from pathlib import Path
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
def main():
|
14
|
+
"""Main entry point for the CLI."""
|
15
|
+
parser = argparse.ArgumentParser(description="Neuro-Simulator Server")
|
16
|
+
parser.add_argument("-D", "--dir", help="Working directory for config and data")
|
17
|
+
parser.add_argument("-H", "--host", help="Host to bind the server to")
|
18
|
+
parser.add_argument("-P", "--port", type=int, help="Port to bind the server to")
|
19
|
+
|
20
|
+
args = parser.parse_args()
|
21
|
+
|
22
|
+
# --- 1. Setup Working Directory ---
|
23
|
+
if args.dir:
|
24
|
+
work_dir = Path(args.dir).resolve()
|
25
|
+
if not work_dir.exists():
|
26
|
+
logging.error(f"Working directory '{work_dir}' does not exist. Please create it first.")
|
27
|
+
sys.exit(1)
|
28
|
+
else:
|
29
|
+
work_dir = Path.home() / ".config" / "neuro-simulator"
|
30
|
+
work_dir.mkdir(parents=True, exist_ok=True)
|
31
|
+
|
32
|
+
os.chdir(work_dir)
|
33
|
+
logging.info(f"Using working directory: {work_dir}")
|
34
|
+
|
35
|
+
# --- 2. Initialize Path Manager ---
|
36
|
+
from neuro_simulator.core import path_manager
|
37
|
+
path_manager.initialize_path_manager(os.getcwd())
|
38
|
+
|
39
|
+
# --- 3. First-Run Environment Initialization ---
|
40
|
+
# This block ensures that a new user has all the necessary default files.
|
41
|
+
try:
|
42
|
+
package_source_path = Path(__file__).parent
|
43
|
+
|
44
|
+
# Helper to copy files if they don't exist
|
45
|
+
def copy_if_not_exists(src: Path, dest: Path):
|
46
|
+
if not dest.exists():
|
47
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
48
|
+
shutil.copy(src, dest)
|
49
|
+
logging.info(f"Copied default file to {dest}")
|
50
|
+
|
51
|
+
# Copy config.yaml.example
|
52
|
+
copy_if_not_exists(package_source_path / "config.yaml.example", work_dir / "config.yaml.example")
|
53
|
+
|
54
|
+
# Copy prompts
|
55
|
+
copy_if_not_exists(package_source_path / "agent" / "neuro_prompt.txt", path_manager.path_manager.neuro_prompt_path)
|
56
|
+
copy_if_not_exists(package_source_path / "agent" / "memory_prompt.txt", path_manager.path_manager.memory_agent_prompt_path)
|
57
|
+
|
58
|
+
# Copy default memory JSON files
|
59
|
+
copy_if_not_exists(package_source_path / "agent" / "memory" / "core_memory.json", path_manager.path_manager.core_memory_path)
|
60
|
+
copy_if_not_exists(package_source_path / "agent" / "memory" / "init_memory.json", path_manager.path_manager.init_memory_path)
|
61
|
+
copy_if_not_exists(package_source_path / "agent" / "memory" / "temp_memory.json", path_manager.path_manager.temp_memory_path)
|
62
|
+
|
63
|
+
# Copy default assets directory
|
64
|
+
source_assets_dir = package_source_path / "assets"
|
65
|
+
destination_assets_dir = path_manager.path_manager.assets_dir
|
66
|
+
if not destination_assets_dir.exists():
|
67
|
+
shutil.copytree(source_assets_dir, destination_assets_dir)
|
68
|
+
logging.info(f"Copied default asset directory to {destination_assets_dir}")
|
69
|
+
|
70
|
+
except Exception as e:
|
71
|
+
logging.warning(f"Could not copy all default files: {e}")
|
72
|
+
|
73
|
+
# --- 4. Load Configuration ---
|
74
|
+
from neuro_simulator.core.config import config_manager
|
75
|
+
from pydantic import ValidationError
|
76
|
+
import uvicorn
|
77
|
+
|
78
|
+
main_config_path = path_manager.path_manager.working_dir / "config.yaml"
|
79
|
+
try:
|
80
|
+
config_manager.load(str(main_config_path))
|
81
|
+
except FileNotFoundError:
|
82
|
+
logging.error(f"FATAL: Configuration file '{main_config_path.name}' not found.")
|
83
|
+
logging.error(f"If this is your first time, please rename 'config.yaml.example' to 'config.yaml' after filling it out.")
|
84
|
+
sys.exit(1)
|
85
|
+
except ValidationError as e:
|
86
|
+
logging.error(f"FATAL: Configuration error in '{main_config_path.name}':")
|
87
|
+
logging.error(e)
|
88
|
+
sys.exit(1)
|
89
|
+
except Exception as e:
|
90
|
+
logging.error(f"FATAL: An unexpected error occurred while loading the configuration: {e}")
|
91
|
+
sys.exit(1)
|
92
|
+
|
93
|
+
# --- 5. Determine Server Host and Port ---
|
94
|
+
# Command-line arguments override config file settings
|
95
|
+
server_host = args.host or config_manager.settings.server.host
|
96
|
+
server_port = args.port or config_manager.settings.server.port
|
97
|
+
|
98
|
+
# --- 6. Run the Server ---
|
99
|
+
logging.info(f"Starting Neuro-Simulator server on {server_host}:{server_port}...")
|
100
|
+
try:
|
101
|
+
uvicorn.run(
|
102
|
+
"neuro_simulator.core.application:app",
|
103
|
+
host=server_host,
|
104
|
+
port=server_port,
|
105
|
+
reload=False
|
106
|
+
)
|
107
|
+
except ImportError as e:
|
108
|
+
logging.error(f"Could not import the application. Make sure the package is installed correctly. Details: {e}", exc_info=True)
|
109
|
+
sys.exit(1)
|
110
|
+
|
111
|
+
if __name__ == "__main__":
|
112
|
+
main()
|
@@ -482,23 +482,22 @@ async def handle_admin_ws_message(websocket: WebSocket, data: dict):
|
|
482
482
|
response["payload"] = status
|
483
483
|
|
484
484
|
# Config Management Actions
|
485
|
+
elif action == "get_settings_schema":
|
486
|
+
response["payload"] = config_manager.settings.model_json_schema()
|
487
|
+
|
485
488
|
elif action == "get_configs":
|
486
|
-
|
487
|
-
configs = filter_config_for_frontend(config_manager.settings)
|
488
|
-
response["payload"] = configs
|
489
|
+
response["payload"] = config_manager.settings.model_dump()
|
489
490
|
|
490
491
|
elif action == "update_configs":
|
491
|
-
from ..api.system import filter_config_for_frontend
|
492
492
|
await config_manager.update_settings(payload)
|
493
|
-
updated_configs =
|
493
|
+
updated_configs = config_manager.settings.model_dump()
|
494
494
|
response["payload"] = updated_configs
|
495
495
|
await connection_manager.broadcast_to_admins({"type": "config_updated", "payload": updated_configs})
|
496
496
|
|
497
497
|
elif action == "reload_configs":
|
498
498
|
await config_manager.update_settings({})
|
499
499
|
response["payload"] = {"status": "success", "message": "Configuration reloaded"}
|
500
|
-
|
501
|
-
updated_configs = filter_config_for_frontend(config_manager.settings)
|
500
|
+
updated_configs = config_manager.settings.model_dump()
|
502
501
|
await connection_manager.broadcast_to_admins({"type": "config_updated", "payload": updated_configs})
|
503
502
|
|
504
503
|
# Other Agent Actions
|
@@ -110,56 +110,29 @@ class ConfigManager:
|
|
110
110
|
self._update_callbacks = []
|
111
111
|
self._initialized = True
|
112
112
|
|
113
|
-
def
|
114
|
-
"""
|
113
|
+
def load(self, config_path_str: str):
|
114
|
+
"""
|
115
|
+
Loads the configuration from the given path, validates it, and sets it
|
116
|
+
on the manager instance.
|
117
|
+
|
118
|
+
Raises:
|
119
|
+
FileNotFoundError: If the config file does not exist.
|
120
|
+
ValueError: If the config file is empty.
|
121
|
+
pydantic.ValidationError: If the config file content does not match the AppSettings schema.
|
122
|
+
"""
|
115
123
|
config_path = Path(config_path_str)
|
116
|
-
example_path = Path(example_path_str)
|
117
|
-
|
118
|
-
# Scenario 1: Both config and example are missing in the working directory.
|
119
|
-
if not config_path.exists() and not example_path.exists():
|
120
|
-
try:
|
121
|
-
import importlib.resources
|
122
|
-
# For Python 3.9+, prefer importlib.resources.files
|
123
|
-
ref = importlib.resources.files('neuro_simulator') / 'config.yaml.example'
|
124
|
-
with importlib.resources.as_file(ref) as package_example_path:
|
125
|
-
shutil.copy(package_example_path, example_path)
|
126
|
-
logging.info(f"Created '{example_path}' from package resource.")
|
127
|
-
logging.error(f"Configuration file '{config_path.name}' not found. A new '{example_path.name}' has been created. Please configure it and rename it to '{config_path.name}'.")
|
128
|
-
sys.exit(1)
|
129
|
-
except Exception as e:
|
130
|
-
logging.error(f"FATAL: Could not create config from package resources: {e}")
|
131
|
-
sys.exit(1)
|
132
|
-
|
133
|
-
# Scenario 2: Config is missing, but example exists.
|
134
|
-
elif not config_path.exists() and example_path.exists():
|
135
|
-
logging.error(f"Configuration file '{config_path.name}' not found, but '{example_path.name}' exists. Please rename it to '{config_path.name}' after configuration.")
|
136
|
-
sys.exit(1)
|
137
|
-
|
138
|
-
# Scenario 3: Config exists, but example is missing.
|
139
|
-
elif config_path.exists() and not example_path.exists():
|
140
|
-
try:
|
141
|
-
import importlib.resources
|
142
|
-
# For Python 3.9+, prefer importlib.resources.files
|
143
|
-
ref = importlib.resources.files('neuro_simulator') / 'config.yaml.example'
|
144
|
-
with importlib.resources.as_file(ref) as package_example_path:
|
145
|
-
shutil.copy(package_example_path, example_path)
|
146
|
-
logging.info(f"Created missing '{example_path.name}' from package resource.")
|
147
|
-
except Exception as e:
|
148
|
-
logging.warning(f"Could not create missing '{example_path.name}': {e}")
|
149
|
-
|
150
|
-
# Proceed with loading the config if it exists.
|
151
|
-
try:
|
152
|
-
with open(config_path, 'r', encoding='utf-8') as f:
|
153
|
-
yaml_config = yaml.safe_load(f)
|
154
|
-
if yaml_config is None:
|
155
|
-
raise ValueError(f"Configuration file '{config_path}' is empty.")
|
156
|
-
|
157
|
-
self.settings = AppSettings.model_validate(yaml_config)
|
158
|
-
logging.info("Main configuration loaded successfully.")
|
159
124
|
|
160
|
-
|
161
|
-
|
162
|
-
|
125
|
+
if not config_path.exists():
|
126
|
+
raise FileNotFoundError(f"Configuration file '{config_path}' not found.")
|
127
|
+
|
128
|
+
with open(config_path, 'r', encoding='utf-8') as f:
|
129
|
+
yaml_config = yaml.safe_load(f)
|
130
|
+
if yaml_config is None:
|
131
|
+
raise ValueError(f"Configuration file '{config_path}' is empty.")
|
132
|
+
|
133
|
+
# This will raise ValidationError on failure
|
134
|
+
self.settings = AppSettings.model_validate(yaml_config)
|
135
|
+
logging.info("Configuration loaded and validated successfully.")
|
163
136
|
|
164
137
|
def save_settings(self):
|
165
138
|
"""Saves the current configuration to config.yaml while preserving comments and formatting."""
|
@@ -312,9 +285,6 @@ class ConfigManager:
|
|
312
285
|
model to ensure sub-models are correctly instantiated, and then
|
313
286
|
notifying callbacks.
|
314
287
|
"""
|
315
|
-
# Prevent API keys from being updated from the panel
|
316
|
-
new_settings_data.pop('api_keys', None)
|
317
|
-
|
318
288
|
try:
|
319
289
|
# 1. Dump the current settings model to a dictionary.
|
320
290
|
current_settings_dict = self.settings.model_dump()
|
@@ -3,6 +3,7 @@ import asyncio
|
|
3
3
|
import base64
|
4
4
|
import html
|
5
5
|
import logging
|
6
|
+
import re
|
6
7
|
|
7
8
|
import azure.cognitiveservices.speech as speechsdk
|
8
9
|
|
@@ -10,11 +11,40 @@ from ..core.config import config_manager
|
|
10
11
|
|
11
12
|
logger = logging.getLogger(__name__.replace("neuro_simulator", "server", 1))
|
12
13
|
|
14
|
+
def _remove_emoji(text: str) -> str:
|
15
|
+
"""Removes emoji characters from a string."""
|
16
|
+
if not text:
|
17
|
+
return ""
|
18
|
+
# This regex pattern covers a wide range of Unicode emoji characters.
|
19
|
+
emoji_pattern = re.compile(
|
20
|
+
"["
|
21
|
+
"\U0001F600-\U0001F64F" # emoticons
|
22
|
+
"\U0001F300-\U0001F5FF" # symbols & pictographs
|
23
|
+
"\U0001F680-\U0001F6FF" # transport & map symbols
|
24
|
+
"\U0001F700-\U0001F77F" # alchemical symbols
|
25
|
+
"\U0001F780-\U0001F7FF" # Geometric Shapes Extended
|
26
|
+
"\U0001F800-\U0001F8FF" # Supplemental Arrows-C
|
27
|
+
"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
|
28
|
+
"\U0001FA00-\U0001FA6F" # Chess Symbols
|
29
|
+
"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
|
30
|
+
"\U00002702-\U000027B0" # Dingbats
|
31
|
+
"\U000024C2-\U0001F251"
|
32
|
+
"]+",
|
33
|
+
flags=re.UNICODE,
|
34
|
+
)
|
35
|
+
return emoji_pattern.sub(r'', text).strip()
|
36
|
+
|
13
37
|
async def synthesize_audio_segment(text: str, voice_name: str = None, pitch: float = None) -> tuple[str, float]:
|
14
38
|
"""
|
15
39
|
Synthesizes audio using Azure TTS.
|
16
40
|
Returns a Base64 encoded audio string and the audio duration in seconds.
|
17
41
|
"""
|
42
|
+
# Clean emojis from the text before synthesis
|
43
|
+
text = _remove_emoji(text)
|
44
|
+
if not text:
|
45
|
+
# If text is empty after cleaning, no need to synthesize.
|
46
|
+
return "", 0.0
|
47
|
+
|
18
48
|
azure_key = config_manager.settings.api_keys.azure_speech_key
|
19
49
|
azure_region = config_manager.settings.api_keys.azure_speech_region
|
20
50
|
|
@@ -1,125 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
"""Command-line interface for the Neuro-Simulator Server."""
|
3
|
-
|
4
|
-
import argparse
|
5
|
-
import logging
|
6
|
-
import os
|
7
|
-
import shutil
|
8
|
-
import sys
|
9
|
-
from pathlib import Path
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def main():
|
14
|
-
"""Main entry point for the CLI."""
|
15
|
-
parser = argparse.ArgumentParser(description="Neuro-Simulator Server")
|
16
|
-
parser.add_argument("-D", "--dir", help="Working directory for config and data")
|
17
|
-
parser.add_argument("-H", "--host", help="Host to bind the server to")
|
18
|
-
parser.add_argument("-P", "--port", type=int, help="Port to bind the server to")
|
19
|
-
|
20
|
-
args = parser.parse_args()
|
21
|
-
|
22
|
-
# 1. Set working directory
|
23
|
-
if args.dir:
|
24
|
-
work_dir = Path(args.dir).resolve()
|
25
|
-
if not work_dir.exists():
|
26
|
-
logging.error(f"Working directory '{work_dir}' does not exist. Please create it first.")
|
27
|
-
sys.exit(1)
|
28
|
-
else:
|
29
|
-
work_dir = Path.home() / ".config" / "neuro-simulator"
|
30
|
-
work_dir.mkdir(parents=True, exist_ok=True)
|
31
|
-
|
32
|
-
os.chdir(work_dir)
|
33
|
-
logging.info(f"Using working directory: {work_dir}")
|
34
|
-
|
35
|
-
# 2. Initialize paths and load configuration
|
36
|
-
from neuro_simulator.core import path_manager
|
37
|
-
from neuro_simulator.core.config import config_manager
|
38
|
-
import uvicorn
|
39
|
-
|
40
|
-
path_manager.initialize_path_manager(os.getcwd())
|
41
|
-
|
42
|
-
# Define example_path early for config loading
|
43
|
-
example_path = Path(__file__).parent / "config.yaml.example"
|
44
|
-
|
45
|
-
# 2.2. Copy default config.yaml.example if it doesn't exist
|
46
|
-
try:
|
47
|
-
source_config_example = example_path
|
48
|
-
destination_config_example = path_manager.path_manager.working_dir / "config.yaml.example"
|
49
|
-
if not destination_config_example.exists():
|
50
|
-
shutil.copy(source_config_example, destination_config_example)
|
51
|
-
logging.info(f"Copyed default config.yaml.example to {destination_config_example}")
|
52
|
-
except Exception as e:
|
53
|
-
logging.warning(f"Could not copy default config.yaml.example: {e}")
|
54
|
-
|
55
|
-
main_config_path = path_manager.path_manager.working_dir / "config.yaml"
|
56
|
-
config_manager.load_and_validate(str(main_config_path), str(example_path))
|
57
|
-
|
58
|
-
# 2.5. Copy default prompt templates if they don't exist
|
59
|
-
try:
|
60
|
-
# Use Path(__file__).parent for robust path resolution
|
61
|
-
base_path = Path(__file__).parent
|
62
|
-
neuro_prompt_example = base_path / "agent" / "neuro_prompt.txt"
|
63
|
-
memory_prompt_example = base_path / "agent" / "memory_prompt.txt"
|
64
|
-
|
65
|
-
if not path_manager.path_manager.neuro_prompt_path.exists():
|
66
|
-
shutil.copy(neuro_prompt_example, path_manager.path_manager.neuro_prompt_path)
|
67
|
-
logging.info(f"Copied default neuro prompt to {path_manager.path_manager.neuro_prompt_path}")
|
68
|
-
if not path_manager.path_manager.memory_agent_prompt_path.exists():
|
69
|
-
shutil.copy(memory_prompt_example, path_manager.path_manager.memory_agent_prompt_path)
|
70
|
-
logging.info(f"Copied default memory prompt to {path_manager.path_manager.memory_agent_prompt_path}")
|
71
|
-
|
72
|
-
# Copy default memory JSON files if they don't exist
|
73
|
-
memory_files = {
|
74
|
-
"core_memory.json": path_manager.path_manager.core_memory_path,
|
75
|
-
"init_memory.json": path_manager.path_manager.init_memory_path,
|
76
|
-
"temp_memory.json": path_manager.path_manager.temp_memory_path,
|
77
|
-
}
|
78
|
-
for filename, dest_path in memory_files.items():
|
79
|
-
src_path = base_path / "agent" / "memory" / filename
|
80
|
-
if not dest_path.exists():
|
81
|
-
shutil.copy(src_path, dest_path)
|
82
|
-
logging.info(f"Copied default {filename} to {dest_path}")
|
83
|
-
|
84
|
-
# Copy default assets directory if it doesn't exist
|
85
|
-
source_assets_dir = base_path / "assets"
|
86
|
-
destination_assets_dir = path_manager.path_manager.assets_dir
|
87
|
-
|
88
|
-
# Ensure the destination assets directory exists
|
89
|
-
destination_assets_dir.mkdir(parents=True, exist_ok=True)
|
90
|
-
|
91
|
-
# Copy individual files from source assets to destination assets
|
92
|
-
for item in source_assets_dir.iterdir():
|
93
|
-
if item.is_file():
|
94
|
-
dest_file = destination_assets_dir / item.name
|
95
|
-
if not dest_file.exists():
|
96
|
-
shutil.copy(item, dest_file)
|
97
|
-
logging.info(f"Copied asset {item.name} to {dest_file}")
|
98
|
-
elif item.is_dir():
|
99
|
-
# Recursively copy subdirectories if they don't exist
|
100
|
-
dest_subdir = destination_assets_dir / item.name
|
101
|
-
if not dest_subdir.exists():
|
102
|
-
shutil.copytree(item, dest_subdir)
|
103
|
-
logging.info(f"Copied asset directory {item.name} to {dest_subdir}")
|
104
|
-
except Exception as e:
|
105
|
-
logging.warning(f"Could not copy default prompt templates, memory files, or assets: {e}")
|
106
|
-
|
107
|
-
# 3. Determine server host and port
|
108
|
-
server_host = args.host or config_manager.settings.server.host
|
109
|
-
server_port = args.port or config_manager.settings.server.port
|
110
|
-
|
111
|
-
# 4. Run the server
|
112
|
-
logging.info(f"Starting Neuro-Simulator server on {server_host}:{server_port}...")
|
113
|
-
try:
|
114
|
-
uvicorn.run(
|
115
|
-
"neuro_simulator.core.application:app",
|
116
|
-
host=server_host,
|
117
|
-
port=server_port,
|
118
|
-
reload=False
|
119
|
-
)
|
120
|
-
except ImportError as e:
|
121
|
-
logging.error(f"Could not import the application. Make sure the package is installed correctly. Details: {e}", exc_info=True)
|
122
|
-
sys.exit(1)
|
123
|
-
|
124
|
-
if __name__ == "__main__":
|
125
|
-
main()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/add_temp_memory.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/agent/tools/get_core_memory_block.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/nickname_gen/__init__.py
RENAMED
File without changes
|
{neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/nickname_gen/generator.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/tools/add_temp_memory.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator/chatbot/tools/post_chat_message.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{neuro_simulator-0.5.1 → neuro_simulator-0.5.2}/neuro_simulator.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|