neuro-simulator 0.4.3__py3-none-any.whl → 0.5.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.
@@ -1,6 +1,6 @@
1
1
  neuro_simulator/__init__.py,sha256=-tposzyvg6UckPcfSvtc03UjxBa9oCe_zRvlKf8splk,31
2
2
  neuro_simulator/cli.py,sha256=gtmZZ7Y-lZqEtz9AIA4TuJ4vJw5pNFvPrqpxxIaDnl4,5455
3
- neuro_simulator/config.yaml.example,sha256=RbSHEAFD9NEuIvgl5Smpasfz4jiZYQgzTovL3MrhhIs,6549
3
+ neuro_simulator/config.yaml.example,sha256=M-uCuDj-0XvM6BuFNQT9rsFHL_t71UK0jWVSuF6nL6Q,4732
4
4
  neuro_simulator/agent/__init__.py,sha256=t52CZlyTGWqcGjMs90qvpFpRckY2WSSlO7r_H3K_mSY,32
5
5
  neuro_simulator/agent/core.py,sha256=_UkxMV1S33VHjD1JFlKz17GpaDhHQGNA9s9dsRgd3j0,9561
6
6
  neuro_simulator/agent/llm.py,sha256=xPBEXpZ19WOt7YkERNaY9rscNI-ePASTjIt-_sZV7UI,4262
@@ -25,26 +25,38 @@ neuro_simulator/agent/tools/update_core_memory_block.py,sha256=CQgimyPNLmOuK_pDA
25
25
  neuro_simulator/api/__init__.py,sha256=5LWyDSayPGdQS8Rv13nmAKLyhPnMVPyTYDdvoMPB4xw,56
26
26
  neuro_simulator/api/system.py,sha256=OJT6m6HIYATMCAKrgeBRhficaiUjIDl9f-WyUT-RoBw,1874
27
27
  neuro_simulator/assets/neuro_start.mp4,sha256=xCLnNzv4THnzRYwkdV6EiqXc-XtFd867R2ZVLDvNp0Y,8226418
28
+ neuro_simulator/chatbot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ neuro_simulator/chatbot/core.py,sha256=jddeOZDYcEcWpEryMVOlLFCq1YqIZGnqQi7VV_sPnRU,11314
30
+ neuro_simulator/chatbot/llm.py,sha256=UgiAq8aqmuSaf3poX_QIZHPxKPZpr_Xn4aHrhTlESPE,4204
31
+ neuro_simulator/chatbot/memory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
+ neuro_simulator/chatbot/memory/manager.py,sha256=K84EEH-gRPksgt7GcNxvEVo60aHxaOTC3dZMf2rR9bQ,3827
33
+ neuro_simulator/chatbot/nickname_gen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
+ neuro_simulator/chatbot/nickname_gen/generator.py,sha256=ajrGp37uD7kzzzl9msMeD2EWyYW2JBXE2VT3N4IKpBA,6361
35
+ neuro_simulator/chatbot/prompts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
+ neuro_simulator/chatbot/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ neuro_simulator/chatbot/tools/add_temp_memory.py,sha256=ZsqvVx1cZMyjVFTo8ICxdhuk72K2kF17N9imDASODz8,1884
38
+ neuro_simulator/chatbot/tools/base.py,sha256=YebWl1Y0uyMDzehxXWpmbQfPxGcZg1n3cJO2l13wRdc,1208
39
+ neuro_simulator/chatbot/tools/manager.py,sha256=LJx6teTURs7uPstWYS-odyNr32AwDErxRQzqKRhxmjI,5064
40
+ neuro_simulator/chatbot/tools/post_chat_message.py,sha256=lchGCSQKzPZgb1z__MIDkG2Cxn_nAN3ISsNkYGbpTsg,1775
28
41
  neuro_simulator/core/__init__.py,sha256=-ojq25c8XA0CU25b0OxcGjH4IWFEDHR-HXSRSZIuKe8,57
29
42
  neuro_simulator/core/agent_factory.py,sha256=p3IKT6sNzSpUojQjvbZJu0pbmyyb258sGn_YNSJlqwI,1717
30
43
  neuro_simulator/core/agent_interface.py,sha256=ZXUCtkQUvsBQ5iCb0gTILJaShn5KmSrEgKhd7PK18HE,2794
