Fix bugs, N+1 queries, and wire settings in persian-tutor
- Replace inline __import__("datetime").timedelta hack with proper import
- Remove unused import random in anki_export.py
- Add error handling for Claude CLI subprocess failures in ai.py
- Fix hardcoded absolute path in stt.py with relative Path resolution
- Fix N+1 DB queries in vocab.get_flashcard_batch and dashboard.get_category_breakdown
by adding db.get_all_word_progress() batch query
- Wire Ollama model and Whisper size settings to actually update config
via ai.set_ollama_model() and stt.set_whisper_size()
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import time
|
||||
|
||||
import gradio as gr
|
||||
|
||||
import ai
|
||||
import db
|
||||
from modules import vocab, dashboard, essay, tutor, idioms
|
||||
from modules.essay import GCSE_THEMES
|
||||
@@ -214,6 +215,15 @@ def do_anki_export(cats_selected):
|
||||
return path
|
||||
|
||||
|
||||
def update_ollama_model(model):
|
||||
ai.set_ollama_model(model)
|
||||
|
||||
|
||||
def update_whisper_size(size):
|
||||
from stt import set_whisper_size
|
||||
set_whisper_size(size)
|
||||
|
||||
|
||||
def reset_progress():
|
||||
conn = db.get_connection()
|
||||
conn.execute("DELETE FROM word_progress")
|
||||
@@ -491,6 +501,10 @@ with gr.Blocks(title="Persian Language Tutor") as app:
|
||||
|
||||
export_btn.click(fn=do_anki_export, inputs=[export_cats], outputs=[export_file])
|
||||
|
||||
# Wire model settings
|
||||
ollama_model.change(fn=update_ollama_model, inputs=[ollama_model])
|
||||
whisper_size.change(fn=update_whisper_size, inputs=[whisper_size])
|
||||
|
||||
gr.Markdown("### Reset")
|
||||
reset_btn = gr.Button("Reset All Progress", variant="stop")
|
||||
reset_status = gr.Markdown("")
|
||||
|
||||
Reference in New Issue
Block a user