Path for audio-logs' folder is now obtained from obsidian_settings

This commit is contained in:
dimitrievgs 2026-05-03 22:23:46 +03:00
parent a6053b3be6
commit e07de60438
2 changed files with 16 additions and 4 deletions

View File

@ -382,7 +382,7 @@ obsidian_settings_fetched = False
def get_voice_status(): def get_voice_status():
# 2. Вызываем метод у экземпляра voice_inst, а не у модуля # 2. Вызываем метод у экземпляра voice_inst, а не у модуля
return jsonify({ return jsonify({
"transcription": voice_inst.get_context_by_limit(3000, order='reversed'), "transcription": voice_inst.get_context_by_limit(current_obsidian_settings.get('voiceDisplayLimit', 0), order='reversed'),
"response1": list(voice_inst.responses["regular"]), "response1": list(voice_inst.responses["regular"]),
"response2": list(voice_inst.responses["commands"]), "response2": list(voice_inst.responses["commands"]),
"is_running": voice_inst.is_running, "is_running": voice_inst.is_running,
@ -405,6 +405,13 @@ def sync_settings():
if data: if data:
current_obsidian_settings.update(data) current_obsidian_settings.update(data)
# Передаем настройки в voice_service
if data.get('absoluteLogsPath'):
# Если фронт прислал вычисленный абсолютный путь
voice_inst.update_logs_config(
abs_path=data.get('absoluteLogsPath')
)
# TODO: Скорее всего, здесь нужно какое-то событие эмитировать об изменении настроек, и в другом месте ловить # TODO: Скорее всего, здесь нужно какое-то событие эмитировать об изменении настроек, и в другом месте ловить
graph_history_manager.title_generator.llm = get_llm(current_obsidian_settings['summarizationModel']) graph_history_manager.title_generator.llm = get_llm(current_obsidian_settings['summarizationModel'])
graph_history_manager.title_generator.voice_llm = get_llm(current_obsidian_settings['voiceCommandModel']) graph_history_manager.title_generator.voice_llm = get_llm(current_obsidian_settings['voiceCommandModel'])

View File

@ -27,6 +27,11 @@ class VoiceService:
} }
self.lock = threading.Lock() self.lock = threading.Lock()
self._stop_event = threading.Event() self._stop_event = threading.Event()
self.abs_logs_path = None
def update_logs_config(self, abs_path):
"""Обновление путей из настроек Obsidian."""
self.abs_logs_path = abs_path
def _load_history_from_file(self): def _load_history_from_file(self):
"""Парсит существующий файл лога в коллекцию self.history.""" """Парсит существующий файл лога в коллекцию self.history."""
@ -59,11 +64,11 @@ class VoiceService:
def start_session(self, continue_last=False): def start_session(self, continue_last=False):
if self.is_running: return if self.is_running: return
log_dir = "audio-logs" log_dir = self.abs_logs_path if self.abs_logs_path else "audio-logs"
if not os.path.exists(log_dir): os.makedirs(log_dir) if not os.path.exists(log_dir): os.makedirs(log_dir)
if continue_last: if continue_last:
files = sorted([f for f in os.listdir(log_dir) if f.endswith(".txt")]) files = sorted([f for f in os.listdir(log_dir) if f.endswith(".md")])
if files: if files:
self.current_file = os.path.join(log_dir, files[-1]) self.current_file = os.path.join(log_dir, files[-1])
# Загружаем старые реплики в память # Загружаем старые реплики в память
@ -80,7 +85,7 @@ class VoiceService:
threading.Thread(target=self._run_transcription, daemon=True).start() threading.Thread(target=self._run_transcription, daemon=True).start()
def _create_new_file(self, log_dir): def _create_new_file(self, log_dir):
name = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S.txt") name = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S.md")
path = os.path.join(log_dir, name) path = os.path.join(log_dir, name)
with open(path, "w", encoding="utf-8") as f: with open(path, "w", encoding="utf-8") as f:
f.write(f"--- Session Start: {name} ---\n\n") f.write(f"--- Session Start: {name} ---\n\n")