Fix settings naming
This commit is contained in:
parent
a737c3125a
commit
6ce3c9781b
16
app/api.py
16
app/api.py
|
|
@ -9,7 +9,7 @@ from flask import Flask, request, jsonify, Response, stream_with_context
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from flask_socketio import SocketIO
|
from flask_socketio import SocketIO
|
||||||
from workflows import graph_history_manager, run_agent_streaming
|
from workflows import graph_history_manager, run_agent_streaming
|
||||||
from llm_client import MODELS # Добавляем импорт списка моделей
|
from llm_client import MODELS, get_llm # Добавляем импорт списка моделей
|
||||||
|
|
||||||
api = Flask(__name__)
|
api = Flask(__name__)
|
||||||
CORS(
|
CORS(
|
||||||
|
|
@ -374,14 +374,7 @@ from app.voice_service import VoiceService, VOICE_COMMANDS_RESPONSE_TO_STORE
|
||||||
# 1. Создаем экземпляр (обязательно укажите путь к вашей модели Vosk)
|
# 1. Создаем экземпляр (обязательно укажите путь к вашей модели Vosk)
|
||||||
voice_inst = VoiceService(model_path=r"D:\\Work\\Software_Development\\Projects\\vosk\\vosk-model-small-ru-0.22")
|
voice_inst = VoiceService(model_path=r"D:\\Work\\Software_Development\\Projects\\vosk\\vosk-model-small-ru-0.22")
|
||||||
|
|
||||||
current_obsidian_settings = {
|
current_obsidian_settings = {}
|
||||||
'interval': 5,
|
|
||||||
'context_limit': 3000,
|
|
||||||
'voice_model': 'gemini-2.0-flash',
|
|
||||||
'marker_start': 'старт',
|
|
||||||
'marker_stop': 'стоп',
|
|
||||||
'voice_context_limit': 3000
|
|
||||||
}
|
|
||||||
|
|
||||||
obsidian_settings_fetched = False
|
obsidian_settings_fetched = False
|
||||||
|
|
||||||
|
|
@ -411,5 +404,10 @@ def sync_settings():
|
||||||
data = request.json
|
data = request.json
|
||||||
if data:
|
if data:
|
||||||
current_obsidian_settings.update(data)
|
current_obsidian_settings.update(data)
|
||||||
|
|
||||||
|
# TODO: Скорее всего, здесь нужно какое-то событие эмитировать об изменении настроек, и в другом месте ловить
|
||||||
|
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'])
|
||||||
|
|
||||||
print(f"✅⚙️ Settings synced: {current_obsidian_settings}")
|
print(f"✅⚙️ Settings synced: {current_obsidian_settings}")
|
||||||
return jsonify({"status": "synced"})
|
return jsonify({"status": "synced"})
|
||||||
|
|
@ -165,7 +165,7 @@ class VoiceHeartbeatMonitor(threading.Thread):
|
||||||
self._check_commands(obsidian_settings)
|
self._check_commands(obsidian_settings)
|
||||||
|
|
||||||
# 2. Регулярный запрос
|
# 2. Регулярный запрос
|
||||||
if time.time() - self.last_regular_run > obsidian_settings['interval'] * 60:
|
if time.time() - self.last_regular_run > obsidian_settings['voiceInterval'] * 60:
|
||||||
self._run_regular_analysis(obsidian_settings)
|
self._run_regular_analysis(obsidian_settings)
|
||||||
self.last_regular_run = time.time()
|
self.last_regular_run = time.time()
|
||||||
time.sleep(3) # каждые 3 секунды проверяем
|
time.sleep(3) # каждые 3 секунды проверяем
|
||||||
|
|
@ -174,13 +174,13 @@ class VoiceHeartbeatMonitor(threading.Thread):
|
||||||
|
|
||||||
def _check_commands(self, obsidian_settings):
|
def _check_commands(self, obsidian_settings):
|
||||||
# Получаем данные за последние секунды
|
# Получаем данные за последние секунды
|
||||||
raw_text = self.vs.get_last_chars(obsidian_settings['context_limit'])
|
raw_text = self.vs.get_last_chars(obsidian_settings['voiceContextLimit'])
|
||||||
|
|
||||||
import re
|
import re
|
||||||
# Чистим таймстемпы Vosk для LLM (удаляем паттерны [00:00:00])
|
# Чистим таймстемпы Vosk для LLM (удаляем паттерны [00:00:00])
|
||||||
clean_text = re.sub(r'\[.*?\]', '', raw_text)
|
clean_text = re.sub(r'\[.*?\]', '', raw_text)
|
||||||
|
|
||||||
pattern = f"{re.escape(obsidian_settings['marker_start'])}(.*?){re.escape(obsidian_settings['marker_stop'])}"
|
pattern = f"{re.escape(obsidian_settings['markerStart'])}(.*?){re.escape(obsidian_settings['markerStop'])}"
|
||||||
matches = re.findall(pattern, clean_text, re.DOTALL)
|
matches = re.findall(pattern, clean_text, re.DOTALL)
|
||||||
|
|
||||||
for match in matches:
|
for match in matches:
|
||||||
|
|
@ -194,7 +194,7 @@ class VoiceHeartbeatMonitor(threading.Thread):
|
||||||
print(f"🎤 New Voice Command detected: {cmd}")
|
print(f"🎤 New Voice Command detected: {cmd}")
|
||||||
|
|
||||||
# ОТПРАВЛЯЕМ В LLM через TitleGenerator
|
# ОТПРАВЛЯЕМ В LLM через TitleGenerator
|
||||||
prompt = f"{(obsidian_settings.get('systemPrompt') or '')}\n\n{(obsidian_settings.get('prompt_commands') or '')}"
|
prompt = f"{(obsidian_settings.get('systemPrompt') or '')}\n\n{(obsidian_settings.get('promptCommands') or '')}"
|
||||||
self.generator.add_voice_task_to_queue(
|
self.generator.add_voice_task_to_queue(
|
||||||
cmd,
|
cmd,
|
||||||
prompt
|
prompt
|
||||||
|
|
@ -205,10 +205,10 @@ class VoiceHeartbeatMonitor(threading.Thread):
|
||||||
if len(self._processed_hashes) > 100: self._processed_hashes.clear() # Спорно, очень спорно
|
if len(self._processed_hashes) > 100: self._processed_hashes.clear() # Спорно, очень спорно
|
||||||
|
|
||||||
def _run_regular_analysis(self, obsidian_settings):
|
def _run_regular_analysis(self, obsidian_settings):
|
||||||
raw_text = self.vs.get_last_chars(obsidian_settings['voice_context_limit'])
|
raw_text = self.vs.get_last_chars(obsidian_settings['voiceContextLimit'])
|
||||||
if not raw_text.strip(): return
|
if not raw_text.strip(): return
|
||||||
|
|
||||||
prompt = f"{(obsidian_settings.get('systemPrompt') or '')}\n\n{(obsidian_settings.get('prompt_regular') or '')}"
|
prompt = f"{(obsidian_settings.get('systemPrompt') or '')}\n\n{(obsidian_settings.get('promptRegular') or '')}"
|
||||||
|
|
||||||
# Добавим новый тип 'voice_regular' вTitleGenerator аналогично 'voice_command'
|
# Добавим новый тип 'voice_regular' вTitleGenerator аналогично 'voice_command'
|
||||||
self.generator.add_voice_regular_task(raw_text, prompt)
|
self.generator.add_voice_regular_task(raw_text, prompt)
|
||||||
Loading…
Reference in New Issue
Block a user