Skip to content

Commit 16a3833

Browse files
committed
Improve ollamaChat tab completion
We want tab completion to work with `ollamaChat("mistral",<TAB>`. That requires `ollamaChat.models` to return `"mistral"` in its list.
1 parent 2611327 commit 16a3833

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ollamaChat.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,17 @@
182182
endpoint = "http://localhost:11434/api/tags";
183183
response = webread(endpoint);
184184
mdls = string({response.models.name}).';
185+
baseMdls = unique(extractBefore(mdls,":"));
186+
% remove all those "mistral:latest", iff those are the only
187+
% model entries pointing at some model
188+
for base=baseMdls.'
189+
found = startsWith(mdls,base+":");
190+
if nnz(found) == 1
191+
mdls(found) = [];
192+
end
193+
end
194+
mdls = unique([mdls(:); baseMdls]);
195+
mdls(strlength(mdls) < 1) = [];
185196
end
186197
end
187198
end

tests/tollamaChat.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function queryModels(testCase)
128128
models = ollamaChat.models;
129129
testCase.verifyClass(models,"string");
130130
testCase.verifyThat(models, ...
131-
matlab.unittest.constraints.IsSupersetOf("mistral:latest"));
131+
matlab.unittest.constraints.IsSupersetOf("mistral"));
132132
end
133133
end
134134
end

0 commit comments

Comments
 (0)