Ollama chat with streaming mode using TextArea component

3 vues (au cours des 30 derniers jours)
Iori Sumida
Iori Sumida le 30 Avr 2025
I refered the follow URL to implement.
This example shows "Print stream to HTML UI Component". But I'd like to use TextArea component instead.
As the callback function of addChat
function addChat(app, content)
app.TextArea.Value = [app.TextArea.Value, content];
pause(0.1);
drawnow
end
To setup the ollama chat,
app.chat = ollamaChat("gemma3:12b", ...
systemPrompt, ...
Temperature=0.2, ...
StreamFun=@(x) app.addChat(x), ...
TimeOut=600);
Then, in order to generate text like following;
prompt = "Context:" + join(selectedDocs, " ") + newline + ...
"Answer the following question: " + query;
app.history = addUserMessage(app.history, prompt);
[text, response] = generate(app.chat, app.history);
app.addChat(text);
app.history = addResponseMessage(app.history, response);
However, it was not possble to type text retrieved from ollama chat in streaming mode.
I appreciate you could find the solution.
Iori

Réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Produits


Version

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by