Skip to content

Commit b67f5ef

Browse files
committed
new static method ollamaChat.models
1 parent e229935 commit b67f5ef

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

ollamaChat.m

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,22 @@
151151
TimeOut=this.TimeOut, StreamFun=this.StreamFun);
152152
end
153153
end
154-
end
155154

156-
function mustBeNonzeroLengthTextScalar(content)
157-
mustBeNonzeroLengthText(content)
158-
mustBeTextScalar(content)
155+
methods(Static)
156+
function mdls = models
157+
%ollamaChat.models - return models available on ollama server
158+
% MDLS = ollamaChat.models returns a string vector MDLS
159+
% listing the models available on the local ollama server.
160+
%
161+
% These names can be used in the ollamaChat constructor.
162+
% For names with a colon, such as "phi:latest", it is
163+
% possible to only use the part before the colon, i.e.,
164+
% "phi".
165+
endpoint = "http://localhost:11434/api/tags";
166+
response = webread(endpoint);
167+
mdls = string({response.models.name}).';
168+
end
169+
end
159170
end
160171

161172
function mustBeValidMsgs(value)

tests/tollamaChat.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ function assignValueToProperty(property, value)
100100

101101
testCase.verifyWarningFree(@() assignValueToProperty(ValidValuesSetters.Property,ValidValuesSetters.Value));
102102
end
103+
104+
function queryModels(testCase)
105+
% our test setup has at least mistral loaded
106+
models = ollamaChat.models;
107+
testCase.verifyClass(models,"string");
108+
testCase.verifyThat(models, ...
109+
matlab.unittest.constraints.IsSupersetOf("mistral:latest"));
110+
end
103111
end
104112
end
105113

0 commit comments

Comments
 (0)