31
- neuro_simulator/core/application.py,sha256=mW5SlqonSn5oQvb5xuGR8FTZ_-sEx3OUTXwfC_N_-2c,26703
32
- neuro_simulator/core/config.py,sha256=JNcZccxRa0oY_6ctRlue_2Wf2zxL0FONr8jXVE8xqfg,15568
33
- neuro_simulator/core/path_manager.py,sha256=hfjI4s8-WXlgwvPWDSLYMQ2d0OaXPOMYWWlP5xe5NLg,2954
44
+ neuro_simulator/core/application.py,sha256=TxqDz4buITapVwgtO6Pv5-JlG--8JPk5IQraaTFW8oQ,26566
45
+ neuro_simulator/core/config.py,sha256=BszgxKFtHyoYUYUjJmY-kc-X0H7LQencJFKzt56j_hQ,15068
46
+ neuro_simulator/core/path_manager.py,sha256=fQZ5RLdiWYeWXbmnhmgCoBEMWXtnPEGtZ6dhtpyXRCI,4339
34
47
  neuro_simulator/services/__init__.py,sha256=s3ZrAHg5TpJakadAAGY1h0wDw_xqN4Je4aJwJyRBmk4,61
35
- neuro_simulator/services/audience.py,sha256=sAmvkz1ip1MNqaw7t-9abqfnmp0yh8EdG5bS5KYR-Us,4999
36
48
  neuro_simulator/services/audio.py,sha256=EElBue80njZY8_CKQhVtZEcGchJUdmS4EDOvJEEu_LY,2909
37
49
  neuro_simulator/services/builtin.py,sha256=7b5F2StGX2ZT1jMiAAuqov0mx5OMHvUYheo8E1c9fjQ,6097
38
50
  neuro_simulator/services/letta.py,sha256=OEM4qYeRRPoj8qY645YZwCHmMfg1McLp0eTbSAu3KL0,11976
39
- neuro_simulator/services/stream.py,sha256=eueAaxhAwX_n0mT1W0W4YOVCe7fH5uPoMdRf2o0wQMI,5937
51
+ neuro_simulator/services/stream.py,sha256=9k8bNnQu237WMf1qX8OMfItAPEZkaZ4NEiI4FQ_7Ww4,6058
40
52
  neuro_simulator/utils/__init__.py,sha256=xSEFzjT827W81mNyQ_DLtr00TgFlttqfFgpz9pSxFXQ,58
41
53
  neuro_simulator/utils/logging.py,sha256=fAM8mW4czr0RLgAUS6oN-YTWKj5daqwc5g7yjyAgaPw,3892
42
54
  neuro_simulator/utils/process.py,sha256=9OYWx8fzaJZqmFUcjQX37AnBhl7YWvrLxDWBa30vqwU,3192
43
- neuro_simulator/utils/queue.py,sha256=bg-mIFF8ycClwmmfcKSPjAXtvjImzTKf6z7xZc2VX20,2196
55
+ neuro_simulator/utils/queue.py,sha256=pyBiFSSO1ocUF0kZfXvOywVcyYAwk8XDBXR8jJLkgSI,2701
44
56
  neuro_simulator/utils/state.py,sha256=DdBqSAYfjOFtJfB1hEGhYPh32r1ZvFuVlN_-29_-luA,664
45
57
  neuro_simulator/utils/websocket.py,sha256=fjC-qipzjgM_e7XImP12DFmLhvxkMOSr2GnUWws7esE,2058
