From a2d76de690752d2a49d3b55983961bdb46e7888b Mon Sep 17 00:00:00 2001 From: jay Date: Sun, 18 Oct 2026 11:26:35 -0700 Subject: [PATCH 1/2] use models endpoint with openai backend --- oli_bot/chat.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/oli_bot/chat.py b/oli_bot/chat.py index d3e8984..4381027 100644 --- a/oli_bot/chat.py +++ b/oli_bot/chat.py @@ -1771,9 +1771,7 @@ def _server_switch(self, name: str) -> None: async def _show_model_picker(self) -> None: try: # Ollama's client has a list() method to retrieve available models, but other backends may not. - if hasattr(self.backend.client, "list") and callable( - getattr(self.backend.client, "list") - ): + if self.config.backend == "ollama": response = await self.backend.client.list() names = [m.model for m in response.models if m.model] if self.config.model_filters: @@ -1794,6 +1792,27 @@ async def _show_model_picker(self) -> None: model = await self.push_screen_wait(picker) if model: self._switch_model(model) + elif self.config.backend == "openai": + response = self.backend.client.models.list() + names = [m.id for m in response.data if m.id] + if self.config.model_filters: + exclude = [ + f.strip() + for f in self.config.model_filters.split(",") + if f.strip() + ] + if exclude: + names = [n for n in names if not any(ex in n for ex in exclude)] + if not names: + self._add_message( + "System", + "No models found for this backend.", + ) + return + picker = ModelPicker(names, current=self.backend.model) + model = await self.push_screen_wait(picker) + if model: + self._switch_model(model) else: self._add_message( "System", From 718b106c0f992bacfc7c75a8c5734e45873991cc Mon Sep 17 00:00:00 2001 From: jay Date: Sun, 18 Oct 2026 14:24:55 -0700 Subject: [PATCH 2/2] fix models call --- oli_bot/chat.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/oli_bot/chat.py b/oli_bot/chat.py index 4381027..d9105bc 100644 --- a/oli_bot/chat.py +++ b/oli_bot/chat.py @@ -1793,8 +1793,7 @@ async def _show_model_picker(self) -> None: if model: self._switch_model(model) elif self.config.backend == "openai": - response = self.backend.client.models.list() - names = [m.id for m in response.data if m.id] + names = [m.id async for m in self.backend.client.models.list()] if self.config.model_filters: exclude = [ f.strip()