diff --git a/oli_bot/chat.py b/oli_bot/chat.py index d3e8984..d9105bc 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,26 @@ 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": + names = [m.id async for m in self.backend.client.models.list()] + 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",