46
- neuro_simulator-0.4.3.dist-info/METADATA,sha256=2cAnGJWSywTFI4vjaTyogCXdh6n6T681-Bk4PBSg-hs,7675
47
- neuro_simulator-0.4.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
- neuro_simulator-0.4.3.dist-info/entry_points.txt,sha256=qVd5ypnRRgU8Cw7rWfZ7o0OXyS9P9hgY-cRoN_mgz9g,51
49
- neuro_simulator-0.4.3.dist-info/top_level.txt,sha256=V8awSKpcrFnjJDiJxSfy7jtOrnuE2BgAR9hLmfMDWK8,16
50
- neuro_simulator-0.4.3.dist-info/RECORD,,
58
+ neuro_simulator-0.5.0.dist-info/METADATA,sha256=yaElYaysfpSen1W2igb9eR8eTZWHF2N7F-O-4w1Ig3c,7675
59
+ neuro_simulator-0.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
+ neuro_simulator-0.5.0.dist-info/entry_points.txt,sha256=qVd5ypnRRgU8Cw7rWfZ7o0OXyS9P9hgY-cRoN_mgz9g,51
61
+ neuro_simulator-0.5.0.dist-info/top_level.txt,sha256=V8awSKpcrFnjJDiJxSfy7jtOrnuE2BgAR9hLmfMDWK8,16
62
+ neuro_simulator-0.5.0.dist-info/RECORD,,
@@ -1,102 +0,0 @@
1
- # neuro_simulator/services/audience.py
2
- import logging
3
-
4
- from google import genai
5
- from google.genai import types
6
- from openai import AsyncOpenAI
7
-
8
- from ..core.config import config_manager, AppSettings
9
- from ..utils.state import app_state
10
-
11
- logger = logging.getLogger(__name__.replace("neuro_simulator", "server", 1))
12
-
13
- class AudienceLLMClient:
14
- async def generate_chat_messages(self, prompt: str, max_tokens: int) -> str:
15
- raise NotImplementedError
16
-
17
- class GeminiAudienceLLM(AudienceLLMClient):
18
- def __init__(self, api_key: str, model_name: str):
19
- if not api_key:
20
- raise ValueError("Gemini API Key is not provided for GeminiAudienceLLM.")
21
- self.client = genai.Client(api_key=api_key)
22
- self.model_name = model_name
23
- logger.info(f"Initialized GeminiAudienceLLM (new SDK), model: {self.model_name}")
24
-
25
- async def generate_chat_messages(self, prompt: str, max_tokens: int) -> str:
26
- response = await self.client.aio.models.generate_content(
27
- model=self.model_name,
28
- contents=prompt,
29
- config=types.GenerateContentConfig(
30
- temperature=config_manager.settings.audience_simulation.llm_temperature,
31
- max_output_tokens=max_tokens
32
- )
33
- )
34
- raw_chat_text = ""
35
- if hasattr(response, 'text') and response.text:
36
- raw_chat_text = response.text
37
- elif response.candidates and response.candidates[0].content and response.candidates[0].content.parts:
38
- for part in response.candidates[0].content.parts:
39
- if hasattr(part, 'text') and part.text:
40
- raw_chat_text += part.text
41
- return raw_chat_text
42
-
43
- class OpenAIAudienceLLM(AudienceLLMClient):
44
- def __init__(self, api_key: str, model_name: str, base_url: str | None):
45
- if not api_key:
46
- raise ValueError("OpenAI API Key is not provided for OpenAIAudienceLLM.")
47
- self.client = AsyncOpenAI(api_key=api_key, base_url=base_url)
48
- self.model_name = model_name
49
- logger.info(f"Initialized OpenAIAudienceLLM, model: {self.model_name}, API Base: {base_url}")
50
-
51
- async def generate_chat_messages(self, prompt: str, max_tokens: int) -> str:
52
- response = await self.client.chat.completions.create(
53
- model=self.model_name,
54
- messages=[{"role": "user", "content": prompt}],
55
- temperature=config_manager.settings.audience_simulation.llm_temperature,
56
- max_tokens=max_tokens,
57
- )
58
- if response.choices and response.choices[0].message and response.choices[0].message.content:
59
- return response.choices[0].message.content.strip()
60
- return ""
61
-
62
- async def get_dynamic_audience_prompt() -> str:
63
- current_neuro_speech = ""
64
- async with app_state.neuro_last_speech_lock:
65
- current_neuro_speech = app_state.neuro_last_speech
66
-
67
- prompt = config_manager.settings.audience_simulation.prompt_template.format(
68
- neuro_speech=current_neuro_speech,
69
- num_chats_to_generate=config_manager.settings.audience_simulation.chats_per_batch
70
- )
71
- return prompt
72
-
73
- class AudienceChatbotManager:
74
- def __init__(self):
75
- self.client: AudienceLLMClient = self._create_client(config_manager.settings)
76
- self._last_checked_settings: dict = config_manager.settings.audience_simulation.model_dump()
77
- logger.info("AudienceChatbotManager initialized.")
78
-
79
- def _create_client(self, settings: AppSettings) -> AudienceLLMClient:
80
- provider = settings.audience_simulation.llm_provider
81
- logger.info(f"Creating new audience LLM client for provider: {provider}")
82
- if provider.lower() == "gemini":
83
- if not settings.api_keys.gemini_api_key:
84
- raise ValueError("GEMINI_API_KEY not set in config")
85
- return GeminiAudienceLLM(api_key=settings.api_keys.gemini_api_key, model_name=settings.audience_simulation.gemini_model)
86
- elif provider.lower() == "openai":
87
- if not settings.api_keys.openai_api_key:
88
- raise ValueError("OPENAI_API_KEY not set in config")
89
- return OpenAIAudienceLLM(api_key=settings.api_keys.openai_api_key, model_name=settings.audience_simulation.openai_model, base_url=settings.api_keys.openai_api_base_url)
90
- else:
91
- raise ValueError(f"Unsupported AUDIENCE_LLM_PROVIDER: {provider}")
92
-
93
- def handle_config_update(self, new_settings: AppSettings):
94
- new_audience_settings = new_settings.audience_simulation.model_dump()
95
- if new_audience_settings != self._last_checked_settings:
96
- logger.info("Audience simulation settings changed, re-initializing LLM client...")
97
- try:
98
- self.client = self._create_client(new_settings)
99
- self._last_checked_settings = new_audience_settings
100
- logger.info("LLM client hot-reloaded successfully.")
101
- except Exception as e:
102
- logger.error(f"Error hot-reloading LLM client: {e}", exc_info=True)