mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-12 03:16:19 +00:00
Ask Codex itself which models it offers
The Codex model boxes carried a hand-written list, which was already out of date. The settings window now asks `codex debug models` for the catalog the CLI's own picker reads, off the interface thread, and refills both boxes with it; the built-in list is only what is on screen until Codex answers, or when it is not installed at all.
This commit is contained in:
@@ -338,6 +338,33 @@ def _codex_label(item):
|
||||
return t("Using {name}…", name=item_type or "a tool")
|
||||
|
||||
|
||||
def codex_models():
|
||||
"""The models Codex itself would offer right now, best first.
|
||||
|
||||
`codex debug models` prints the catalog the CLI's own model picker reads,
|
||||
fetched from OpenAI and cached beside Codex's config, so the list is as
|
||||
current as the installed Codex and there is no second list to keep up to
|
||||
date here. Entries the picker hides are internal and stay hidden. A machine
|
||||
without Codex, or one too old to have the command, answers with nothing and
|
||||
the caller keeps its built-in list.
|
||||
"""
|
||||
if not shutil.which("codex"):
|
||||
return []
|
||||
try:
|
||||
proc = subprocess.run(["codex", "debug", "models"],
|
||||
capture_output=True, text=True, timeout=30)
|
||||
catalog = json.loads(proc.stdout or "null")
|
||||
except (OSError, subprocess.SubprocessError, ValueError):
|
||||
return []
|
||||
if not isinstance(catalog, dict):
|
||||
return []
|
||||
rows = [row for row in catalog.get("models") or []
|
||||
if isinstance(row, dict) and row.get("slug")
|
||||
and row.get("visibility") != "hide"]
|
||||
rows.sort(key=lambda row: row.get("priority") or 0)
|
||||
return [row["slug"] for row in rows]
|
||||
|
||||
|
||||
# --- OpenRouter -----------------------------------------------------------
|
||||
|
||||
def _ask_openrouter(prompt, conf, on_stage):
|
||||
|
||||
+35
-1
@@ -79,7 +79,11 @@ ASSISTANT_PROVIDERS = [
|
||||
# Aliases resolve to the newest model of that name, so they age better than an
|
||||
# id does; a full id can be typed in when a particular one is wanted.
|
||||
ASSISTANT_MODELS = ["sonnet", "opus", "haiku", "fable"]
|
||||
CODEX_MODELS = ["gpt-5.4-codex", "gpt-5.4", "o4-mini"]
|
||||
# What the Codex boxes offer before Codex itself has answered, and everything
|
||||
# they offer when it cannot: the real list comes from `codex debug models` when
|
||||
# the window opens, so this only has to be roughly right.
|
||||
CODEX_MODELS = ["gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna",
|
||||
"gpt-5.5", "gpt-5.4", "gpt-5.4-mini"]
|
||||
# Starting points only; the box is editable and OpenRouter has hundreds.
|
||||
ASSISTANT_OR_MODELS = [
|
||||
"google/gemini-3.5-flash", "anthropic/claude-sonnet-5", "openai/gpt-5.4",
|
||||
@@ -521,6 +525,7 @@ class SettingsWindow(QDialog):
|
||||
|
||||
_models_loaded = pyqtSignal(list, str)
|
||||
_transcribe_models_loaded = pyqtSignal(list, str)
|
||||
_codex_models_loaded = pyqtSignal(list)
|
||||
# Which key was tested, whether it worked, and what to write under it.
|
||||
_test_done = pyqtSignal(str, bool, str)
|
||||
# The release that was found, or None, and what went wrong instead.
|
||||
@@ -577,6 +582,7 @@ class SettingsWindow(QDialog):
|
||||
|
||||
self._models_loaded.connect(self._on_models_loaded)
|
||||
self._transcribe_models_loaded.connect(self._on_transcribe_models_loaded)
|
||||
self._codex_models_loaded.connect(self._on_codex_models_loaded)
|
||||
self._test_done.connect(self._on_test_done)
|
||||
self._update_checked.connect(self._on_update_checked)
|
||||
self.transcriber.progress.connect(self._on_file_progress)
|
||||
@@ -587,6 +593,7 @@ class SettingsWindow(QDialog):
|
||||
self.meetings.finished.connect(self._on_minutes_finished)
|
||||
self.meetings.failed.connect(self._on_minutes_failed)
|
||||
self._load()
|
||||
self._load_codex_models()
|
||||
# Connected after the load, so that filling the boxes in is not taken
|
||||
# for the user ticking them.
|
||||
self.file_timestamps.toggled.connect(self._remember_file_choices)
|
||||
@@ -1876,6 +1883,33 @@ class SettingsWindow(QDialog):
|
||||
combo.setCurrentText(current)
|
||||
self.models_label.setText(t("{count} models loaded.", count=len(models)))
|
||||
|
||||
def _load_codex_models(self):
|
||||
"""Ask Codex which models it offers, off the interface thread.
|
||||
|
||||
No button and no network of ours: the CLI answers from its own cache in
|
||||
well under a second. Skipped when Codex is not installed, which is also
|
||||
when the built-in list stays on screen and nobody is running Codex
|
||||
anyway.
|
||||
"""
|
||||
if not shutil.which("codex"):
|
||||
return
|
||||
|
||||
def work():
|
||||
found = assistant.codex_models()
|
||||
if found:
|
||||
self._codex_models_loaded.emit(found)
|
||||
|
||||
threading.Thread(target=work, daemon=True).start()
|
||||
|
||||
def _on_codex_models_loaded(self, models):
|
||||
for combo in (self.cleanup_codex_model, self.assistant_codex_model):
|
||||
current = combo.currentText()
|
||||
combo.clear()
|
||||
combo.addItem(t("Codex's own default"), "")
|
||||
for name in models:
|
||||
combo.addItem(name, name)
|
||||
combo.setCurrentText(current)
|
||||
|
||||
def _test_openai(self):
|
||||
key, base = self._typed_key("openai")
|
||||
self._test_key("openai", lambda: t(
|
||||
|
||||
Reference in New Issue
Block a user