Skip to content
Merged

Dev #54

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions oli_bot/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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",
Expand Down
Loading