Files

50 lines
1.7 KiB
Python

"""Вкладка «Модели» — единая библиотека моделей.
Здесь нет отдельных «моделей движков»: локальные GGUF, нативные `.xnh`
и модели серверных движков (Ollama, OpenAI-совместимые) показываются
одним списком в :class:`LibraryPane`.
"""
import customtkinter as ctk
from .base import ViewBase
from .library import LibraryPane
class ModelsView(ViewBase):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
self.title_text = "Модели"
self.configure(fg_color="transparent")
# Пути, добавленные вручную (переживают смену темы).
if self.app_state is not None:
self.extra_model_paths = self.app_state.extra_model_paths
else:
self.extra_model_paths = []
body = ctk.CTkFrame(self, fg_color="transparent")
body.pack(fill="both", expand=True, padx=16, pady=(12, 10))
body.grid_rowconfigure(0, weight=1)
body.grid_columnconfigure(0, weight=1)
self.library = LibraryPane(
body, self.app, self.engine, self.app_state,
on_open_chat=(lambda: self.app.switch_view("chat")) if self.app else None,
)
self.library.grid(row=0, column=0, sticky="nsew")
def reload_library(self):
if getattr(self, "library", None) is not None:
self.library.reload_library()
def on_show(self):
if getattr(self, "library", None) is not None:
self.library.on_show()
def shutdown(self):
try:
self.library.shutdown()
except Exception:
pass