text = aiask(prompt)
[text, response] = aiask(prompt, options)
aiask calls a configured AI provider such as Ollama or an OpenAI-compatible HTTP endpoint.
For Ollama, aiask uses the local HTTP API endpoint http://127.0.0.1:11434/api/generate by default and sends non-streaming requests.
This function asks the provider directly from Nelson. It does not expose MCP tools. Use mcpserver when an external agent must call Nelson tools.
% In a terminal, start Ollama and pull a model first:
% ollama serve
% ollama pull llama3.2
opts = aioptions('Provider', 'ollama', ...
'Model', 'llama3.2', ...
'Endpoint', 'http://127.0.0.1:11434/api/generate', ...
'Timeout', 120, ...
'SystemPrompt', 'Return only Nelson code. Nelson functions use syntax: function y = name(x), statements, end.', ...
'Think', false, ...
'NumPredict', 200, ...
'Temperature', 0);
answer = aiask('Write function y = vector_mean(x). Use y = mean(x).', opts)
opts = aioptions('Provider', 'ollama', 'Model', 'llama3.2');
[text, response] = aiask('Explain the difference between plot and semilogy in Nelson.', opts);
disp(text)
disp(response.total_duration)
models = aimodels();
opts = aioptions('Provider', 'ollama', ...
'Model', models{1}, ...
'SystemPrompt', 'Return only Nelson code. Nelson functions use syntax: function y = name(x), statements, end.', ...
'Think', false, ...
'NumPredict', 120, ...
'Temperature', 0);
answer = aiask('Write function y = vector_mean(x). Use y = mean(x).', opts)
| Version | Description |
|---|---|
| 2.0.0 | initial version |